Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RHELC-788] Implement integration test error after ponr #1265

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions plans/tier1.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,16 @@ adjust+:
discover+:
test+<:
- proxy-conversion/proxy_conversion

/error-after-ponr:
enabled: false
adjust+:
- enabled: true
when: distro == alma-9, rocky-9, oracle-9
because: It will behave the same anywhere. Too expensive to run it on more hosts.
discover+:
SerCantus marked this conversation as resolved.
Show resolved Hide resolved
# Disregarding inheritance in the test discovery.
# As the conversion fails and the system is left in an undetermined state,
# we can't perform any checks after the conversion.
test:
- error-after-ponr
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def test_conversion_with_config_file(convert2rhel):
create_files(config)

with convert2rhel("-y --serverurl {} --debug".format(TEST_VARS["RHSM_SERVER_URL"])) as c2r:
c2r.expect("DEBUG - Found activation_key in /root/.convert2rhel.ini")
c2r.expect("DEBUG - Found org in /root/.convert2rhel.ini")
c2r.expect("DEBUG - Found activation_key in subscription_manager")
c2r.expect("DEBUG - Found org in subscription_manager")
c2r.expect("Conversion successful!")

assert c2r.exitstatus == 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
summary: |
Trigger a error after PONR
description: |
Verify that convert2rhel exits with 2 after a error in PONR
Verify that the error is logged with a message to the user
This test will break the machine, there is no reboot or checks after this test

/error_after_ponr:
test: pytest -m test_error_after_ponr
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from conftest import TEST_VARS


def test_error_after_ponr(convert2rhel, shell):
"""
Verify the improved explanatory log message is displayed to the user when a fail occurs
after the point of no return. Also verify that the exit code is 2.

This test destroys the machine so neither reboot nor any checks after conversion are called
"""
assert shell("yum install dnsmasq -y").returncode == 0
with convert2rhel(
"-y --serverurl {} --username {} --password {} --debug".format(
TEST_VARS["RHSM_SERVER_URL"],
TEST_VARS["RHSM_SCA_USERNAME"],
TEST_VARS["RHSM_SCA_PASSWORD"],
)
) as c2r:
# Wait until Point of no return appears. Then block all the internet connection
c2r.expect_exact("WARNING - The tool allows rollback of any action until this point.")
c2r.expect_exact("Convert: Replace system packages")

# Everything is resolved to localhost
with open("/etc/dnsmasq.conf", "a") as f:
f.write("address=/#/127.0.0.1")

with open("/etc/resolv.conf", "w") as f:
f.write("nameserver 127.0.0.1")

assert shell("systemctl enable dnsmasq && systemctl restart dnsmasq").returncode == 0

c2r.expect("WARNING - The conversion process failed")
c2r.expect(
"The system is left in an undetermined state that Convert2RHEL cannot fix. The system might not be fully converted, and might incorrectly be reporting as a Red Hat Enterprise Linux machine"
)
c2r.expect(
"It is strongly recommended to store the Convert2RHEL logs for later investigation, and restore the system from a backup"
)

assert c2r.exitstatus == 2
Loading