Skip to content

Commit

Permalink
Make the excluded kernel test destructive (#1346)
Browse files Browse the repository at this point in the history
  • Loading branch information
kokesak authored Aug 28, 2024
1 parent a73f357 commit 954dbe2
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 40 deletions.
19 changes: 13 additions & 6 deletions plans/tier1.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ adjust+:
- kernel-boot-files/corrupted_initramfs_file


/kernel-core-only:
/kernel_core_only:
enabled: false
adjust+:
- enabled: true
Expand All @@ -247,7 +247,14 @@ adjust+:
test+<:
- conversion-method/activation_key_conversion

/firewalld-disabled-ol8:

/yum_conf_exclude_packages:
discover+:
test+<:
- yum-conf-exclude-packages/yum_conf_exclude_packages


/firewalld_disabled_ol8:
enabled: false
adjust+:
- enabled: true
Expand All @@ -257,7 +264,7 @@ adjust+:
test+<:
- firewalld-disabled-ol8

/multiple-nic:
/multiple_nic:
enabled: false
adjust+:
- enabled: true
Expand All @@ -277,7 +284,7 @@ adjust+:
test+<:
- conversion-method/rhsm_conversion

/host-metering:
/host_metering:
enabled: false
adjust+:
- enabled: true
Expand All @@ -288,10 +295,10 @@ adjust+:
- host-metering/test_host_metering_conversion
test+:
- host-metering/check_active_host_metering
/proxy-server:
/proxy_server:
adjust+:
- enabled: false
when: distro == alma-9, oracle-9
when: distro == alma-9, oracle-9, rocky-9
because: The test is currently flaky on these targets. Needs further investigation.
discover+:
test+<:
Expand Down
9 changes: 8 additions & 1 deletion tests/integration/common/checks-after-conversion/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ order: 52

/verify_string_in_log:
summary+: |
Requested string is present in logfile
Requested string is present in a logfile
description+: |
Essentially a sanity check verifying required strings are present in a logfile.
In some cases, we do not need to catch an output during the conversion
Expand Down Expand Up @@ -152,6 +152,13 @@ order: 52
- traceback-not-present
test: pytest -m test_traceback_not_present

/check_empty_exclude_in_critical_commands:
summary+: |
Verify that convert2rhel used `--setopt=exclude= ` in every `repoquery` and `yumdownloader` call.
test: pytest -m test_check_empty_exclude_in_critical_commands
link:
- verifies: https://issues.redhat.com/browse/RHELC-774

/yum_check:
summary+: |
Run yum check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,22 @@ def test_traceback_not_present(log_file_data):
traceback_str = r"traceback"
match = re.search(traceback_str, log_file_data, re.IGNORECASE)
assert match is None, "Traceback found in the log file data."


def test_check_empty_exclude_in_critical_commands(log_file_data):
"""
Verify that convert2rhel used `--setopt=exclude=` in every `repoquery` and `yumdownloader` call.
Reference ticket: https://issues.redhat.com/browse/RHELC-774
"""
number_of_repoquery_calls = len(re.findall("Calling command 'repoquery", log_file_data))
number_of_repoquery_calls_with_exclude = len(
re.findall("Calling command 'repoquery.*--setopt=exclude=\s.*", log_file_data)
)
assert number_of_repoquery_calls != 0
assert number_of_repoquery_calls == number_of_repoquery_calls_with_exclude

number_of_yumdownloader_calls = len(re.findall("Calling command 'yumdownloader", log_file_data))
number_of_yumdownloader_calls_with_exclude = len(
re.findall("Calling command 'yumdownloader.*--setopt=exclude=\s.*", log_file_data)
)
assert number_of_yumdownloader_calls == number_of_yumdownloader_calls_with_exclude
14 changes: 0 additions & 14 deletions tests/integration/tier0/non-destructive/kernel/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@ tag+:
pytest -m test_verify_latest_kernel_check_passes_with_failed_repoquery


/yum_exclude_kernel:
summary+: |
Exclude kernel|kernel-core defined in yum config
description+: |
Verify, the conversion does not raise:
'Could not find any kernel from repositories to compare against the loaded kernel.'
When `exclude=kernel kernel-core` is defined in yum.conf
Verify IS_LOADED_KERNEL_LATEST has succeeded is raised and terminate the utility.
tag+:
- yum-exclude-kernel
test: |
pytest -m test_latest_kernel_check_with_yum_exclude_kernel_option


/outdated_kernel_error:
summary+: |
Outdated kernel version installed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,6 @@ def test_verify_latest_kernel_check_passes_with_failed_repoquery(convert2rhel, t
assert c2r.exitstatus == 1


@pytest.mark.parametrize("yum_conf_exclude", [["kernel", "kernel-core"]], indirect=True)
def test_latest_kernel_check_with_yum_exclude_kernel_option(convert2rhel, yum_conf_exclude):
"""
Verify, the conversion does not raise:
'Could not find any kernel from repositories to compare against the loaded kernel.'
When `exclude=kernel kernel-core` is defined in yum.conf
Verify IS_LOADED_KERNEL_LATEST has succeeded is raised and terminate the utility.
"""
# Run the conversion and verify that it proceeds past the latest kernel check
# if so, interrupt the conversion
with convert2rhel("-y --debug") as c2r:
if c2r.expect("IS_LOADED_KERNEL_LATEST has succeeded") == 0:
c2r.sendcontrol("c")
else:
assert AssertionError, "Utility did not raise IS_LOADED_KERNEL_LATEST has succeeded"

assert c2r.exitstatus == 1


def test_outdated_kernel_error(outdated_kernel, shell, convert2rhel):
"""
System has non latest kernel installed.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
summary+: |
Exclude kernel* and redhat-release-server packages in yum conf
description+: |
This tests verifies that it is possible to do a full conversion when
the all kernel packages (kernel*) and redhat-release-server is set to be excluded
in the yum configuration file.

tag+:
- kernel
link:
- verifies: https://issues.redhat.com/browse/RHELC-774
/yum_conf_exclude_packages:
test: pytest -m test_yum_conf_exclude_packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import pytest

from conftest import TEST_VARS


@pytest.mark.parametrize("yum_conf_exclude", [["kernel*", "redhat-release-server"]], indirect=True)
def test_yum_conf_exclude_packages(convert2rhel, yum_conf_exclude):
"""
Verify, the conversion does not raise:
'Could not find any kernel from repositories to compare against the loaded kernel.'
When `exclude=kernel kernel-core redhat-release-server` is defined in yum.conf
Verify IS_LOADED_KERNEL_LATEST has succeeded is raised.
Reference ticket: https://issues.redhat.com/browse/RHELC-774
"""
with convert2rhel(
"-y --serverurl {} --username {} --password {} --pool {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_USERNAME"],
TEST_VARS["RHSM_PASSWORD"],
TEST_VARS["RHSM_POOL"],
)
) as c2r:
c2r.expect("IS_LOADED_KERNEL_LATEST has succeeded")

assert c2r.exitstatus == 0

0 comments on commit 954dbe2

Please sign in to comment.