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 <ddiblik@redhat.com>

* Switch order of conditions in outdated_kernel fixture

Signed-off-by: Daniel Diblik <ddiblik@redhat.com>

* Adjust tests after rebase, add non-sca tags

Signed-off-by: Daniel Diblik <ddiblik@redhat.com>

---------

Signed-off-by: Daniel Diblik <ddiblik@redhat.com>
  • Loading branch information
danmyway authored Sep 3, 2024
1 parent 90e8a60 commit 2a0ed40
Show file tree
Hide file tree
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
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions tests/ansible_collections/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
Expand Down Expand Up @@ -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
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/tier0/non-destructive/els/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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"],
)
Expand Down
1 change: 1 addition & 0 deletions tests/integration/tier0/non-destructive/eus/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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)
Expand All @@ -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"],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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")
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Loading

0 comments on commit 2a0ed40

Please sign in to comment.