From c98f96ebe4425306c6674e34c526b5a1b97d081e Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Tue, 21 May 2024 00:17:05 -0400 Subject: [PATCH 01/29] Added the log message for the user system backup * This commit adds to the print_data_collection() to make sure the user knows to back up there system before running convert2rhel analyze --- convert2rhel/breadcrumbs.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/convert2rhel/breadcrumbs.py b/convert2rhel/breadcrumbs.py index 462752d5ad..de919df9f4 100644 --- a/convert2rhel/breadcrumbs.py +++ b/convert2rhel/breadcrumbs.py @@ -236,6 +236,14 @@ def print_data_collection(self): RHSM_CUSTOM_FACTS_FILE, ) + # Add in the warning about the system back up here! + loggerinst.warnign( + "Convert2RHEL modifies the systems during the analysis and then rolls back these" + " changes when the analysis is complete. In rare cases, this rollback can fail.\n" + "By continuing, you confirm that you have made a system backup and verified that" + " you can restore from the backup." + ) + utils.ask_to_continue() From 7239776024ee91f64af16a3ec90de6c73e5b8fe2 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Wed, 22 May 2024 13:09:51 -0400 Subject: [PATCH 02/29] Moved the log outside the print_data_collection() * it is better to have this outside of the print_data_collection() as it has nothing to do with that --- convert2rhel/breadcrumbs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/convert2rhel/breadcrumbs.py b/convert2rhel/breadcrumbs.py index de919df9f4..8fdd51061f 100644 --- a/convert2rhel/breadcrumbs.py +++ b/convert2rhel/breadcrumbs.py @@ -235,6 +235,7 @@ def print_data_collection(self): "- Convert2RHEL related environment variables\n\n", RHSM_CUSTOM_FACTS_FILE, ) + utils.ask_to_continue() # Add in the warning about the system back up here! loggerinst.warnign( From fc4c425bf4895d789e9054f41b3e64e1216c5b89 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Thu, 30 May 2024 11:03:52 -0400 Subject: [PATCH 03/29] Moved the confirmation of user backup * the confirmation for the users backup is now its own function and is seperated from the print_data_collection() as this has noting to do with that function * Added the call to the new function to be right after the print_data_collection() --- convert2rhel/breadcrumbs.py | 1 + convert2rhel/main.py | 1 + 2 files changed, 2 insertions(+) diff --git a/convert2rhel/breadcrumbs.py b/convert2rhel/breadcrumbs.py index 8fdd51061f..e69da96132 100644 --- a/convert2rhel/breadcrumbs.py +++ b/convert2rhel/breadcrumbs.py @@ -237,6 +237,7 @@ def print_data_collection(self): ) utils.ask_to_continue() + def confirm_backup(self): # Add in the warning about the system back up here! loggerinst.warnign( "Convert2RHEL modifies the systems during the analysis and then rolls back these" diff --git a/convert2rhel/main.py b/convert2rhel/main.py index 39f855b2cc..973f9a88c2 100644 --- a/convert2rhel/main.py +++ b/convert2rhel/main.py @@ -327,6 +327,7 @@ def perform_boilerplate(): loggerinst.task("Prepare: Inform about data collection") breadcrumbs.breadcrumbs.print_data_collection() + breadcrumbs.bredcrumbs.confirm_backup() def show_eula(): From 04a92e51cc4f8644671fda40ff81fa7eb70c3142 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Wed, 12 Jun 2024 13:56:00 -0400 Subject: [PATCH 04/29] Made a function for the user back up check * now the prompt to ask the user if they have a back up of there system is in a function * draft the unit test for this function --- convert2rhel/breadcrumbs.py | 10 ++++---- convert2rhel/unit_tests/breadcrumbs_test.py | 27 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/convert2rhel/breadcrumbs.py b/convert2rhel/breadcrumbs.py index e69da96132..394e2183f0 100644 --- a/convert2rhel/breadcrumbs.py +++ b/convert2rhel/breadcrumbs.py @@ -237,13 +237,13 @@ def print_data_collection(self): ) utils.ask_to_continue() - def confirm_backup(self): + def confirm_user_backup(self): # Add in the warning about the system back up here! loggerinst.warnign( - "Convert2RHEL modifies the systems during the analysis and then rolls back these" - " changes when the analysis is complete. In rare cases, this rollback can fail.\n" - "By continuing, you confirm that you have made a system backup and verified that" - " you can restore from the backup." + "Convert2RHEL modifies the systems during the analysis and then rolls back these " + "changes when the analysis is complete. In rare cases, this rollback can fail. " + "By continuing, you confirm that you have made a system backup and verified that " + "you can restore from the backup." ) utils.ask_to_continue() diff --git a/convert2rhel/unit_tests/breadcrumbs_test.py b/convert2rhel/unit_tests/breadcrumbs_test.py index 3d822b20bb..d9a1cb4600 100644 --- a/convert2rhel/unit_tests/breadcrumbs_test.py +++ b/convert2rhel/unit_tests/breadcrumbs_test.py @@ -18,13 +18,17 @@ __metaclass__ = type import json +import sys import pytest import six +import convert2rhel.toolopts + from convert2rhel import breadcrumbs, pkghandler, pkgmanager from convert2rhel.unit_tests import create_pkg_information, create_pkg_obj from convert2rhel.unit_tests.conftest import centos7 +from convert2rhel.unit_tests.toolopts_test import mock_cli_arguments six.add_move(six.MovedModule("mock", "mock", "unittest.mock")) @@ -344,3 +348,26 @@ def test_set_non_default_channel_els(global_tool_opts, monkeypatch): monkeypatch.setattr(breadcrumbs, "tool_opts", global_tool_opts) breadcrumbs.breadcrumbs._set_non_default_channel() assert breadcrumbs.breadcrumbs.non_default_channel == "ELS" +@pytest.mark.parametrize( + ("argv", "expected", "message"), + ( + ( + ["analyze"], + False, + "Convert2RHEL modifies the systems during the analysis and then rolls back these " + "changes when the analysis is complete. In rare cases, this rollback can fail. " + "By continuing, you confirm that you have made a system backup and verified that " + "you can restore from the backup.", + ), + ), +) +def test_confirm_user_backup(argv, expected, message, monkeypatch, global_tool_opts, caplog): + monkeypatch.setattr(sys, "argv", mock_cli_arguments(argv)) + try: + convert2rhel.toolopts.CLI() + except SystemExit: + pass + + # assert global_tool_opts.no_rpm_va == expected + if message: + assert message in caplog.text From 8722fdb318b55e18be7d00393f4860978985d572 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Wed, 26 Jun 2024 10:19:03 -0400 Subject: [PATCH 05/29] Moved the confirm_user_backup() to main.py *Moved the function and test to main.py, and main_test.py as this check doesn't align with what breadcrumbs.py is doing --- convert2rhel/breadcrumbs.py | 11 ----------- convert2rhel/main.py | 14 +++++++++++++- convert2rhel/unit_tests/breadcrumbs_test.py | 3 +++ convert2rhel/unit_tests/main_test.py | 13 +++++++++++++ 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/convert2rhel/breadcrumbs.py b/convert2rhel/breadcrumbs.py index 394e2183f0..fd7c3b5865 100644 --- a/convert2rhel/breadcrumbs.py +++ b/convert2rhel/breadcrumbs.py @@ -237,17 +237,6 @@ def print_data_collection(self): ) utils.ask_to_continue() - def confirm_user_backup(self): - # Add in the warning about the system back up here! - loggerinst.warnign( - "Convert2RHEL modifies the systems during the analysis and then rolls back these " - "changes when the analysis is complete. In rare cases, this rollback can fail. " - "By continuing, you confirm that you have made a system backup and verified that " - "you can restore from the backup." - ) - - utils.ask_to_continue() - def _write_obj_to_array_json(path, new_object, key): """Write new object to array defined by key in JSON file. diff --git a/convert2rhel/main.py b/convert2rhel/main.py index 973f9a88c2..0217b49171 100644 --- a/convert2rhel/main.py +++ b/convert2rhel/main.py @@ -314,6 +314,18 @@ def _handle_inhibitors_found_exception(): return ConversionExitCodes.INHIBITORS_FOUND +def confirm_user_backup(): + # Add in the warning about the system back up here! + loggerinst.warning( + "Convert2RHEL modifies the systems during the analysis and then rolls back these " + "changes when the analysis is complete. In rare cases, this rollback can fail. " + "By continuing, you confirm that you have made a system backup and verified that " + "you can restore from the backup." + ) + + utils.ask_to_continue() + + # # Boilerplate Tasks # @@ -327,7 +339,7 @@ def perform_boilerplate(): loggerinst.task("Prepare: Inform about data collection") breadcrumbs.breadcrumbs.print_data_collection() - breadcrumbs.bredcrumbs.confirm_backup() + confirm_user_backup() def show_eula(): diff --git a/convert2rhel/unit_tests/breadcrumbs_test.py b/convert2rhel/unit_tests/breadcrumbs_test.py index d9a1cb4600..f93fb6975a 100644 --- a/convert2rhel/unit_tests/breadcrumbs_test.py +++ b/convert2rhel/unit_tests/breadcrumbs_test.py @@ -334,6 +334,7 @@ def test_set_target_os(pretend_os): "name": "CentOS Linux", "version": "7.9", } == breadcrumbs.breadcrumbs.target_os +<<<<<<< HEAD def test_set_non_default_channel_eus(global_tool_opts, monkeypatch): @@ -371,3 +372,5 @@ def test_confirm_user_backup(argv, expected, message, monkeypatch, global_tool_o # assert global_tool_opts.no_rpm_va == expected if message: assert message in caplog.text +======= +>>>>>>> 05fa47ff (Moved the confirm_user_backup() to main.py) diff --git a/convert2rhel/unit_tests/main_test.py b/convert2rhel/unit_tests/main_test.py index 610781675d..530c0cbf98 100644 --- a/convert2rhel/unit_tests/main_test.py +++ b/convert2rhel/unit_tests/main_test.py @@ -768,3 +768,16 @@ def test_handle_inhibitors_found_exception(monkeypatch, rollback_failures, retur ret = main._handle_inhibitors_found_exception() assert ret == return_code + + +def test_confirm_user_backup(caplog): + message = ( + "Convert2RHEL modifies the systems during the analysis and then rolls back these " + "changes when the analysis is complete. In rare cases, this rollback can fail. " + "By continuing, you confirm that you have made a system backup and verified that " + "you can restore from the backup." + ) + + main.confirm_user_backup() + + assert message in caplog.text From ea55420a331a38a80fca40069248dc0a2a32e223 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Fri, 28 Jun 2024 10:58:08 -0400 Subject: [PATCH 06/29] Finnished the uint test for Confirm_user_backup() * This unit test was mostly done we just needed to account for the user input and now it does that and it passes --- convert2rhel/unit_tests/main_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/convert2rhel/unit_tests/main_test.py b/convert2rhel/unit_tests/main_test.py index 530c0cbf98..a77af4ac65 100644 --- a/convert2rhel/unit_tests/main_test.py +++ b/convert2rhel/unit_tests/main_test.py @@ -770,7 +770,8 @@ def test_handle_inhibitors_found_exception(monkeypatch, rollback_failures, retur assert ret == return_code -def test_confirm_user_backup(caplog): +@pytest.mark.parametrize("user_input", ["y", "n"]) +def test_confirm_user_backup(caplog, monkeypatch, user_input): message = ( "Convert2RHEL modifies the systems during the analysis and then rolls back these " "changes when the analysis is complete. In rare cases, this rollback can fail. " @@ -778,6 +779,9 @@ def test_confirm_user_backup(caplog): "you can restore from the backup." ) + # Simulate user input + monkeypatch.setattr("builtins.input", lambda _: user_input) + main.confirm_user_backup() assert message in caplog.text From 2fde33a5be9b2b799601c4afbe4be913f4f5556e Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Wed, 3 Jul 2024 02:44:36 -0400 Subject: [PATCH 07/29] Removed leftover imports from breadcrumbs_test.py * In the test for breadcrumbs_test.py there where imports for the test that were never used * fixed two tests that fail with the addition of this test because the function calls utils.ask_to_continue() more then the other tests expect --- convert2rhel/unit_tests/breadcrumbs_test.py | 4 ---- convert2rhel/unit_tests/main_test.py | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/convert2rhel/unit_tests/breadcrumbs_test.py b/convert2rhel/unit_tests/breadcrumbs_test.py index f93fb6975a..852bc463fa 100644 --- a/convert2rhel/unit_tests/breadcrumbs_test.py +++ b/convert2rhel/unit_tests/breadcrumbs_test.py @@ -18,17 +18,13 @@ __metaclass__ = type import json -import sys import pytest import six -import convert2rhel.toolopts - from convert2rhel import breadcrumbs, pkghandler, pkgmanager from convert2rhel.unit_tests import create_pkg_information, create_pkg_obj from convert2rhel.unit_tests.conftest import centos7 -from convert2rhel.unit_tests.toolopts_test import mock_cli_arguments six.add_move(six.MovedModule("mock", "mock", "unittest.mock")) diff --git a/convert2rhel/unit_tests/main_test.py b/convert2rhel/unit_tests/main_test.py index a77af4ac65..5e0aa0f529 100644 --- a/convert2rhel/unit_tests/main_test.py +++ b/convert2rhel/unit_tests/main_test.py @@ -285,7 +285,7 @@ def test_main(monkeypatch, global_tool_opts, tmp_path): assert raise_for_skipped_failures_mock.call_count == 2 assert report_summary_mock.call_count == 2 assert clear_versionlock_mock.call_count == 1 - assert ask_to_continue_mock.call_count == 1 + assert ask_to_continue_mock.call_count == 2 assert restart_system_mock.call_count == 1 assert summary_as_json_mock.call_count == 1 assert summary_as_txt_mock.call_count == 1 From ad0f23d149485a515de87371659b6f85a63cc1fc Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Wed, 10 Jul 2024 18:50:37 -0400 Subject: [PATCH 08/29] Draft used the mock for the users input * This commit changes the way the unit test is set up so that it now uses the ask_to_continue_mock in main_test to mock user input * Removed the import for unit test as the old test used it * Reverted the other uint tests that used the ask_to_continue_mock fuctions and set their values back to what they were before modification in the first commit --- convert2rhel/unit_tests/main_test.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/convert2rhel/unit_tests/main_test.py b/convert2rhel/unit_tests/main_test.py index 5e0aa0f529..c5ce0569cb 100644 --- a/convert2rhel/unit_tests/main_test.py +++ b/convert2rhel/unit_tests/main_test.py @@ -770,8 +770,13 @@ def test_handle_inhibitors_found_exception(monkeypatch, rollback_failures, retur assert ret == return_code -@pytest.mark.parametrize("user_input", ["y", "n"]) -def test_confirm_user_backup(caplog, monkeypatch, user_input): +def test_confirm_user_backup(monkeypatch, caplog): + ask_to_continue_mock = mock.Mock() + + monkeypatch.setattr(utils, "ask_to_continue", ask_to_continue_mock) + + main.confirm_user_backup() + message = ( "Convert2RHEL modifies the systems during the analysis and then rolls back these " "changes when the analysis is complete. In rare cases, this rollback can fail. " @@ -779,9 +784,4 @@ def test_confirm_user_backup(caplog, monkeypatch, user_input): "you can restore from the backup." ) - # Simulate user input - monkeypatch.setattr("builtins.input", lambda _: user_input) - - main.confirm_user_backup() - - assert message in caplog.text + assert ask_to_continue_mock.call_count == 1 From b5cc721456a9fae2e41a0e5d41ff66c2add63410 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Mon, 15 Jul 2024 21:21:29 -0400 Subject: [PATCH 09/29] Added the assert for the message --- convert2rhel/unit_tests/main_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/convert2rhel/unit_tests/main_test.py b/convert2rhel/unit_tests/main_test.py index c5ce0569cb..bebef770e5 100644 --- a/convert2rhel/unit_tests/main_test.py +++ b/convert2rhel/unit_tests/main_test.py @@ -784,4 +784,5 @@ def test_confirm_user_backup(monkeypatch, caplog): "you can restore from the backup." ) + assert message in caplog.records[-1].message assert ask_to_continue_mock.call_count == 1 From 105c5367f58d185e4cd76096a291849077840509 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Wed, 21 Aug 2024 13:03:28 -0400 Subject: [PATCH 10/29] Added a mock to ask_to_continue() in * in some of the other tests the ask_to_continue fuction is now being called from the test_confirm_user_backup() and this should be handled so for thoes functions a mock,monkeypatch, and a check was added. functions:test_main_rollback_analyze_exit_phase, test_main_rollback_analyze_exit_phase_without_subman, test_main_rollback_pre_ponr_changes_phase, test_main_traceback_before_action_completion, test_main_traceback_in_clear_versionlock, --- convert2rhel/unit_tests/main_test.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/convert2rhel/unit_tests/main_test.py b/convert2rhel/unit_tests/main_test.py index bebef770e5..94ab68b59e 100644 --- a/convert2rhel/unit_tests/main_test.py +++ b/convert2rhel/unit_tests/main_test.py @@ -315,6 +315,8 @@ def test_main_rollback_post_cli_phase(self, monkeypatch, caplog, tmp_path): assert "No changes were made to the system." in caplog.records[-2].message def test_main_traceback_in_clear_versionlock(self, caplog, monkeypatch, tmp_path): + ask_to_continue_mock = mock.Mock(return_value=True) + monkeypatch.setattr(applock, "_DEFAULT_LOCK_DIR", str(tmp_path)) monkeypatch.setattr(utils, "require_root", RequireRootMocked()) monkeypatch.setattr(main, "initialize_file_logging", InitializeFileLoggingMocked()) @@ -334,6 +336,8 @@ def test_main_traceback_in_clear_versionlock(self, caplog, monkeypatch, tmp_path ), ) + monkeypatch.setattr(utils, "ask_to_continue", ask_to_continue_mock) + # Mock rollback items monkeypatch.setattr(main, "rollback_changes", RollbackChangesMocked()) monkeypatch.setattr(main, "provide_status_after_rollback", PrintInfoAfterRollbackMocked()) @@ -349,6 +353,7 @@ def test_main_traceback_in_clear_versionlock(self, caplog, monkeypatch, tmp_path assert system_info.resolve_system_info.call_count == 1 assert breadcrumbs.collect_early_data.call_count == 1 assert pkghandler.clear_versionlock.call_count == 1 + assert ask_to_continue_mock.call_count == 1 assert main.rollback_changes.call_count == 0 assert main.provide_status_after_rollback.call_count == 0 @@ -372,6 +377,7 @@ def test_main_traceback_before_action_completion(self, monkeypatch, caplog, tmp_ clean_yum_metadata_mock = mock.Mock() run_pre_actions_mock = mock.Mock(side_effect=Exception("Action Framework Crashed")) clear_versionlock_mock = mock.Mock() + ask_to_continue_mock = mock.Mock(return_value=True) summary_as_txt_mock = mock.Mock() # Mock the rollback calls @@ -391,6 +397,7 @@ def test_main_traceback_before_action_completion(self, monkeypatch, caplog, tmp_ monkeypatch.setattr(system_info, "print_system_information", print_system_information_mock) monkeypatch.setattr(breadcrumbs, "collect_early_data", collect_early_data_mock) monkeypatch.setattr(pkghandler, "clear_versionlock", clear_versionlock_mock) + monkeypatch.setattr(utils, "ask_to_continue", ask_to_continue_mock) monkeypatch.setattr(pkgmanager, "clean_yum_metadata", clean_yum_metadata_mock) monkeypatch.setattr(actions, "run_pre_actions", run_pre_actions_mock) monkeypatch.setattr(breadcrumbs, "finish_collection", finish_collection_mock) @@ -411,6 +418,7 @@ def test_main_traceback_before_action_completion(self, monkeypatch, caplog, tmp_ assert clean_yum_metadata_mock.call_count == 1 assert run_pre_actions_mock.call_count == 1 assert clear_versionlock_mock.call_count == 1 + assert ask_to_continue_mock.call_count == 1 assert finish_collection_mock.call_count == 1 assert should_subscribe_mock.call_count == 1 assert update_rhsm_custom_facts_mock.call_count == 1 @@ -436,6 +444,7 @@ def test_main_rollback_pre_ponr_changes_phase(self, monkeypatch, tmp_path, globa run_pre_actions_mock = mock.Mock() report_summary_mock = mock.Mock() clear_versionlock_mock = mock.Mock() + ask_to_continue_mock = mock.Mock(return_value=True) find_actions_of_severity_mock = mock.Mock() summary_as_txt_mock = mock.Mock() @@ -456,6 +465,7 @@ def test_main_rollback_pre_ponr_changes_phase(self, monkeypatch, tmp_path, globa monkeypatch.setattr(system_info, "print_system_information", print_system_information_mock) monkeypatch.setattr(breadcrumbs, "collect_early_data", collect_early_data_mock) monkeypatch.setattr(pkghandler, "clear_versionlock", clear_versionlock_mock) + monkeypatch.setattr(utils, "ask_to_continue", ask_to_continue_mock) monkeypatch.setattr(pkgmanager, "clean_yum_metadata", clean_yum_metadata_mock) monkeypatch.setattr(actions, "run_pre_actions", run_pre_actions_mock) monkeypatch.setattr(report, "_summary", report_summary_mock) @@ -480,6 +490,7 @@ def test_main_rollback_pre_ponr_changes_phase(self, monkeypatch, tmp_path, globa assert report_summary_mock.call_count == 1 assert find_actions_of_severity_mock.call_count == 1 assert clear_versionlock_mock.call_count == 1 + assert ask_to_continue_mock.call_count == 1 assert finish_collection_mock.call_count == 1 assert should_subscribe_mock.call_count == 1 assert update_rhsm_custom_facts_mock.call_count == 1 @@ -507,6 +518,7 @@ def test_main_rollback_analyze_exit_phase_without_subman(self, global_tool_opts, (system_info, "print_system_information", mock.Mock()), (breadcrumbs, "collect_early_data", mock.Mock()), (pkghandler, "clear_versionlock", mock.Mock()), + (utils, "ask_to_continue", mock.Mock(return_value=True)), (pkgmanager, "clean_yum_metadata", mock.Mock()), (actions, "run_pre_actions", mock.Mock()), (report, "_summary", mock.Mock()), @@ -530,6 +542,7 @@ def test_main_rollback_analyze_exit_phase_without_subman(self, global_tool_opts, assert system_info.print_system_information.call_count == 1 assert breadcrumbs.collect_early_data.call_count == 1 assert pkghandler.clear_versionlock.call_count == 1 + assert utils.ask_to_continue.call_count == 1 assert pkgmanager.clean_yum_metadata.call_count == 1 assert actions.run_pre_actions.call_count == 1 assert report._summary.call_count == 1 @@ -553,6 +566,7 @@ def test_main_rollback_analyze_exit_phase(self, global_tool_opts, monkeypatch, t run_pre_actions_mock = mock.Mock() report_summary_mock = mock.Mock() clear_versionlock_mock = mock.Mock() + ask_to_continue_mock = mock.Mock(return_value=True) summary_as_json_mock = mock.Mock() summary_as_txt_mock = mock.Mock() @@ -572,6 +586,7 @@ def test_main_rollback_analyze_exit_phase(self, global_tool_opts, monkeypatch, t monkeypatch.setattr(system_info, "print_system_information", print_system_information_mock) monkeypatch.setattr(breadcrumbs, "collect_early_data", collect_early_data_mock) monkeypatch.setattr(pkghandler, "clear_versionlock", clear_versionlock_mock) + monkeypatch.setattr(utils, "ask_to_continue", ask_to_continue_mock) monkeypatch.setattr(pkgmanager, "clean_yum_metadata", clean_yum_metadata_mock) monkeypatch.setattr(actions, "run_pre_actions", run_pre_actions_mock) monkeypatch.setattr(report, "_summary", report_summary_mock) @@ -595,6 +610,7 @@ def test_main_rollback_analyze_exit_phase(self, global_tool_opts, monkeypatch, t assert run_pre_actions_mock.call_count == 1 assert report_summary_mock.call_count == 1 assert clear_versionlock_mock.call_count == 1 + assert ask_to_continue_mock.call_count == 1 assert finish_collection_mock.call_count == 1 assert should_subscribe_mock.call_count == 1 assert update_rhsm_custom_facts_mock.call_count == 1 @@ -661,7 +677,7 @@ def test_main_rollback_post_ponr_changes_phase(self, monkeypatch, caplog, tmp_pa assert find_actions_of_severity_mock.call_count == 1 assert clear_versionlock_mock.call_count == 1 assert report_summary_mock.call_count == 2 - assert ask_to_continue_mock.call_count == 1 + assert ask_to_continue_mock.call_count == 2 assert finish_collection_mock.call_count == 1 assert summary_as_json_mock.call_count == 1 assert summary_as_txt_mock.call_count == 1 @@ -771,8 +787,9 @@ def test_handle_inhibitors_found_exception(monkeypatch, rollback_failures, retur def test_confirm_user_backup(monkeypatch, caplog): - ask_to_continue_mock = mock.Mock() + ask_to_continue_mock = mock.Mock(return_value=True) + # Mock the ask_to_continue function monkeypatch.setattr(utils, "ask_to_continue", ask_to_continue_mock) main.confirm_user_backup() From 472b4de54eb563f2c139fe664dc9f0b7feaed677 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Wed, 11 Sep 2024 18:09:11 -0400 Subject: [PATCH 11/29] Draft for the fix for the sanity tests * the intergration tests needed another yes input for the newly added prompt --- .../assessment-report/test_assessment_report.py | 3 +++ .../non-destructive/logged-command/test_logged_command.py | 3 +++ .../rollback-handling/test_rollback_handling.py | 3 +++ .../subscription-manager/test_sub_man_pre_register.py | 3 +++ .../system-release-backup/test_system_release_backup.py | 3 +++ 5 files changed, 15 insertions(+) diff --git a/tests/integration/tier0/non-destructive/assessment-report/test_assessment_report.py b/tests/integration/tier0/non-destructive/assessment-report/test_assessment_report.py index 3ee220a021..2d176a15b0 100644 --- a/tests/integration/tier0/non-destructive/assessment-report/test_assessment_report.py +++ b/tests/integration/tier0/non-destructive/assessment-report/test_assessment_report.py @@ -105,6 +105,9 @@ def test_successful_report(convert2rhel): c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + # Assert that we start rollback first c2r.expect("Rollback: RHSM-related actions") diff --git a/tests/integration/tier0/non-destructive/logged-command/test_logged_command.py b/tests/integration/tier0/non-destructive/logged-command/test_logged_command.py index 157cb32437..1a11fd6ded 100644 --- a/tests/integration/tier0/non-destructive/logged-command/test_logged_command.py +++ b/tests/integration/tier0/non-destructive/logged-command/test_logged_command.py @@ -40,6 +40,9 @@ def test_logfile_starts_with_command(convert2rhel): c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + # After that we can stop the execution. c2r.expect("Prepare: Clear YUM/DNF version locks") c2r.sendcontrol("c") diff --git a/tests/integration/tier0/non-destructive/rollback-handling/test_rollback_handling.py b/tests/integration/tier0/non-destructive/rollback-handling/test_rollback_handling.py index 8f13d6a7ca..bc50479236 100644 --- a/tests/integration/tier0/non-destructive/rollback-handling/test_rollback_handling.py +++ b/tests/integration/tier0/non-destructive/rollback-handling/test_rollback_handling.py @@ -179,6 +179,9 @@ def test_proper_rhsm_clean_up(shell, convert2rhel): c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + # Wait till the system is properly registered and subscribed, then # send the interrupt signal to the c2r process. c2r.expect("Prepare: Get RHEL repository IDs") diff --git a/tests/integration/tier0/non-destructive/subscription-manager/test_sub_man_pre_register.py b/tests/integration/tier0/non-destructive/subscription-manager/test_sub_man_pre_register.py index 1c3ddf6e79..153c7a08cf 100644 --- a/tests/integration/tier0/non-destructive/subscription-manager/test_sub_man_pre_register.py +++ b/tests/integration/tier0/non-destructive/subscription-manager/test_sub_man_pre_register.py @@ -18,6 +18,9 @@ def test_pre_registered_wont_unregister(shell, pre_registered, convert2rhel): c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + c2r.expect("Subscription Manager is already present", timeout=300) c2r.expect( "SUBSCRIBE_SYSTEM has succeeded", diff --git a/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py b/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py index 245007e650..22edd9d749 100644 --- a/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py +++ b/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py @@ -90,6 +90,9 @@ def test_override_inhibitor_os_release_restored( c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + c2r.expect("'CONVERT2RHEL_INCOMPLETE_ROLLBACK' environment variable detected, continuing conversion.") c2r.expect("Continue with the system conversion") From 886547bcf5815514d825d32dde81d8ef1d6d1e25 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Tue, 17 Sep 2024 09:21:58 -0400 Subject: [PATCH 12/29] Draft added in the rest of the fixes for the tests * In the intergration tests there where two more tests that needed the extra input value "y" so that it would account for the new prompt --- .../basic-sanity-checks/test_basic_sanity_checks.py | 6 ++++++ .../system-release-backup/test_system_release_backup.py | 3 +++ 2 files changed, 9 insertions(+) diff --git a/tests/integration/tier0/non-destructive/basic-sanity-checks/test_basic_sanity_checks.py b/tests/integration/tier0/non-destructive/basic-sanity-checks/test_basic_sanity_checks.py index fc015f34cb..7f6c75076e 100644 --- a/tests/integration/tier0/non-destructive/basic-sanity-checks/test_basic_sanity_checks.py +++ b/tests/integration/tier0/non-destructive/basic-sanity-checks/test_basic_sanity_checks.py @@ -105,6 +105,9 @@ def test_c2r_version_latest_with_mocked_newer_version(convert2rhel, c2r_version, c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + assert c2r.expect("Latest available convert2rhel version is installed.", timeout=300) == 0 c2r.sendcontrol("c") @@ -153,6 +156,9 @@ def test_c2r_version_latest_override_inhibitor(convert2rhel, c2r_version, versio c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + assert c2r.expect("You are currently running 0.01.0", timeout=300) == 0 assert ( c2r.expect( diff --git a/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py b/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py index 22edd9d749..856b98fdc7 100644 --- a/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py +++ b/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py @@ -57,6 +57,9 @@ def test_inhibitor_os_release_restored(shell, convert2rhel, fixture_satellite, r c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + c2r.expect_exact("set the environment variable 'CONVERT2RHEL_INCOMPLETE_ROLLBACK", timeout=600) # We expect the return code to be 2, given an error is raised assert c2r.exitstatus == 2 From e18da440ee57ba703f76812cf41737511dc4eca6 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Wed, 18 Sep 2024 17:50:30 -0400 Subject: [PATCH 13/29] Added the second prompt for the intergration test --- .../test_single_yum_transaction_validation.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/integration/tier0/non-destructive/single-yum-transaction-validation/test_single_yum_transaction_validation.py b/tests/integration/tier0/non-destructive/single-yum-transaction-validation/test_single_yum_transaction_validation.py index 16c8134cdb..f9a4201200 100644 --- a/tests/integration/tier0/non-destructive/single-yum-transaction-validation/test_single_yum_transaction_validation.py +++ b/tests/integration/tier0/non-destructive/single-yum-transaction-validation/test_single_yum_transaction_validation.py @@ -192,6 +192,9 @@ def test_packages_with_in_name_period(shell, convert2rhel, packages_with_period) c2r.expect("Continue with the system conversion", timeout=300) c2r.sendline("y") + c2r.expect("Continue with the system conversion", timeout=300) + c2r.sendline("y") + c2r.expect("VALIDATE_PACKAGE_MANAGER_TRANSACTION has succeeded") assert c2r.exitstatus == 0 From f60d80f4f6502e13355f75fe893a063350e385d6 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Tue, 24 Sep 2024 17:38:24 -0400 Subject: [PATCH 14/29] added some more fixes for the intergration tests --- .../tier0/destructive/conversion-method/test_pre_registered.py | 3 +++ .../subscription-manager/test_sub_man_pre_register.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py b/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py index 0a3c37043a..958fc7026e 100644 --- a/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py +++ b/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py @@ -1,4 +1,7 @@ def test_pre_registered_system_conversion(convert2rhel, pre_registered): with convert2rhel("-y --debug") as c2r: c2r.expect("Conversion successful!") + + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") assert c2r.exitstatus == 0 diff --git a/tests/integration/tier0/non-destructive/subscription-manager/test_sub_man_pre_register.py b/tests/integration/tier0/non-destructive/subscription-manager/test_sub_man_pre_register.py index 153c7a08cf..984b0c522d 100644 --- a/tests/integration/tier0/non-destructive/subscription-manager/test_sub_man_pre_register.py +++ b/tests/integration/tier0/non-destructive/subscription-manager/test_sub_man_pre_register.py @@ -52,6 +52,9 @@ def test_pre_registered_re_register(shell, pre_registered, convert2rhel): c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + c2r.expect("Registering the system using subscription-manager") c2r.expect("Continue with the system conversion?") c2r.sendline("n") From e0abaa336626ae1168e6b47d045539d15a810264 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Wed, 25 Sep 2024 18:32:15 -0400 Subject: [PATCH 15/29] Added in some more cases for the intergration test * there are a few more intergration tests that needed another input for the new check that was added --- .../assessment-report/test_assessment_report.py | 3 +++ .../basic-sanity-checks/test_basic_sanity_checks.py | 9 +++++++++ .../kernel-modules/test_unsupported_kmod.py | 8 ++++++++ .../tier0/non-destructive/kernel/test_custom_kernel.py | 3 +++ .../kernel/test_kernel_check_verification.py | 3 +++ .../subscription-manager/test_sub_man_pre_register.py | 9 +++++++++ 6 files changed, 35 insertions(+) diff --git a/tests/integration/tier0/non-destructive/assessment-report/test_assessment_report.py b/tests/integration/tier0/non-destructive/assessment-report/test_assessment_report.py index 2d176a15b0..bc0538eabd 100644 --- a/tests/integration/tier0/non-destructive/assessment-report/test_assessment_report.py +++ b/tests/integration/tier0/non-destructive/assessment-report/test_assessment_report.py @@ -56,6 +56,9 @@ def test_failures_and_skips_in_report(convert2rhel): c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + # Assert that we start rollback first c2r.expect_exact("TASK - [Rollback:") diff --git a/tests/integration/tier0/non-destructive/basic-sanity-checks/test_basic_sanity_checks.py b/tests/integration/tier0/non-destructive/basic-sanity-checks/test_basic_sanity_checks.py index 7f6c75076e..77847f7b5e 100644 --- a/tests/integration/tier0/non-destructive/basic-sanity-checks/test_basic_sanity_checks.py +++ b/tests/integration/tier0/non-destructive/basic-sanity-checks/test_basic_sanity_checks.py @@ -128,6 +128,9 @@ def test_c2r_version_latest_inhibitor(convert2rhel, c2r_version, version): c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + assert ( c2r.expect_exact( "(OVERRIDABLE) CONVERT2RHEL_LATEST_VERSION::OUT_OF_DATE - Outdated convert2rhel version detected", @@ -182,6 +185,9 @@ def test_clean_cache(convert2rhel): c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + assert c2r.expect("Prepare: Clean yum cache metadata", timeout=300) == 0 assert c2r.expect("Cached repositories metadata cleaned successfully.", timeout=300) == 0 @@ -202,6 +208,9 @@ def test_rhsm_error_logged(convert2rhel): c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + # Wait until we reach the point where the RHEL certificate has been # installed otherwise we won't attempt to remove it. assert c2r.expect("PRE_SUBSCRIPTION has succeeded") == 0 diff --git a/tests/integration/tier0/non-destructive/kernel-modules/test_unsupported_kmod.py b/tests/integration/tier0/non-destructive/kernel-modules/test_unsupported_kmod.py index e2a783ee1b..b923d08195 100644 --- a/tests/integration/tier0/non-destructive/kernel-modules/test_unsupported_kmod.py +++ b/tests/integration/tier0/non-destructive/kernel-modules/test_unsupported_kmod.py @@ -67,6 +67,9 @@ def test_override_inhibitor_with_unavailable_kmod_loaded( c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + c2r.expect("Detected 'CONVERT2RHEL_ALLOW_UNAVAILABLE_KMODS' environment variable") c2r.expect("We will continue the conversion with the following kernel modules") @@ -101,6 +104,9 @@ def test_inhibitor_with_force_loaded_tainted_kmod(shell, convert2rhel, forced_km c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + assert c2r.expect("TAINTED_KMODS::TAINTED_KMODS_DETECTED - Tainted kernel modules detected") == 0 c2r.sendcontrol("c") @@ -127,6 +133,8 @@ def test_override_inhibitor_with_tainted_kmod(shell, convert2rhel, forced_kmods, # We need to get past the data collection acknowledgement. c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") # Validate that with the envar the conversion is not inhibited with an error, # but just a warning is displayed and the user is allowed to proceed with a full conversion c2r.expect_exact("(WARNING) TAINTED_KMODS::SKIP_TAINTED_KERNEL_MODULE_CHECK") diff --git a/tests/integration/tier0/non-destructive/kernel/test_custom_kernel.py b/tests/integration/tier0/non-destructive/kernel/test_custom_kernel.py index 35022d8e98..0282e6d3d7 100644 --- a/tests/integration/tier0/non-destructive/kernel/test_custom_kernel.py +++ b/tests/integration/tier0/non-destructive/kernel/test_custom_kernel.py @@ -137,6 +137,9 @@ def test_custom_kernel(convert2rhel, shell, custom_kernel): c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + c2r.expect( "WARNING - Custom kernel detected. The booted kernel needs to be signed by {}".format(os_vendor) ) diff --git a/tests/integration/tier0/non-destructive/kernel/test_kernel_check_verification.py b/tests/integration/tier0/non-destructive/kernel/test_kernel_check_verification.py index ed47300a51..65cfca62af 100644 --- a/tests/integration/tier0/non-destructive/kernel/test_kernel_check_verification.py +++ b/tests/integration/tier0/non-destructive/kernel/test_kernel_check_verification.py @@ -40,6 +40,9 @@ def test_verify_latest_kernel_check_passes_with_failed_repoquery(convert2rhel, t c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + c2r.expect( "Couldn't fetch the list of the most recent kernels available in the repositories. Did not perform the loaded kernel check.", timeout=300, diff --git a/tests/integration/tier0/non-destructive/subscription-manager/test_sub_man_pre_register.py b/tests/integration/tier0/non-destructive/subscription-manager/test_sub_man_pre_register.py index 984b0c522d..31dec25c06 100644 --- a/tests/integration/tier0/non-destructive/subscription-manager/test_sub_man_pre_register.py +++ b/tests/integration/tier0/non-destructive/subscription-manager/test_sub_man_pre_register.py @@ -75,6 +75,9 @@ def test_unregistered_no_credentials(shell, convert2rhel): c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + c2r.expect("SUBSCRIBE_SYSTEM::SYSTEM_NOT_REGISTERED - Not registered with RHSM", timeout=300) assert c2r.exitstatus == 2 @@ -92,6 +95,9 @@ def test_no_sca_not_subscribed(shell, pre_registered, convert2rhel): c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + c2r.expect("We'll try to auto-attach a subscription") c2r.expect("SUBSCRIBE_SYSTEM has succeeded") c2r.expect("Continue with the system conversion?") @@ -116,6 +122,9 @@ def test_no_sca_subscription_attachment_error(shell, convert2rhel, pre_registere c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + c2r.expect("We'll try to auto-attach a subscription") c2r.expect_exact("(ERROR) SUBSCRIBE_SYSTEM::NO_ACCESS_TO_RHEL_REPOS - No access to RHEL repositories") From 9c74bb70fd8fd492405fb3c166f697fcaeee378c Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Tue, 8 Oct 2024 13:57:06 -0400 Subject: [PATCH 16/29] added in two yes prompts for the intergartion test * added the extra propmts in test_basic_sanity_checks.py and test_assessment_report.py --- .../assessment-report/test_assessment_report.py | 3 +++ .../basic-sanity-checks/test_basic_sanity_checks.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/tests/integration/tier0/non-destructive/assessment-report/test_assessment_report.py b/tests/integration/tier0/non-destructive/assessment-report/test_assessment_report.py index bc0538eabd..3396ea0503 100644 --- a/tests/integration/tier0/non-destructive/assessment-report/test_assessment_report.py +++ b/tests/integration/tier0/non-destructive/assessment-report/test_assessment_report.py @@ -153,6 +153,9 @@ def test_convert_method_successful_report(convert2rhel): c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + # Refuse the full conversion at PONR c2r.expect("Continue with the system conversion?") c2r.sendline("n") diff --git a/tests/integration/tier0/non-destructive/basic-sanity-checks/test_basic_sanity_checks.py b/tests/integration/tier0/non-destructive/basic-sanity-checks/test_basic_sanity_checks.py index 77847f7b5e..aa3c051876 100644 --- a/tests/integration/tier0/non-destructive/basic-sanity-checks/test_basic_sanity_checks.py +++ b/tests/integration/tier0/non-destructive/basic-sanity-checks/test_basic_sanity_checks.py @@ -275,6 +275,7 @@ def test_analyze_incomplete_rollback(remove_repositories, convert2rhel): with convert2rhel("analyze --debug") as c2r: # We need to get past the data collection acknowledgement c2r.sendline("y") + c2r.sendline("y") # Verify the user is informed to not use the envar during the analysis assert ( c2r.expect( @@ -291,6 +292,7 @@ def test_analyze_incomplete_rollback(remove_repositories, convert2rhel): with convert2rhel("--debug") as c2r: # We need to get past the data collection acknowledgement c2r.sendline("y") + c2r.sendline("y") assert ( c2r.expect( "'CONVERT2RHEL_INCOMPLETE_ROLLBACK' environment variable detected, continuing conversion.", From 3b08ad9e10dfd06a8389a463860e8d3ea19a4251 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Wed, 9 Oct 2024 12:11:14 -0400 Subject: [PATCH 17/29] Added in input for test_pre_registered.py --- .../tier0/destructive/conversion-method/test_pre_registered.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py b/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py index 958fc7026e..9d9e90e41d 100644 --- a/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py +++ b/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py @@ -4,4 +4,7 @@ def test_pre_registered_system_conversion(convert2rhel, pre_registered): c2r.expect("Continue with the system conversion?") c2r.sendline("y") + + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") assert c2r.exitstatus == 0 From 6607a586a787ffab0e9c93da1518cd9e2432c201 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Thu, 10 Oct 2024 10:22:42 -0400 Subject: [PATCH 18/29] Removed one of the c2r.expect lines from a test * There was an extra c2r.expect line in the pre_registered_systems_conversions intergration test --- .../tier0/destructive/conversion-method/test_pre_registered.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py b/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py index 9d9e90e41d..d6497dd5db 100644 --- a/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py +++ b/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py @@ -1,7 +1,5 @@ def test_pre_registered_system_conversion(convert2rhel, pre_registered): with convert2rhel("-y --debug") as c2r: - c2r.expect("Conversion successful!") - c2r.expect("Continue with the system conversion?") c2r.sendline("y") From 011bdc05369872afa4c9e9575c70ae443440493b Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Thu, 17 Oct 2024 18:35:37 -0400 Subject: [PATCH 19/29] Added a prompt to another intergration test * Added the input for the intergration test pre_registered_system_conversion --- .../custom-repository/test_custom_repository.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/integration/tier0/non-destructive/custom-repository/test_custom_repository.py b/tests/integration/tier0/non-destructive/custom-repository/test_custom_repository.py index 8f0db06304..5b5df72e08 100644 --- a/tests/integration/tier0/non-destructive/custom-repository/test_custom_repository.py +++ b/tests/integration/tier0/non-destructive/custom-repository/test_custom_repository.py @@ -31,6 +31,12 @@ def test_custom_valid_repo_without_rhsm(convert2rhel, set_custom_repository_file enable_repo_opt = " ".join(f"--enablerepo {repo}" for repo in get_custom_repos_names()) with convert2rhel(f"-y --no-rhsm {enable_repo_opt} --debug", unregister=True) as c2r: + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + c2r.expect("The repositories passed through the --enablerepo option are all accessible.") c2r.sendcontrol("c") From 308feb079bc38cd11ee89262b2890c6e248ade60 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Fri, 18 Oct 2024 17:32:33 -0400 Subject: [PATCH 20/29] removed the commit in confirm_user_backup --- convert2rhel/main.py | 1 - .../system-release-backup/test_system_release_backup.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/convert2rhel/main.py b/convert2rhel/main.py index 0217b49171..45e4344371 100644 --- a/convert2rhel/main.py +++ b/convert2rhel/main.py @@ -315,7 +315,6 @@ def _handle_inhibitors_found_exception(): def confirm_user_backup(): - # Add in the warning about the system back up here! loggerinst.warning( "Convert2RHEL modifies the systems during the analysis and then rolls back these " "changes when the analysis is complete. In rare cases, this rollback can fail. " diff --git a/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py b/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py index 856b98fdc7..e18dc3c1e6 100644 --- a/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py +++ b/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py @@ -93,7 +93,7 @@ def test_override_inhibitor_os_release_restored( c2r.expect("Continue with the system conversion?") c2r.sendline("y") - c2r.expect("Continue with the system conversion?") + # c2r.expect("Continue with the system conversion?") c2r.sendline("y") c2r.expect("'CONVERT2RHEL_INCOMPLETE_ROLLBACK' environment variable detected, continuing conversion.") From a37bb0c99646c5aef15432b954eb02c380a4827c Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Fri, 18 Oct 2024 18:01:28 -0400 Subject: [PATCH 21/29] Removed the rebase markers --- convert2rhel/unit_tests/breadcrumbs_test.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/convert2rhel/unit_tests/breadcrumbs_test.py b/convert2rhel/unit_tests/breadcrumbs_test.py index 852bc463fa..ce557b21f3 100644 --- a/convert2rhel/unit_tests/breadcrumbs_test.py +++ b/convert2rhel/unit_tests/breadcrumbs_test.py @@ -22,9 +22,12 @@ import pytest import six +import sys + from convert2rhel import breadcrumbs, pkghandler, pkgmanager from convert2rhel.unit_tests import create_pkg_information, create_pkg_obj from convert2rhel.unit_tests.conftest import centos7 +from convert2rhel.unit_tests.cli_test import mock_cli_arguments six.add_move(six.MovedModule("mock", "mock", "unittest.mock")) @@ -330,7 +333,6 @@ def test_set_target_os(pretend_os): "name": "CentOS Linux", "version": "7.9", } == breadcrumbs.breadcrumbs.target_os -<<<<<<< HEAD def test_set_non_default_channel_eus(global_tool_opts, monkeypatch): @@ -345,6 +347,8 @@ def test_set_non_default_channel_els(global_tool_opts, monkeypatch): monkeypatch.setattr(breadcrumbs, "tool_opts", global_tool_opts) breadcrumbs.breadcrumbs._set_non_default_channel() assert breadcrumbs.breadcrumbs.non_default_channel == "ELS" + + @pytest.mark.parametrize( ("argv", "expected", "message"), ( @@ -368,5 +372,3 @@ def test_confirm_user_backup(argv, expected, message, monkeypatch, global_tool_o # assert global_tool_opts.no_rpm_va == expected if message: assert message in caplog.text -======= ->>>>>>> 05fa47ff (Moved the confirm_user_backup() to main.py) From 39138a43be8ad5768c4a4d2fa8f6f56796ed310d Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Fri, 18 Oct 2024 18:05:11 -0400 Subject: [PATCH 22/29] Changed how we are calling toolopts.CLI() --- convert2rhel/unit_tests/breadcrumbs_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/convert2rhel/unit_tests/breadcrumbs_test.py b/convert2rhel/unit_tests/breadcrumbs_test.py index ce557b21f3..a950919b75 100644 --- a/convert2rhel/unit_tests/breadcrumbs_test.py +++ b/convert2rhel/unit_tests/breadcrumbs_test.py @@ -24,7 +24,7 @@ import sys -from convert2rhel import breadcrumbs, pkghandler, pkgmanager +from convert2rhel import breadcrumbs, pkghandler, pkgmanager, toolopts from convert2rhel.unit_tests import create_pkg_information, create_pkg_obj from convert2rhel.unit_tests.conftest import centos7 from convert2rhel.unit_tests.cli_test import mock_cli_arguments @@ -365,7 +365,7 @@ def test_set_non_default_channel_els(global_tool_opts, monkeypatch): def test_confirm_user_backup(argv, expected, message, monkeypatch, global_tool_opts, caplog): monkeypatch.setattr(sys, "argv", mock_cli_arguments(argv)) try: - convert2rhel.toolopts.CLI() + toolopts.CLI() except SystemExit: pass From 4293d958c8563ab1423957f7dda9b932942dea82 Mon Sep 17 00:00:00 2001 From: Anderw Anglin Date: Mon, 21 Oct 2024 15:41:24 -0400 Subject: [PATCH 23/29] Removed some old code from a rebase --- convert2rhel/unit_tests/breadcrumbs_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/convert2rhel/unit_tests/breadcrumbs_test.py b/convert2rhel/unit_tests/breadcrumbs_test.py index a950919b75..ff1bcbe226 100644 --- a/convert2rhel/unit_tests/breadcrumbs_test.py +++ b/convert2rhel/unit_tests/breadcrumbs_test.py @@ -24,7 +24,7 @@ import sys -from convert2rhel import breadcrumbs, pkghandler, pkgmanager, toolopts +from convert2rhel import breadcrumbs, pkghandler, pkgmanager, cli from convert2rhel.unit_tests import create_pkg_information, create_pkg_obj from convert2rhel.unit_tests.conftest import centos7 from convert2rhel.unit_tests.cli_test import mock_cli_arguments @@ -365,7 +365,7 @@ def test_set_non_default_channel_els(global_tool_opts, monkeypatch): def test_confirm_user_backup(argv, expected, message, monkeypatch, global_tool_opts, caplog): monkeypatch.setattr(sys, "argv", mock_cli_arguments(argv)) try: - toolopts.CLI() + cli.CLI() except SystemExit: pass From 6f74781fd134ea406413b9111a22da7583b52618 Mon Sep 17 00:00:00 2001 From: Anderw Anglin Date: Mon, 21 Oct 2024 15:45:03 -0400 Subject: [PATCH 24/29] fully removed the test_confirm_user_backup() from breadcrumbs_test * in the last commit it just changed the test but it was supposed to remove the test all together it is now fully removed --- convert2rhel/unit_tests/breadcrumbs_test.py | 27 +-------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/convert2rhel/unit_tests/breadcrumbs_test.py b/convert2rhel/unit_tests/breadcrumbs_test.py index ff1bcbe226..7d189b9429 100644 --- a/convert2rhel/unit_tests/breadcrumbs_test.py +++ b/convert2rhel/unit_tests/breadcrumbs_test.py @@ -24,7 +24,7 @@ import sys -from convert2rhel import breadcrumbs, pkghandler, pkgmanager, cli +from convert2rhel import breadcrumbs, pkghandler, pkgmanager from convert2rhel.unit_tests import create_pkg_information, create_pkg_obj from convert2rhel.unit_tests.conftest import centos7 from convert2rhel.unit_tests.cli_test import mock_cli_arguments @@ -347,28 +347,3 @@ def test_set_non_default_channel_els(global_tool_opts, monkeypatch): monkeypatch.setattr(breadcrumbs, "tool_opts", global_tool_opts) breadcrumbs.breadcrumbs._set_non_default_channel() assert breadcrumbs.breadcrumbs.non_default_channel == "ELS" - - -@pytest.mark.parametrize( - ("argv", "expected", "message"), - ( - ( - ["analyze"], - False, - "Convert2RHEL modifies the systems during the analysis and then rolls back these " - "changes when the analysis is complete. In rare cases, this rollback can fail. " - "By continuing, you confirm that you have made a system backup and verified that " - "you can restore from the backup.", - ), - ), -) -def test_confirm_user_backup(argv, expected, message, monkeypatch, global_tool_opts, caplog): - monkeypatch.setattr(sys, "argv", mock_cli_arguments(argv)) - try: - cli.CLI() - except SystemExit: - pass - - # assert global_tool_opts.no_rpm_va == expected - if message: - assert message in caplog.text From b9e4db7658d498e143cc4dc130cb987fd363b3e6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 19:46:52 +0000 Subject: [PATCH 25/29] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- convert2rhel/unit_tests/breadcrumbs_test.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/convert2rhel/unit_tests/breadcrumbs_test.py b/convert2rhel/unit_tests/breadcrumbs_test.py index 7d189b9429..653574e88f 100644 --- a/convert2rhel/unit_tests/breadcrumbs_test.py +++ b/convert2rhel/unit_tests/breadcrumbs_test.py @@ -22,12 +22,10 @@ import pytest import six -import sys from convert2rhel import breadcrumbs, pkghandler, pkgmanager from convert2rhel.unit_tests import create_pkg_information, create_pkg_obj from convert2rhel.unit_tests.conftest import centos7 -from convert2rhel.unit_tests.cli_test import mock_cli_arguments six.add_move(six.MovedModule("mock", "mock", "unittest.mock")) From 42a484db93d557e304e3680e7306405e8dc546d5 Mon Sep 17 00:00:00 2001 From: Anderw Anglin Date: Mon, 21 Oct 2024 17:18:57 -0400 Subject: [PATCH 26/29] Draft trying to just pass the input for the test --- .../non-destructive/custom-repository/test_custom_repository.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tier0/non-destructive/custom-repository/test_custom_repository.py b/tests/integration/tier0/non-destructive/custom-repository/test_custom_repository.py index 5b5df72e08..18d7f0e740 100644 --- a/tests/integration/tier0/non-destructive/custom-repository/test_custom_repository.py +++ b/tests/integration/tier0/non-destructive/custom-repository/test_custom_repository.py @@ -34,7 +34,7 @@ def test_custom_valid_repo_without_rhsm(convert2rhel, set_custom_repository_file c2r.expect("Continue with the system conversion?") c2r.sendline("y") - c2r.expect("Continue with the system conversion?") + # c2r.expect("Continue with the system conversion?") c2r.sendline("y") c2r.expect("The repositories passed through the --enablerepo option are all accessible.") From ed1ccd2869a066eebc5a5a47336185cf524e0e05 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Tue, 22 Oct 2024 14:13:00 -0400 Subject: [PATCH 27/29] draft Commited out the extra prompt * This is just a test to try and see whats going on with the test Just to make sure that this test needs two prompts --- .../system-release-backup/test_system_release_backup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py b/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py index e18dc3c1e6..a94040fcf9 100644 --- a/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py +++ b/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py @@ -94,7 +94,7 @@ def test_override_inhibitor_os_release_restored( c2r.sendline("y") # c2r.expect("Continue with the system conversion?") - c2r.sendline("y") + # c2r.sendline("y") c2r.expect("'CONVERT2RHEL_INCOMPLETE_ROLLBACK' environment variable detected, continuing conversion.") From b5860a6119581e4b9e4bba276fb928c4ed541cb5 Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Wed, 23 Oct 2024 14:02:16 -0400 Subject: [PATCH 28/29] Removed some of the prompts as they are not needed --- .../destructive/conversion-method/test_pre_registered.py | 6 +----- .../custom-repository/test_custom_repository.py | 6 ------ .../system-release-backup/test_system_release_backup.py | 3 --- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py b/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py index d6497dd5db..0a3c37043a 100644 --- a/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py +++ b/tests/integration/tier0/destructive/conversion-method/test_pre_registered.py @@ -1,8 +1,4 @@ def test_pre_registered_system_conversion(convert2rhel, pre_registered): with convert2rhel("-y --debug") as c2r: - c2r.expect("Continue with the system conversion?") - c2r.sendline("y") - - c2r.expect("Continue with the system conversion?") - c2r.sendline("y") + c2r.expect("Conversion successful!") assert c2r.exitstatus == 0 diff --git a/tests/integration/tier0/non-destructive/custom-repository/test_custom_repository.py b/tests/integration/tier0/non-destructive/custom-repository/test_custom_repository.py index 18d7f0e740..8f0db06304 100644 --- a/tests/integration/tier0/non-destructive/custom-repository/test_custom_repository.py +++ b/tests/integration/tier0/non-destructive/custom-repository/test_custom_repository.py @@ -31,12 +31,6 @@ def test_custom_valid_repo_without_rhsm(convert2rhel, set_custom_repository_file enable_repo_opt = " ".join(f"--enablerepo {repo}" for repo in get_custom_repos_names()) with convert2rhel(f"-y --no-rhsm {enable_repo_opt} --debug", unregister=True) as c2r: - c2r.expect("Continue with the system conversion?") - c2r.sendline("y") - - # c2r.expect("Continue with the system conversion?") - c2r.sendline("y") - c2r.expect("The repositories passed through the --enablerepo option are all accessible.") c2r.sendcontrol("c") diff --git a/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py b/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py index a94040fcf9..508653c1fc 100644 --- a/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py +++ b/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py @@ -93,9 +93,6 @@ def test_override_inhibitor_os_release_restored( c2r.expect("Continue with the system conversion?") c2r.sendline("y") - # c2r.expect("Continue with the system conversion?") - # c2r.sendline("y") - c2r.expect("'CONVERT2RHEL_INCOMPLETE_ROLLBACK' environment variable detected, continuing conversion.") c2r.expect("Continue with the system conversion") From fe6fc0660cb13cd1399bf5e35de37349c77e1d9d Mon Sep 17 00:00:00 2001 From: Andrew Anglin Date: Thu, 24 Oct 2024 14:25:00 -0400 Subject: [PATCH 29/29] draft added in a prompt --- .../system-release-backup/test_system_release_backup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py b/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py index 508653c1fc..856b98fdc7 100644 --- a/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py +++ b/tests/integration/tier0/non-destructive/system-release-backup/test_system_release_backup.py @@ -93,6 +93,9 @@ def test_override_inhibitor_os_release_restored( c2r.expect("Continue with the system conversion?") c2r.sendline("y") + c2r.expect("Continue with the system conversion?") + c2r.sendline("y") + c2r.expect("'CONVERT2RHEL_INCOMPLETE_ROLLBACK' environment variable detected, continuing conversion.") c2r.expect("Continue with the system conversion")