Skip to content

Commit

Permalink
[RHELC-1105] Try using SCA enabled account in tests (#1186)
Browse files Browse the repository at this point in the history
* Try using SCA enabled account in tests

Signed-off-by: Daniel Diblik <[email protected]>

* Switch order of conditions in outdated_kernel fixture

Signed-off-by: Daniel Diblik <[email protected]>

* Adjust tests after rebase, add non-sca tags

Signed-off-by: Daniel Diblik <[email protected]>

---------

Signed-off-by: Daniel Diblik <[email protected]>
danmyway authored Sep 3, 2024
1 parent 90e8a60 commit 2a0ed40
Showing 41 changed files with 156 additions and 175 deletions.
6 changes: 6 additions & 0 deletions plans/tier1.fmf
Original file line number Diff line number Diff line change
@@ -226,6 +226,12 @@ adjust+:
- kernel-boot-files/missing_kernel_boot_files

/corrupted_initramfs_file:
adjust+:
- enabled: false
when: distro == alma-8-latest, alma-9-latest, rocky-8.8
because: |
An unhandled UnicodeDecodeError breaks the conversion.
Reference https://issues.redhat.com/browse/RHELC-1711
discover+:
test+<:
- kernel-boot-files/corrupted_initramfs_file
5 changes: 2 additions & 3 deletions tests/ansible_collections/group_vars/all.yml
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ build_rpm: "{{ lookup('env', 'ANSIBLE_BUILD_RPM') }}"
rpm_provider: "{{ lookup('env', 'ANSIBLE_RPM_PROVIDER') }}"
rpm_url_el7: "{{ lookup('env', 'ANSIBLE_RPM_URL_EL7') }}"
rpm_url_el8: "{{ lookup('env', 'ANSIBLE_RPM_URL_EL8') }}"
rhsm_pool: "{{ lookup('env', 'RHSM_POOL') }}"
rhsm_password: "{{ lookup('env', 'RHSM_PASSWORD') }}"
rhsm_username: "{{ lookup('env', 'RHSM_USERNAME') }}"
rhsm_password: "{{ lookup('env', 'RHSM_SCA_PASSWORD') }}"
rhsm_username: "{{ lookup('env', 'RHSM_SCA_USERNAME') }}"
rhsm_server_url: "{{ lookup('env', 'RHSM_SERVER_URL') }}"
30 changes: 13 additions & 17 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -221,13 +221,12 @@ def convert2rhel(shell):
>>> (
>>> "-y "
>>> "--serverurl {} --username {} "
>>> "--password {} --pool {} "
>>> "--password {} "
>>> "--debug"
>>> ).format(
>>> TEST_VARS["RHSM_SERVER_URL"],
>>> TEST_VARS["RHSM_USERNAME"],
>>> TEST_VARS["RHSM_PASSWORD"],
>>> TEST_VARS["RHSM_POOL"],
>>> TEST_VARS["RHSM_SCA_USERNAME"],
>>> TEST_VARS["RHSM_SCA_PASSWORD"],
>>> )
>>> ) as c2r:
>>> c2r.expect("Kernel is compatible with RHEL")
@@ -607,14 +606,14 @@ def pre_registered(shell, request):
A fixture to install subscription manager and pre-register the system prior to the convert2rhel run.
We're using the client-tools-for-rhel-<version>-rpms repository to install the subscription-manager package from.
The rhn-client-tools package obsoletes the subscription-manager, so we remove the package on Oracle Linux.
By default, the RHSM_USERNAME and RHSM_PASSWORD is passed to the subman registration.
By default, the RHSM_SCA_USERNAME and RHSM_SCA_PASSWORD is passed to the subman registration.
Can be parametrized by requesting a different KEY from the TEST_VARS file.
@pytest.mark.parametrize("pre_registered", [("DIFFERENT_USERNAME", "DIFFERENT_PASSWORD")], indirect=True)
"""
subman = SubscriptionManager()

username = TEST_VARS["RHSM_USERNAME"]
password = TEST_VARS["RHSM_PASSWORD"]
username = TEST_VARS["RHSM_SCA_USERNAME"]
password = TEST_VARS["RHSM_SCA_PASSWORD"]
# Use custom keys when the fixture is parametrized
if hasattr(request, "param"):
username_key, password_key = request.param
@@ -635,9 +634,6 @@ def pre_registered(shell, request):
== 0
)

if "C2R_TESTS_NOSUB" not in os.environ:
assert shell("subscription-manager attach --pool {}".format(TEST_VARS["RHSM_POOL"])).returncode == 0

rhsm_uuid_command = "subscription-manager identity | grep identity"

uuid_raw_output = shell(rhsm_uuid_command).output
@@ -745,12 +741,6 @@ def outdated_kernel(shell, hybrid_rocky_image):
pytest.skip("The `kernel` fixture has already run.")

if os.environ["TMT_REBOOT_COUNT"] == "0":
# Verify that there is multiple kernels installed
if int(shell("rpm -q kernel | wc -l").output.strip()) > 1:
# We don't need to do anything at this point
# The whole setup needed happens after
pass

# There won't be much changes for EL 7 packages anymore
# We can hardcode this then
# The release part differs a bit on CentOS and Oracle,
@@ -759,11 +749,17 @@ def outdated_kernel(shell, hybrid_rocky_image):
older_kernel = "kernel-3.10.0-1160.118*"
assert shell(f"yum install -y {older_kernel}").returncode == 0

# Verify that there is multiple kernels installed
if int(shell("rpm -q kernel | wc -l").output.strip()) > 1:
# We don't need to do anything at this point
# The whole setup needed happens after
pass

# Try to downgrade kernel version, if there is not multiple versions installed already.
# If the kernel downgrade fails, assume it's not possible and try to install from
# an older repo. This should only happen when Alma and Rocky has just landed on
# a fresh minor version.
elif shell("yum downgrade kernel -y").returncode != 0:
elif shell("yum downgrade kernel -y").returncode == 1:
# Assuming this can only happen with Alma and Rocky we'll try to install an older kernel
# from a previous minor version.
# For that we need to use the vault url and bump te current minor down one version.
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ def test_activation_key_conversion(convert2rhel):
with convert2rhel(
"-y --serverurl {} -k {} -o {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_KEY"],
TEST_VARS["RHSM_ORG"],
TEST_VARS["RHSM_SCA_KEY"],
TEST_VARS["RHSM_SCA_ORG"],
)
) as c2r:
c2r.expect("Conversion successful!")
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ def test_conversion_with_config_file(convert2rhel):
Use config file to feed the credentials for the registration and verify a successful conversion.
"""
activation_key = "[subscription_manager]\nactivation_key = {}\norg = {}".format(
TEST_VARS["RHSM_KEY"], TEST_VARS["RHSM_ORG"]
TEST_VARS["RHSM_SCA_KEY"], TEST_VARS["RHSM_SCA_ORG"]
)
config = [Config("~/.convert2rhel.ini", activation_key)]
create_files(config)
Original file line number Diff line number Diff line change
@@ -3,11 +3,10 @@

def test_rhsm_conversion(convert2rhel):
with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("Conversion successful!")
Original file line number Diff line number Diff line change
@@ -14,8 +14,8 @@ def test_rhsm_with_eus_system_conversion(convert2rhel, shell):
with convert2rhel(
"-y --serverurl {} --username {} --password {} --debug --eus".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect_exact("Enabling RHEL repositories:")
Original file line number Diff line number Diff line change
@@ -35,11 +35,10 @@ def test_packages_upgraded_after_conversion(convert2rhel, shell):

# Run utility until the reboot
with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("Conversion successful!")
Original file line number Diff line number Diff line change
@@ -15,11 +15,10 @@ def test_single_yum_transaction(convert2rhel, shell):
pkgmanager = "dnf"

with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("no modifications to the system will happen this time.", timeout=1200)
Original file line number Diff line number Diff line change
@@ -22,11 +22,10 @@ def test_yum_distro_sync(convert2rhel, shell):
"""

with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("Conversion successful!")
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ def test_failures_and_skips_in_report(convert2rhel):
and it corresponds to its respective schema.
"""
with convert2rhel(
"analyze --serverurl {} --username test --password test --pool a_pool --debug".format(
"analyze --serverurl {} --username test --password test --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
)
) as c2r:
@@ -94,11 +94,10 @@ def test_successful_report(convert2rhel):
And does not contain: Error header, Skip header.
"""
with convert2rhel(
"analyze --serverurl {} --username {} --password {} --pool {} --debug".format(
"analyze --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
# We need to get past the data collection acknowledgement.
@@ -137,11 +136,10 @@ def test_convert_method_successful_report(convert2rhel):
Success header, Error header, Skip header.
"""
with convert2rhel(
"convert --serverurl {} --username {} --password {} --pool {} --debug".format(
"convert --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
# We need to get past the data collection acknowledgement.
Original file line number Diff line number Diff line change
@@ -140,8 +140,8 @@ def test_config_standard_paths_priority_diff_methods(convert2rhel, shell):
# fmt: off
(
"[subscription_manager]\n"
f"activation_key = {TEST_VARS['RHSM_KEY']}\n"
f"org = {TEST_VARS['RHSM_ORG']}\n"
f"activation_key = {TEST_VARS['RHSM_SCA_KEY']}\n"
f"org = {TEST_VARS['RHSM_SCA_ORG']}\n"
),
# fmt: on
),
@@ -182,8 +182,8 @@ def test_config_standard_paths_priority(convert2rhel):
# fmt: off
(
"[subscription_manager]\n"
f"username = {TEST_VARS['RHSM_USERNAME']}\n"
f"password = {TEST_VARS['RHSM_PASSWORD']}\n"
f"username = {TEST_VARS['RHSM_SCA_USERNAME']}\n"
f"password = {TEST_VARS['RHSM_SCA_PASSWORD']}\n"
),
# fmt: on
),
Original file line number Diff line number Diff line change
@@ -54,8 +54,8 @@ def test_duplicate_packages_installed(convert2rhel, install_duplicate_pkg):
with convert2rhel(
"analyze -y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
# The error about duplicate packages should be included at the end of the pre-conversion analysis report
2 changes: 2 additions & 0 deletions tests/integration/tier0/non-destructive/els/main.fmf
Original file line number Diff line number Diff line change
@@ -32,7 +32,9 @@ adjust+:
Verify that Convert2RHEL is working properly when ELS repositories are not available for conversions
(the account does not have the ELS SKU available) to RHEL ELS version (7.9)
and the --els option is provided. The regular repositories should be enabled as a fallback option.
We're deliberately using SCA disabled account for this scenario.
tag+:
- test-rhsm-non-els-account
- non-sca
test: |
pytest -m test_rhsm_non_els_account
Original file line number Diff line number Diff line change
@@ -96,11 +96,13 @@ def test_rhsm_non_els_account(convert2rhel):
Verify that Convert2RHEL is working properly when ELS repositories are not available for conversions
(the account does not have the ELS SKU available) to RHEL ELS version (7.9)
and the --els option is provided. The regular repositories should be enabled as a fallback option.
We're deliberately using SCA disabled account for this scenario.
"""

with convert2rhel(
"analyze -y --serverurl {} --username {} --password {} --debug --els".format(
TEST_VARS["RHSM_SERVER_URL"],
# We're deliberately using SCA disabled account for this
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
)
1 change: 1 addition & 0 deletions tests/integration/tier0/non-destructive/eus/main.fmf
Original file line number Diff line number Diff line change
@@ -40,5 +40,6 @@ adjust+:
should be enabled.
tag+:
- test-rhsm-non-eus-account
- non-sca
test: |
pytest -m test_rhsm_non_eus_account
Original file line number Diff line number Diff line change
@@ -89,7 +89,10 @@ def test_eus_enablement(
eus_mapping_update(modified_mapping)
with convert2rhel(
"analyze -y --debug --serverurl {} -u {} -p {} {}".format(
TEST_VARS["RHSM_SERVER_URL"], TEST_VARS["RHSM_USERNAME"], TEST_VARS["RHSM_PASSWORD"], additional_option
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
additional_option,
)
) as c2r:
c2r.expect(repoid_message, timeout=120)
@@ -115,11 +118,13 @@ def test_rhsm_non_eus_account(convert2rhel):
Verify that Convert2RHEL is working properly when EUS repositories are not available for conversions
(the account does not have the EUS SKU available) to RHEL EUS minor versions (8.6, ...)
and the --eus option is provided. The regular repositories should be enabled as a fallback option.
We're deliberately using SCA disabled account for this scenario.
"""

with convert2rhel(
"analyze -y --serverurl {} --username {} --password {} --debug --eus".format(
TEST_VARS["RHSM_SERVER_URL"],
# We're deliberately using SCA disabled account for this scenario.
TEST_VARS["RHSM_NON_EUS_USERNAME"],
TEST_VARS["RHSM_NON_EUS_PASSWORD"],
)
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ def test_firewalld_inhibitor(shell, convert2rhel):

with convert2rhel(
"-y --debug --serverurl {} --username {} --password {}".format(
TEST_VARS["RHSM_SERVER_URL"], TEST_VARS["RHSM_USERNAME"], TEST_VARS["RHSM_PASSWORD"]
TEST_VARS["RHSM_SERVER_URL"], TEST_VARS["RHSM_SCA_USERNAME"], TEST_VARS["RHSM_SCA_PASSWORD"]
),
unregister=True,
) as c2r:
Original file line number Diff line number Diff line change
@@ -36,11 +36,10 @@ def test_inhibitor_with_unavailable_kmod_loaded(kmod_in_different_directory, con
ENSURE_KERNEL_MODULES_COMPATIBILITY.UNSUPPORTED_KERNEL_MODULES.
"""
with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
),
unregister=True,
) as c2r:
@@ -60,12 +59,11 @@ def test_override_inhibitor_with_unavailable_kmod_loaded(
"""
environment_variables(envars)
with convert2rhel(
"--serverurl {} --username {} --password {} --pool {} --debug".format(
"--serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
)
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
),
) as c2r:
c2r.expect("Continue with the system conversion?")
c2r.sendline("y")
@@ -123,8 +121,8 @@ def test_override_inhibitor_with_tainted_kmod(shell, convert2rhel, forced_kmods,
with convert2rhel(
"--serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
),
unregister=True,
) as c2r:
@@ -178,11 +176,10 @@ def test_inhibitor_with_custom_built_tainted_kmod(custom_kmod, convert2rhel):
"""

with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
),
unregister=True,
) as c2r:
Original file line number Diff line number Diff line change
@@ -31,11 +31,10 @@ def test_releasever_modified_in_c2r_config(convert2rhel, os_release, c2r_config,
"""
with c2r_config.replace_line(pattern="releasever=.*", repl="releasever=333"):
with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
),
unregister=True,
) as c2r:
@@ -71,11 +70,10 @@ def test_inhibitor_releasever_noexistent_release(convert2rhel, config_at, os_rel
f"release {os_release.version[0]}.11.1111",
):
with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
),
unregister=True,
) as c2r:
Original file line number Diff line number Diff line change
@@ -37,8 +37,8 @@ def test_list_third_party_pkgs(convert2rhel, problematic_third_party_package):
with convert2rhel(
"analyze -y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
# Verify that the analysis report is printed
Original file line number Diff line number Diff line change
@@ -170,11 +170,10 @@ def test_proper_rhsm_clean_up(shell, convert2rhel):
packages_to_remove_at_cleanup = install_packages(shell, assign_packages())

with convert2rhel(
"analyze --serverurl {} --username {} --password {} --pool {} --debug".format(
"analyze --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("Continue with the system conversion?")
@@ -235,8 +234,8 @@ def test_terminate_on_registration_start(convert2rhel):
with convert2rhel(
"--debug -y --serverurl {} --username {} --password {}".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
),
unregister=True,
) as c2r:
@@ -255,8 +254,8 @@ def test_terminate_on_registration_success(convert2rhel):
with convert2rhel(
"--debug -y --serverurl {} --username {} --password {}".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
),
unregister=True,
) as c2r:
Original file line number Diff line number Diff line change
@@ -74,11 +74,10 @@ def test_package_download_error(convert2rhel, shell, yum_cache):
transaction.
"""
with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("Validate the {} transaction".format(PKGMANAGER))
@@ -115,11 +114,10 @@ def test_transaction_validation_error(convert2rhel, shell, yum_cache):
tool is doing a proper rollback when the transaction is being processed.
"""
with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect(
@@ -176,11 +174,10 @@ def test_packages_with_in_name_period(shell, convert2rhel, packages_with_period)
"""

with convert2rhel(
"analyze --serverurl {} --username {} --password {} --pool {} --debug".format(
"analyze --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
# Swallow the data collection warning
@@ -219,11 +216,10 @@ def test_override_exclude_list_in_yum_config(convert2rhel, outdated_kernel, yum_
if os.environ["TMT_REBOOT_COUNT"] == "1":
try:
with convert2rhel(
"analyze --serverurl {} --username {} --password {} --pool {} --debug -y".format(
"analyze --serverurl {} --username {} --password {} --debug -y".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("VALIDATE_PACKAGE_MANAGER_TRANSACTION has succeeded")
Original file line number Diff line number Diff line change
@@ -95,12 +95,11 @@ tag+:
description+: |
This test verifies that running conversion on pre-registered system
without an attached subscription will try auto attaching the subscription.
environment+:
C2R_TESTS_NOSUB: 1
test: |
pytest -m test_no_sca_not_subscribed
tag+:
- no-sca-not-subscribed
- non-sca

/no_sca_subscription_attachment_error:
summary+: |
@@ -110,9 +109,9 @@ tag+:
without an attached subscription will try auto attaching the subscription.
When the attachment fails, the SUBSCRIBE_SYSTEM::NO_ACCESS_TO_RHEL_REPOS
error is raised.
environment+:
C2R_TESTS_NOSUB: 1
We're deliberately using SCA disabled account without any available subscriptions for this scenario.
test: |
pytest -m test_no_sca_subscription_attachment_error
tag+:
- no-sca-subscription-attachment-error
- non-sca
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ def test_pre_registered_re_register(shell, pre_registered, convert2rhel):
"""
with convert2rhel(
"--debug --serverurl {} --username {} --password {}".format(
TEST_VARS["RHSM_SERVER_URL"], TEST_VARS["RHSM_USERNAME"], TEST_VARS["RHSM_PASSWORD"]
TEST_VARS["RHSM_SERVER_URL"], TEST_VARS["RHSM_SCA_USERNAME"], TEST_VARS["RHSM_SCA_PASSWORD"]
)
) as c2r:
# We need to get past the data collection acknowledgement.
@@ -74,10 +74,12 @@ def test_unregistered_no_credentials(shell, convert2rhel):
assert c2r.exitstatus == 2


@pytest.mark.parametrize("pre_registered", [("RHSM_USERNAME", "RHSM_PASSWORD")], indirect=True)
def test_no_sca_not_subscribed(shell, pre_registered, convert2rhel):
"""
This test verifies that running conversion on pre-registered system
without an attached subscription will try auto attaching the subscription.
SCA disabled account is used for this scenario.
"""
with convert2rhel("--debug") as c2r:
# We need to get past the data collection acknowledgement.
@@ -101,6 +103,7 @@ def test_no_sca_subscription_attachment_error(shell, convert2rhel, pre_registere
without an attached subscription will try auto attaching the subscription.
When the attachment fails, the SUBSCRIBE_SYSTEM::NO_ACCESS_TO_RHEL_REPOS
error is raised.
We're deliberately using SCA disabled account without any available subscriptions for this scenario.
"""
with convert2rhel("--debug") as c2r:
# We need to get past the data collection acknowledgement.
Original file line number Diff line number Diff line change
@@ -19,11 +19,10 @@ def test_sub_man_rollback(convert2rhel, shell, required_packages):
# due to not being able to expand the $releasever variable
for run in range(2):
with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
assert c2r.expect("Validate the dnf transaction") == 0
Original file line number Diff line number Diff line change
@@ -19,15 +19,13 @@ def test_empty_user_response_username_and_password(convert2rhel):

retries = 0
while True:
c2r.sendline(TEST_VARS["RHSM_USERNAME"])
print("Sending username:", TEST_VARS["RHSM_USERNAME"])
c2r.sendline(TEST_VARS["RHSM_SCA_USERNAME"])
c2r.expect("Password: ")
c2r.sendline()
try:
assert c2r.expect("Password", timeout=300) == 0
# Provide password, expect successful registration and subscription prompt
c2r.sendline(TEST_VARS["RHSM_PASSWORD"])
print("Sending password")
c2r.sendline(TEST_VARS["RHSM_SCA_PASSWORD"])
assert c2r.expect("System registration succeeded", timeout=180) == 0
break
except Exception:
Original file line number Diff line number Diff line change
@@ -23,11 +23,10 @@ def test_invalid_changes_to_grub_file(convert2rhel):
print(line, end="")

with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
assert c2r.expect("GRUB2 config file generation failed.") == 0
Original file line number Diff line number Diff line change
@@ -34,11 +34,10 @@ def test_valid_changes_to_grub_file(convert2rhel):
print(line, end="")

with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
assert c2r.expect("Successfully updated GRUB2 on the system.") == 0
Original file line number Diff line number Diff line change
@@ -14,11 +14,10 @@ def test_yum_conf_patch(convert2rhel, shell):
pkgmanager_conf = "/etc/dnf/dnf.conf"

with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("{} patched.".format(pkgmanager_conf))
Original file line number Diff line number Diff line change
@@ -51,11 +51,10 @@ def test_detect_correct_boot_partition(convert2rhel):
rhel_version = "7"

with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
assert c2r.expect("Calling command '/usr/sbin/blkid -p -s PART_ENTRY_NUMBER %s'" % boot_device) == 0
Original file line number Diff line number Diff line change
@@ -20,11 +20,10 @@ def test_excluded_packages_removed(shell, convert2rhel):

# run utility until the reboot
with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
pass
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ def test_firewalld_disabled_ol8(shell, convert2rhel):

with convert2rhel(
"-y --debug --serverurl {} --username {} --password {}".format(
TEST_VARS["RHSM_SERVER_URL"], TEST_VARS["RHSM_USERNAME"], TEST_VARS["RHSM_PASSWORD"]
TEST_VARS["RHSM_SERVER_URL"], TEST_VARS["RHSM_SCA_USERNAME"], TEST_VARS["RHSM_SCA_PASSWORD"]
),
) as c2r:
c2r.expect("Firewalld service reported that it is not running.")
Original file line number Diff line number Diff line change
@@ -56,8 +56,8 @@ def test_run_conversion_with_host_metering(shell, convert2rhel):
with convert2rhel(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("Installing host-metering packages")
Original file line number Diff line number Diff line change
@@ -81,11 +81,10 @@ def test_handling_corrupted_initramfs_file(convert2rhel, shell):
kernel_name = "kernel-core"

with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("Prepare: Final modifications to the system")
Original file line number Diff line number Diff line change
@@ -53,11 +53,10 @@ def test_handling_missing_kernel_boot_files(convert2rhel, shell):
kernel_name = "kernel-core"

with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("Prepare: Final modifications to the system")
Original file line number Diff line number Diff line change
@@ -39,11 +39,10 @@ def test_latest_kernel_check_skip(shell, convert2rhel, backup_directory):
shell("yum-config-manager --enable rhel-7-server-rpms --releasever 7Server")

with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
# Make sure the kernel comparison is skipped
Original file line number Diff line number Diff line change
@@ -51,11 +51,10 @@ def test_system_not_updated(shell, convert2rhel, downgrade_and_versionlock):
packages.
"""
with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("WARNING - YUM/DNF versionlock plugin is in use. It may cause the conversion to fail.")
@@ -70,11 +69,10 @@ def test_system_not_updated(shell, convert2rhel, downgrade_and_versionlock):

# Run utility until the reboot
with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("WARNING - YUM/DNF versionlock plugin is in use. It may cause the conversion to fail.")
Original file line number Diff line number Diff line change
@@ -13,11 +13,10 @@ def test_package_removed_from_centos_85(convert2rhel, shell):
assert shell("rpm -qi subscription-manager-initial-setup-addon").returncode == 0

with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("Conversion successful!")
Original file line number Diff line number Diff line change
@@ -13,11 +13,10 @@ def test_yum_conf_exclude_packages(convert2rhel, yum_conf_exclude):
Reference ticket: https://issues.redhat.com/browse/RHELC-774
"""
with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
c2r.expect("IS_LOADED_KERNEL_LATEST has succeeded")
Original file line number Diff line number Diff line change
@@ -60,11 +60,10 @@ def test_httpd_package_transaction_error(shell, convert2rhel, handle_packages):
"""
# run c2r analyze to verify the yum transaction
with convert2rhel(
"analyze -y --serverurl {} --username {} --password {} --pool {} --debug".format(
"analyze -y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
index = c2r.expect_exact(

0 comments on commit 2a0ed40

Please sign in to comment.