From 44bf15a295a3347a5c59b6e27633e7fabefdae07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Padilla=20=C3=81lvarez?= Date: Thu, 9 May 2024 13:24:31 +0200 Subject: [PATCH 1/6] docs: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f82cebb7c..faf0f72186 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ All notable changes to this project will be documented in this file. ### Changed +- Change manager Vulnerability Detector E2E test case ([#5345](https://github.com/wazuh/wazuh-qa/pull/5345)) \- (Tests) - Include additional Vulnerability Detector E2E tests ([#5287](https://github.com/wazuh/wazuh-qa/pull/5287)) \- (Framework + Tests) - Change Vulnerability Detection feed updated waiter ([#5227](https://github.com/wazuh/wazuh-qa/pull/5227)) \- (Tests) - Replace timestamp filter with vulnerabilities detected_at field.([#5266](https://github.com/wazuh/wazuh-qa/pull/5266)) \- (Framework + Tests) From 188042f14aba618d22724f44b28110a5ae23f9ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Padilla=20=C3=81lvarez?= Date: Thu, 9 May 2024 14:28:39 +0200 Subject: [PATCH 2/6] fix: skip truncate test_change_agent_manager case --- .../test_vulnerability_detector/conftest.py | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/end_to_end/test_vulnerability_detector/conftest.py b/tests/end_to_end/test_vulnerability_detector/conftest.py index a242eaef7c..51c2a0e679 100644 --- a/tests/end_to_end/test_vulnerability_detector/conftest.py +++ b/tests/end_to_end/test_vulnerability_detector/conftest.py @@ -126,31 +126,43 @@ def backup_configuration(host_manager: HostManager): @pytest.fixture(scope="module") -def clean_environment_logs(host_manager: HostManager): +def clean_environment_logs(host_manager: HostManager, request): """Clean Agents and Managers logs Args: host_manager: An instance of the HostManager class containing information about hosts. + request: The request object to access the current test request data. """ yield - logging.error("Truncate managers and agents logs") - truncate_remote_host_group_files(host_manager, "all", "logs") + skip_truncate_tests = ['test_change_agent_manager'] + + if any(test in request.node.name for test in skip_truncate_tests): + print("Skipping truncation of logs for this test.") + else: + logging.error("Truncate managers and agents logs") + truncate_remote_host_group_files(host_manager, "all", "logs") @pytest.fixture(scope="function") -def clean_environment_logs_function(host_manager: HostManager): +def clean_environment_logs_function(host_manager: HostManager, request): """Clean Agents and Managers logs Args: host_manager: An instance of the HostManager class containing information about hosts. + request: The request object to access the current test request data. """ yield - logging.error("Truncate managers and agents logs") - truncate_remote_host_group_files(host_manager, "all", "logs") + skip_truncate_tests = ['test_change_agent_manager'] + + if any(test in request.node.name for test in skip_truncate_tests): + print("Skipping truncation of logs for this test.") + else: + logging.error("Truncate managers and agents logs") + truncate_remote_host_group_files(host_manager, "all", "logs") @pytest.fixture(scope="module") From a365c44da15d40f3e42f9fbaff9aae5df58d8dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Padilla=20=C3=81lvarez?= Date: Thu, 9 May 2024 14:45:45 +0200 Subject: [PATCH 3/6] docs: update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index faf0f72186..df3aee5eb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,6 @@ All notable changes to this project will be documented in this file. ### Changed -- Change manager Vulnerability Detector E2E test case ([#5345](https://github.com/wazuh/wazuh-qa/pull/5345)) \- (Tests) - Include additional Vulnerability Detector E2E tests ([#5287](https://github.com/wazuh/wazuh-qa/pull/5287)) \- (Framework + Tests) - Change Vulnerability Detection feed updated waiter ([#5227](https://github.com/wazuh/wazuh-qa/pull/5227)) \- (Tests) - Replace timestamp filter with vulnerabilities detected_at field.([#5266](https://github.com/wazuh/wazuh-qa/pull/5266)) \- (Framework + Tests) @@ -58,6 +57,7 @@ All notable changes to this project will be documented in this file. ### Fixed +- Fix truncate logs in change manager Vulnerability Detector E2E test case ([#5355](https://github.com/wazuh/wazuh-qa/pull/5355)) \- (Tests) - Fix packages in Windows and macOS upgrade cases ([#5223](https://github.com/wazuh/wazuh-qa/pull/5223)) \- (Framework + Tests) - Fix vulnerabilities and add new packages to Vulnerability Detector E2E tests ([#5234](https://github.com/wazuh/wazuh-qa/pull/5234)) \- (Tests) - Fix provision macOS endpoints with npm ([#5128](https://github.com/wazuh/wazuh-qa/pull/5158)) \- (Tests) From ff13f5c0025ce500100b2e3e4191d1207a264ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Padilla=20=C3=81lvarez?= Date: Thu, 9 May 2024 15:03:48 +0200 Subject: [PATCH 4/6] fix: change prints for debugging --- tests/end_to_end/test_vulnerability_detector/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/end_to_end/test_vulnerability_detector/conftest.py b/tests/end_to_end/test_vulnerability_detector/conftest.py index 51c2a0e679..85647d282e 100644 --- a/tests/end_to_end/test_vulnerability_detector/conftest.py +++ b/tests/end_to_end/test_vulnerability_detector/conftest.py @@ -139,7 +139,7 @@ def clean_environment_logs(host_manager: HostManager, request): skip_truncate_tests = ['test_change_agent_manager'] if any(test in request.node.name for test in skip_truncate_tests): - print("Skipping truncation of logs for this test.") + logging.error("Skipping truncation of logs for this test.") else: logging.error("Truncate managers and agents logs") truncate_remote_host_group_files(host_manager, "all", "logs") @@ -159,7 +159,7 @@ def clean_environment_logs_function(host_manager: HostManager, request): skip_truncate_tests = ['test_change_agent_manager'] if any(test in request.node.name for test in skip_truncate_tests): - print("Skipping truncation of logs for this test.") + logging.error("Skipping truncation of logs for this test.") else: logging.error("Truncate managers and agents logs") truncate_remote_host_group_files(host_manager, "all", "logs") From d99ede4bfa859316019fa7a820932d448ab8e8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Padilla=20=C3=81lvarez?= Date: Mon, 13 May 2024 15:35:00 +0200 Subject: [PATCH 5/6] fix: restart agent after change of manager --- .../test_vulnerability_detector/conftest.py | 24 +++++-------------- .../test_vulnerability_detector.py | 9 +++++++ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/tests/end_to_end/test_vulnerability_detector/conftest.py b/tests/end_to_end/test_vulnerability_detector/conftest.py index 85647d282e..a242eaef7c 100644 --- a/tests/end_to_end/test_vulnerability_detector/conftest.py +++ b/tests/end_to_end/test_vulnerability_detector/conftest.py @@ -126,43 +126,31 @@ def backup_configuration(host_manager: HostManager): @pytest.fixture(scope="module") -def clean_environment_logs(host_manager: HostManager, request): +def clean_environment_logs(host_manager: HostManager): """Clean Agents and Managers logs Args: host_manager: An instance of the HostManager class containing information about hosts. - request: The request object to access the current test request data. """ yield - skip_truncate_tests = ['test_change_agent_manager'] - - if any(test in request.node.name for test in skip_truncate_tests): - logging.error("Skipping truncation of logs for this test.") - else: - logging.error("Truncate managers and agents logs") - truncate_remote_host_group_files(host_manager, "all", "logs") + logging.error("Truncate managers and agents logs") + truncate_remote_host_group_files(host_manager, "all", "logs") @pytest.fixture(scope="function") -def clean_environment_logs_function(host_manager: HostManager, request): +def clean_environment_logs_function(host_manager: HostManager): """Clean Agents and Managers logs Args: host_manager: An instance of the HostManager class containing information about hosts. - request: The request object to access the current test request data. """ yield - skip_truncate_tests = ['test_change_agent_manager'] - - if any(test in request.node.name for test in skip_truncate_tests): - logging.error("Skipping truncation of logs for this test.") - else: - logging.error("Truncate managers and agents logs") - truncate_remote_host_group_files(host_manager, "all", "logs") + logging.error("Truncate managers and agents logs") + truncate_remote_host_group_files(host_manager, "all", "logs") @pytest.fixture(scope="module") diff --git a/tests/end_to_end/test_vulnerability_detector/test_vulnerability_detector.py b/tests/end_to_end/test_vulnerability_detector/test_vulnerability_detector.py index 0be278768d..15e56b9eeb 100644 --- a/tests/end_to_end/test_vulnerability_detector/test_vulnerability_detector.py +++ b/tests/end_to_end/test_vulnerability_detector/test_vulnerability_detector.py @@ -622,10 +622,19 @@ def permutate_agents_managers(self, host_manager): ) change_agent_manager_ip(host_manager, agent, manager_ip) + # Restart agents to apply the new configuration changes + logging.error("Restarting agents") + host_manager.control_environment("restart", ["agent"], parallel=True) + yield + # Restore the original configuration after tests are done restore_configuration(host_manager, backup_configuration) + # Restart agents again to ensure they reconnect with their original managers + logging.error("Restarting agents") + host_manager.control_environment("restart", ["agent"], parallel=True) + @pytest.mark.parametrize("preconditions, body, teardown", single_vulnerable_case_complete_list, ids=single_vulnerable_case_list_ids,) def test_install_vulnerable_package_when_agent_down(self, host_manager, request, record_property, preconditions, From afdb574c09d2f2abf24de5ee7be90b1309d24d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Padilla=20=C3=81lvarez?= Date: Mon, 13 May 2024 15:47:59 +0200 Subject: [PATCH 6/6] docs: update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8d9231297..ef0bde7578 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,7 +60,7 @@ All notable changes to this project will be documented in this file. ### Fixed -- Fix truncate logs in change manager Vulnerability Detector E2E test case ([#5355](https://github.com/wazuh/wazuh-qa/pull/5355)) \- (Tests) +- Fix restart agent in change manager Vulnerability Detector E2E test case ([#5355](https://github.com/wazuh/wazuh-qa/pull/5355)) \- (Tests) - Fix shutdown messages system test ([#5298](https://github.com/wazuh/wazuh-qa/pull/5298)) \- (Framework + Tests) - Fix upgrade macOS package cases for vulnerability scanner E2E ([#5334](https://github.com/wazuh/wazuh-qa/pull/5334)) \- (Tests) - Fix test cases in Vulnerability Detection E2E test by adding new packages ([#5349](https://github.com/wazuh/wazuh-qa/pull/5349)) \- (Tests)