Skip to content

Commit

Permalink
Try to block the internet connection after PONR
Browse files Browse the repository at this point in the history
  • Loading branch information
kokesak committed Sep 27, 2024
1 parent e2d07de commit a5dd447
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
summary: |
Trigger a error after PONR
description: |
Verify that convert2rhel exits with 1 after a error in PONR
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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,30 @@
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 1.
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 "Replace system packages" task to cause the failure
# This will prevent yum restoring the original configuration
c2r.expect("CONVERT_SYSTEM_PACKAGES has succeeded")
# 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")

assert shell('echo "proxy=localhost" >> /etc/yum.conf').returncode == 0
# 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(
Expand All @@ -29,4 +37,4 @@ def test_error_after_ponr(convert2rhel, shell):
"It is strongly recommended to store the Convert2RHEL logs for later investigation, and restore the system from a backup"
)

assert c2r.exitstatus == 1
assert c2r.exitstatus == 2

0 comments on commit a5dd447

Please sign in to comment.