From d0eab543ff2fb45cb8e70cc779d3d245d393e9e7 Mon Sep 17 00:00:00 2001 From: Martin 'kokesak' Litwora Date: Thu, 26 Sep 2024 17:02:25 +0200 Subject: [PATCH] Try to block the internet connection after PONR --- .../destructive/error-after-ponr/main.fmf | 2 +- .../error-after-ponr/test_error_after_ponr.py | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/integration/tier1/destructive/error-after-ponr/main.fmf b/tests/integration/tier1/destructive/error-after-ponr/main.fmf index e3c45ea53d..7bf3a84d50 100644 --- a/tests/integration/tier1/destructive/error-after-ponr/main.fmf +++ b/tests/integration/tier1/destructive/error-after-ponr/main.fmf @@ -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 diff --git a/tests/integration/tier1/destructive/error-after-ponr/test_error_after_ponr.py b/tests/integration/tier1/destructive/error-after-ponr/test_error_after_ponr.py index ebb3121f4b..a8ffc98518 100644 --- a/tests/integration/tier1/destructive/error-after-ponr/test_error_after_ponr.py +++ b/tests/integration/tier1/destructive/error-after-ponr/test_error_after_ponr.py @@ -4,10 +4,11 @@ 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"], @@ -15,11 +16,18 @@ def test_error_after_ponr(convert2rhel, shell): 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( @@ -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