From a980ae5cfeeedb7d9753d62c7161c0cc6efbc28e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Thu, 21 Mar 2024 11:43:24 +0000 Subject: [PATCH 01/18] fix: test group sync status --- .../wazuh_testing/tools/system.py | 2 +- .../test_group_sync_status.py | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/deps/wazuh_testing/wazuh_testing/tools/system.py b/deps/wazuh_testing/wazuh_testing/tools/system.py index 9726739b06..88c33a6fc8 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/system.py +++ b/deps/wazuh_testing/wazuh_testing/tools/system.py @@ -374,7 +374,7 @@ def run_command(self, host: str, cmd: str, check: bool = False): Returns: stdout (str): The output of the command execution. """ - return self.get_host(host).ansible("command", cmd, check=check)["stdout"] + return self.get_host(host).ansible("command", cmd, check=check) def run_shell(self, host: str, cmd: str, check: bool = False): """Run a shell command on the specified host and return its stdout. diff --git a/tests/system/test_cluster/test_agent_groups/test_group_sync_status.py b/tests/system/test_cluster/test_agent_groups/test_group_sync_status.py index 51e3edd7a7..828de1f938 100644 --- a/tests/system/test_cluster/test_agent_groups/test_group_sync_status.py +++ b/tests/system/test_cluster/test_agent_groups/test_group_sync_status.py @@ -147,28 +147,35 @@ def test_group_sync_status(metadata, target_node, clean_environment, group_creat first_time_check = 'synced' second_time_check = '' - # Check each 0.25 seconds/10 seconds sync_status + # Check each 0.10 seconds/10 seconds sync_status for _ in range(T_10): - time.sleep(T_025) - agent1_status = json.loads(execute_wdb_query(query, test_infra_hosts[0], host_manager))[1]['group_sync_status'] - agent2_status = json.loads(execute_wdb_query(query, test_infra_hosts[0], host_manager))[2]['group_sync_status'] + # Retrieve status information once to avoid redundant calls + status_info = json.loads(execute_wdb_query(query, test_infra_hosts[0], host_manager))[1:3] + agent1_status = status_info[0]['group_sync_status'] + agent2_status = status_info[1]['group_sync_status'] + # Determine the logic based on metadata['agent_in_group'] if metadata['agent_in_group'] == 'agent1': - if 'syncreq' == agent1_status and 'synced' == agent2_status: + if agent1_status == 'syncreq' and agent2_status == 'synced': first_time_check = "syncreq" + break elif metadata['agent_in_group'] == 'agent2': - if 'synced' == agent1_status and 'syncreq' == agent2_status: + if agent1_status == 'synced' and agent2_status == 'syncreq': first_time_check = "syncreq" + break else: if agent1_status == 'syncreq' and agent2_status == 'syncreq': first_time_check = 'syncreq' + break - time.sleep(T_5) + time.sleep(0.10) assert metadata['expected_first_check'] == first_time_check + time.sleep(T_5) + # Check after 5 seconds, sync_status if 'syncreq' in execute_wdb_query(query, test_infra_hosts[0], host_manager): second_time_check = 'syncreq' From b69c1f00ac65a9d66fda452aa75153affcf7e653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Thu, 21 Mar 2024 12:47:51 +0000 Subject: [PATCH 02/18] fix: restore stoud in run command method --- deps/wazuh_testing/wazuh_testing/tools/system.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/wazuh_testing/wazuh_testing/tools/system.py b/deps/wazuh_testing/wazuh_testing/tools/system.py index 88c33a6fc8..9726739b06 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/system.py +++ b/deps/wazuh_testing/wazuh_testing/tools/system.py @@ -374,7 +374,7 @@ def run_command(self, host: str, cmd: str, check: bool = False): Returns: stdout (str): The output of the command execution. """ - return self.get_host(host).ansible("command", cmd, check=check) + return self.get_host(host).ansible("command", cmd, check=check)["stdout"] def run_shell(self, host: str, cmd: str, check: bool = False): """Run a shell command on the specified host and return its stdout. From 53b8e4f70595f5df44652fcdb17002e4bee6307c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Tue, 26 Mar 2024 11:22:50 +0000 Subject: [PATCH 03/18] feat: increase timeout to 40 --- .../test_agent_groups/test_assign_agent_to_a_group.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group.py b/tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group.py index 390bbc4525..c5e64523f6 100644 --- a/tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group.py +++ b/tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group.py @@ -66,7 +66,7 @@ # Variables test_group = 'group_test' -timeout = 25 +timeout = 40 # Tests @@ -107,12 +107,15 @@ def test_assign_agent_to_a_group(agent_target, initial_status, clean_environment restart_cluster(test_infra_agents, host_manager) time.sleep(timeout) + # Check that agent status is active in cluster check_agent_status(agent_id, agent_name, agent_ip, AGENT_STATUS_ACTIVE, host_manager, test_infra_managers) if (initial_status == AGENT_STATUS_DISCONNECTED): host_manager.control_service(host='wazuh-agent1', service=WAZUH_SERVICE_PREFIX, state=WAZUH_SERVICES_STOPPED) + time.sleep(timeout) + check_agent_status(agent_id, agent_name, agent_ip, AGENT_STATUS_DISCONNECTED, host_manager, test_infra_managers) try: @@ -123,6 +126,7 @@ def test_assign_agent_to_a_group(agent_target, initial_status, clean_environment assign_agent_to_new_group('wazuh-master', test_group, agent_id, host_manager) time.sleep(timeout) + # Check that agent has group set to group_test on Managers check_agent_groups(agent_id, test_group, test_infra_managers, host_manager) From 6988bec6761aa26393dcf03a072042f769c3d0a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Tue, 26 Mar 2024 11:28:51 +0000 Subject: [PATCH 04/18] feat: increase timeout to 40 --- .../test_agent_groups/test_assign_agent_to_a_group_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py b/tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py index 0567cb03fe..8b59711001 100644 --- a/tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py +++ b/tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py @@ -63,7 +63,7 @@ tmp_path = os.path.join(local_path, 'tmp') # Variables -timeout = 10 +timeout = 30 test_group = 'group_test' From b8eb2dac1bf42a602c08740e823b38e7d0b79fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Tue, 26 Mar 2024 11:46:36 +0000 Subject: [PATCH 05/18] feat: increase timeout to 20 --- .../test_cluster/test_agent_groups/test_group_sync_status.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/system/test_cluster/test_agent_groups/test_group_sync_status.py b/tests/system/test_cluster/test_agent_groups/test_group_sync_status.py index 828de1f938..0a0b4f50e3 100644 --- a/tests/system/test_cluster/test_agent_groups/test_group_sync_status.py +++ b/tests/system/test_cluster/test_agent_groups/test_group_sync_status.py @@ -59,7 +59,7 @@ '..', '..', 'provisioning', 'enrollment_cluster', 'roles', 'agent-role', 'files', 'ossec.conf') t1_configuration_parameters, t1_configuration_metadata, t1_case_ids = get_test_cases_data(test_cases_yaml) - +TIMEOUT_SECOND_CHECK = 10 @pytest.fixture() def group_creation_and_assignation(metadata, target_node): @@ -141,6 +141,7 @@ def test_group_sync_status(metadata, target_node, clean_environment, group_creat cluster recreates groups without syncreq status. ''' # Delete group folder + delete_agent_group(metadata['delete_target'], metadata['group_folder_deleted'], host_manager, 'folder') # Set values @@ -174,7 +175,7 @@ def test_group_sync_status(metadata, target_node, clean_environment, group_creat assert metadata['expected_first_check'] == first_time_check - time.sleep(T_5) + time.sleep(TIMEOUT_SECOND_CHECK) # Check after 5 seconds, sync_status if 'syncreq' in execute_wdb_query(query, test_infra_hosts[0], host_manager): From 086431d41b6e7a513e79b0d6c30fcdeb5e75346d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Mon, 1 Apr 2024 14:42:44 +0100 Subject: [PATCH 06/18] fix: include timeout before gather group id --- .../system/test_cluster/test_agent_groups/test_remove_group.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/system/test_cluster/test_agent_groups/test_remove_group.py b/tests/system/test_cluster/test_agent_groups/test_remove_group.py index 8e8810df37..104e6becb7 100644 --- a/tests/system/test_cluster/test_agent_groups/test_remove_group.py +++ b/tests/system/test_cluster/test_agent_groups/test_remove_group.py @@ -100,6 +100,7 @@ def test_remove_group(metadata, group, target_node, pre_configured_groups, clean ''' # Get group IDs group_ids = {} + timeout_get_groups_id = 3 for manager in test_infra_managers: group_ids[manager] = str(get_group_id(group, manager, host_manager)) @@ -112,6 +113,8 @@ def test_remove_group(metadata, group, target_node, pre_configured_groups, clean messages_path=messages_path, tmp_path=tmp_path).run(update_position=True) + sleep(timeout_get_groups_id) + for manager in test_infra_managers: group_ids[manager] = str(get_group_id(group, manager, host_manager)) From 86b0c05a508eb65c0c042c9bdf2b0b4107400172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Tue, 2 Apr 2024 10:59:53 +0100 Subject: [PATCH 07/18] fix: increase group hash timeout --- .../test_cluster/test_agent_groups/test_group_hash.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/system/test_cluster/test_agent_groups/test_group_hash.py b/tests/system/test_cluster/test_agent_groups/test_group_hash.py index be985cbd02..9b670805ff 100644 --- a/tests/system/test_cluster/test_agent_groups/test_group_hash.py +++ b/tests/system/test_cluster/test_agent_groups/test_group_hash.py @@ -107,13 +107,13 @@ def test_group_hash(target_node, group, n_agents, configure_groups, clean_enviro # Restart agent restart_cluster(test_infra_agents, host_manager) - time.sleep(fw.T_10) + time.sleep(fw.T_20) # Assing group for multigroups case for agent in range(n_agents): if group != 'default': assign_agent_to_new_group(test_infra_managers[0], group, agents_data[agent][1], host_manager) - time.sleep(fw.T_10) + time.sleep(fw.T_20) # Calculate global hash expected_global_hash = calculate_global_hash(test_infra_managers[0], host_manager) @@ -129,7 +129,7 @@ def test_group_hash(target_node, group, n_agents, configure_groups, clean_enviro # Unassign one agent from group unassign_agent_from_group(test_infra_managers[0], group, agents_data[0][1], host_manager) - time.sleep(fw.T_10) + time.sleep(fw.T_20) # Calculate global hash expected_global_hash = calculate_global_hash(test_infra_managers[0], host_manager) From 3dbeca0e283fd99ee9bb72331756bddee9f36e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Tue, 2 Apr 2024 11:00:17 +0100 Subject: [PATCH 08/18] fix: increase guess group timeout --- .../test_agent_groups/data/guess_group_messages_master.yaml | 4 ++-- .../test_agent_groups/data/guess_group_messages_worker.yaml | 6 +++--- .../test_agent_groups/test_assign_groups_guess.py | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_master.yaml b/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_master.yaml index d7a718a22b..817b1bb70b 100644 --- a/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_master.yaml +++ b/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_master.yaml @@ -4,7 +4,7 @@ wazuh-master: timeout: 30 - regex: ".*Group assigned: 'GROUP_ID'" path: /var/ossec/logs/ossec.log - timeout: 10 + timeout: 30 - regex: .*Agent 'AGENT_ID' group is 'GROUP_ID' path: /var/ossec/logs/ossec.log - timeout: 10 + timeout: 30 diff --git a/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_worker.yaml b/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_worker.yaml index 096bb776d1..94a6e78078 100644 --- a/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_worker.yaml +++ b/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_worker.yaml @@ -5,14 +5,14 @@ wazuh-worker1: timeout: 30 - regex: ".*Message received from master node: '{\"error\":0,\"message\":\"ok\",\"data\":{\"group\":\"GROUP_ID\"}}'" path: /var/ossec/logs/ossec.log - timeout: 10 + timeout: 30 - regex: .*Agent 'AGENT_ID' group is 'GROUP_ID' path: /var/ossec/logs/ossec.log - timeout: 10 + timeout: 30 wazuh-master: - regex: .*Agent 'AGENT_ID' with file 'merged.mg' MD5 .* path: /var/ossec/logs/ossec.log timeout: 30 - regex: ".*Group assigned: 'GROUP_ID'" path: /var/ossec/logs/ossec.log - timeout: 10 + timeout: 30 diff --git a/tests/system/test_cluster/test_agent_groups/test_assign_groups_guess.py b/tests/system/test_cluster/test_agent_groups/test_assign_groups_guess.py index b59db3ea1a..1afb93165a 100644 --- a/tests/system/test_cluster/test_agent_groups/test_assign_groups_guess.py +++ b/tests/system/test_cluster/test_agent_groups/test_assign_groups_guess.py @@ -276,6 +276,7 @@ def test_guess_multigroups(n_agents, target_node, status_guess_agent_group, clea # Run the callback checks for the ossec.log messages_path = master_messages_path if target_node == 'wazuh-master' else worker_messages_path replace_regex_in_file(['AGENT_ID', 'GROUP_ID'], [agent1_id, expected_group], messages_path) + HostMonitor(inventory_path=inventory_path, messages_path=messages_path, tmp_path=tmp_path).run(update_position=True) From d9172cef20c527002b5c23b35ec2e6ae0682aed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Tue, 2 Apr 2024 11:01:29 +0100 Subject: [PATCH 09/18] fix: agent setup environment --- .../test_agent_enrollment.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py b/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py index 2cb61ca7a5..b97350ceb6 100644 --- a/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py +++ b/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py @@ -25,17 +25,27 @@ # Remove the agent once the test has finished @pytest.fixture(scope='module') -def clean_environment(): - yield +def setup_environment(): + host_manager.control_service(host='wazuh-agent1', service='wazuh', state="stopped") agent_id = host_manager.run_command('wazuh-master', f'cut -c 1-3 {WAZUH_PATH}/etc/client.keys') host_manager.get_host('wazuh-master').ansible("command", f'{WAZUH_PATH}/bin/manage_agents -r {agent_id}', check=False) + host_manager.clear_file(host='wazuh-agent1', file_path=os.path.join(WAZUH_PATH, 'etc', 'client.keys')) + host_manager.clear_file(host='wazuh-agent1', file_path=os.path.join(WAZUH_LOGS_PATH, 'ossec.log')) + + yield + host_manager.control_service(host='wazuh-agent1', service='wazuh', state="stopped") + agent_id = host_manager.run_command('wazuh-master', f'cut -c 1-3 {WAZUH_PATH}/etc/client.keys') + host_manager.get_host('wazuh-master').ansible("command", f'{WAZUH_PATH}/bin/manage_agents -r {agent_id}', + check=False) host_manager.clear_file(host='wazuh-agent1', file_path=os.path.join(WAZUH_PATH, 'etc', 'client.keys')) host_manager.clear_file(host='wazuh-agent1', file_path=os.path.join(WAZUH_LOGS_PATH, 'ossec.log')) + host_manager.control_service(host='wazuh-agent1', service='wazuh', state="start") + -def test_agent_enrollment(clean_environment): +def test_agent_enrollment(setup_environment): """Check agent enrollment process works as expected. An agent pointing to a worker should be able to register itself into the master by starting Wazuh-agent process.""" # Clean ossec.log and cluster.log From dc3fe02e7d10c50479692b88feae687ac75a3ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Tue, 2 Apr 2024 12:43:24 +0100 Subject: [PATCH 10/18] fix: increase timeout guess group --- .../data/guess_group_messages_master.yaml | 6 +++--- .../data/guess_group_messages_worker.yaml | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_master.yaml b/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_master.yaml index 817b1bb70b..ebd971cabc 100644 --- a/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_master.yaml +++ b/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_master.yaml @@ -1,10 +1,10 @@ wazuh-master: - regex: .*Agent 'AGENT_ID' with file 'merged.mg' MD5 .* path: var/ossec/logs/ossec.log - timeout: 30 + timeout: 60 - regex: ".*Group assigned: 'GROUP_ID'" path: /var/ossec/logs/ossec.log - timeout: 30 + timeout: 60 - regex: .*Agent 'AGENT_ID' group is 'GROUP_ID' path: /var/ossec/logs/ossec.log - timeout: 30 + timeout: 60 diff --git a/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_worker.yaml b/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_worker.yaml index 94a6e78078..a354ee9817 100644 --- a/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_worker.yaml +++ b/tests/system/test_cluster/test_agent_groups/data/guess_group_messages_worker.yaml @@ -2,17 +2,17 @@ wazuh-worker1: - regex: ".*Sending message to master node: '{\"daemon_name\":\"remoted\",\"message\":{\"command\":\"assigngroup\",\ \"parameters\":{\"agent\":\"AGENT_ID\",\"md5\":.*" path: /var/ossec/logs/ossec.log - timeout: 30 + timeout: 60 - regex: ".*Message received from master node: '{\"error\":0,\"message\":\"ok\",\"data\":{\"group\":\"GROUP_ID\"}}'" path: /var/ossec/logs/ossec.log - timeout: 30 + timeout: 60 - regex: .*Agent 'AGENT_ID' group is 'GROUP_ID' path: /var/ossec/logs/ossec.log - timeout: 30 + timeout: 60 wazuh-master: - regex: .*Agent 'AGENT_ID' with file 'merged.mg' MD5 .* path: /var/ossec/logs/ossec.log - timeout: 30 + timeout: 60 - regex: ".*Group assigned: 'GROUP_ID'" path: /var/ossec/logs/ossec.log - timeout: 30 + timeout: 60 From e2d413bbfc76b9e7f4e1a1f93d8c1e991a44980f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Wed, 3 Apr 2024 09:42:31 +0100 Subject: [PATCH 11/18] fix: restore setup env fixture --- .../test_agent_enrollment/test_agent_enrollment.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py b/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py index b97350ceb6..3196d1499f 100644 --- a/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py +++ b/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py @@ -26,12 +26,6 @@ # Remove the agent once the test has finished @pytest.fixture(scope='module') def setup_environment(): - host_manager.control_service(host='wazuh-agent1', service='wazuh', state="stopped") - agent_id = host_manager.run_command('wazuh-master', f'cut -c 1-3 {WAZUH_PATH}/etc/client.keys') - host_manager.get_host('wazuh-master').ansible("command", f'{WAZUH_PATH}/bin/manage_agents -r {agent_id}', - check=False) - host_manager.clear_file(host='wazuh-agent1', file_path=os.path.join(WAZUH_PATH, 'etc', 'client.keys')) - host_manager.clear_file(host='wazuh-agent1', file_path=os.path.join(WAZUH_LOGS_PATH, 'ossec.log')) yield @@ -48,6 +42,7 @@ def setup_environment(): def test_agent_enrollment(setup_environment): """Check agent enrollment process works as expected. An agent pointing to a worker should be able to register itself into the master by starting Wazuh-agent process.""" + # Clean ossec.log and cluster.log host_manager.clear_file(host='wazuh-master', file_path=os.path.join(WAZUH_LOGS_PATH, 'ossec.log')) host_manager.clear_file(host='wazuh-worker1', file_path=os.path.join(WAZUH_LOGS_PATH, 'ossec.log')) @@ -57,7 +52,7 @@ def test_agent_enrollment(setup_environment): # Start the agent enrollment process by restarting the wazuh-agent host_manager.control_service(host='wazuh-master', service='wazuh', state="restarted") host_manager.control_service(host='wazuh-worker1', service='wazuh', state="restarted") - host_manager.get_host('wazuh-agent1').ansible('command', f'service wazuh-agent restart', check=False) + host_manager.control_service(host='wazuh-agent1', service='wazuh', state="restarted") # Run the callback checks for the ossec.log and the cluster.log HostMonitor(inventory_path=inventory_path, From f45a1a2acd377fd06055c210d3794152f980d007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Wed, 3 Apr 2024 10:13:49 +0100 Subject: [PATCH 12/18] docs: include 5134 changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d904188361..d99f9035eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ All notable changes to this project will be documented in this file. ### Fixed +- Fix enrollment cluster system testS ([#5134](https://github.com/wazuh/wazuh-qa/pull/5134/)) \- (Tests) - Fix test_shutdown_message system test ([#5087](https://github.com/wazuh/wazuh-qa/pull/5087)) \- (Tests) - Include timeout to test_authd system tests ([#5083](https://github.com/wazuh/wazuh-qa/pull/5083)) \- (Tests) - Fix Vulnerability Detection mismatch in scans ([#5053](https://github.com/wazuh/wazuh-qa/pull/5053)) \- (Tests) From a7847b256c7e5ab99b45a96be0a33f7ae7053b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Wed, 3 Apr 2024 10:14:29 +0100 Subject: [PATCH 13/18] refac: remove redundant commentaries --- .../test_cluster/test_agent_groups/test_group_sync_status.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/system/test_cluster/test_agent_groups/test_group_sync_status.py b/tests/system/test_cluster/test_agent_groups/test_group_sync_status.py index 0a0b4f50e3..07878fb677 100644 --- a/tests/system/test_cluster/test_agent_groups/test_group_sync_status.py +++ b/tests/system/test_cluster/test_agent_groups/test_group_sync_status.py @@ -150,12 +150,10 @@ def test_group_sync_status(metadata, target_node, clean_environment, group_creat # Check each 0.10 seconds/10 seconds sync_status for _ in range(T_10): - # Retrieve status information once to avoid redundant calls status_info = json.loads(execute_wdb_query(query, test_infra_hosts[0], host_manager))[1:3] agent1_status = status_info[0]['group_sync_status'] agent2_status = status_info[1]['group_sync_status'] - # Determine the logic based on metadata['agent_in_group'] if metadata['agent_in_group'] == 'agent1': if agent1_status == 'syncreq' and agent2_status == 'synced': first_time_check = "syncreq" From f1194589a5f32f44d9d944141d20e4479790c51e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Wed, 3 Apr 2024 10:14:44 +0100 Subject: [PATCH 14/18] refac: move timeout to global variable --- .../test_cluster/test_agent_groups/test_remove_group.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/system/test_cluster/test_agent_groups/test_remove_group.py b/tests/system/test_cluster/test_agent_groups/test_remove_group.py index 104e6becb7..44b8188107 100644 --- a/tests/system/test_cluster/test_agent_groups/test_remove_group.py +++ b/tests/system/test_cluster/test_agent_groups/test_remove_group.py @@ -29,7 +29,7 @@ # Variables t1_configuration_parameters, t1_configuration_metadata, t1_case_ids = get_test_cases_data(t1_cases_path) queries = ['sql select `group` from agent;', 'sql select name from `group`;', 'sql select id_group from belongs;'] - +TIMEOUT_GET_GROUPS_ID = 3 # Fixtures @pytest.fixture() @@ -100,7 +100,6 @@ def test_remove_group(metadata, group, target_node, pre_configured_groups, clean ''' # Get group IDs group_ids = {} - timeout_get_groups_id = 3 for manager in test_infra_managers: group_ids[manager] = str(get_group_id(group, manager, host_manager)) @@ -113,7 +112,7 @@ def test_remove_group(metadata, group, target_node, pre_configured_groups, clean messages_path=messages_path, tmp_path=tmp_path).run(update_position=True) - sleep(timeout_get_groups_id) + sleep(TIMEOUT_GET_GROUPS_ID) for manager in test_infra_managers: group_ids[manager] = str(get_group_id(group, manager, host_manager)) From ced84eab984347a68f64bed90a2e1bc9a58484d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Wed, 3 Apr 2024 10:23:41 +0100 Subject: [PATCH 15/18] docs: fix typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d99f9035eb..83c1997024 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,7 +49,7 @@ All notable changes to this project will be documented in this file. ### Fixed -- Fix enrollment cluster system testS ([#5134](https://github.com/wazuh/wazuh-qa/pull/5134/)) \- (Tests) +- Fix enrollment cluster system tests ([#5134](https://github.com/wazuh/wazuh-qa/pull/5134/)) \- (Tests) - Fix test_shutdown_message system test ([#5087](https://github.com/wazuh/wazuh-qa/pull/5087)) \- (Tests) - Include timeout to test_authd system tests ([#5083](https://github.com/wazuh/wazuh-qa/pull/5083)) \- (Tests) - Fix Vulnerability Detection mismatch in scans ([#5053](https://github.com/wazuh/wazuh-qa/pull/5053)) \- (Tests) From 0f098db962a82f2710afce9dccb0951ae272e66d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Wed, 3 Apr 2024 10:39:40 +0100 Subject: [PATCH 16/18] fix: remove start agent in setup yield --- .../test_cluster/test_agent_enrollment/test_agent_enrollment.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py b/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py index 3196d1499f..65016c2ea2 100644 --- a/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py +++ b/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py @@ -35,7 +35,6 @@ def setup_environment(): check=False) host_manager.clear_file(host='wazuh-agent1', file_path=os.path.join(WAZUH_PATH, 'etc', 'client.keys')) host_manager.clear_file(host='wazuh-agent1', file_path=os.path.join(WAZUH_LOGS_PATH, 'ossec.log')) - host_manager.control_service(host='wazuh-agent1', service='wazuh', state="start") From ba4854b425a99614faca812dd902b2b2a8ed15bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Wed, 3 Apr 2024 11:06:09 +0100 Subject: [PATCH 17/18] style: rename fixture --- .../test_agent_enrollment/test_agent_enrollment.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py b/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py index 65016c2ea2..1126656086 100644 --- a/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py +++ b/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py @@ -25,7 +25,7 @@ # Remove the agent once the test has finished @pytest.fixture(scope='module') -def setup_environment(): +def clean_environment(): yield @@ -37,8 +37,7 @@ def setup_environment(): host_manager.clear_file(host='wazuh-agent1', file_path=os.path.join(WAZUH_LOGS_PATH, 'ossec.log')) - -def test_agent_enrollment(setup_environment): +def test_agent_enrollment(clean_environment): """Check agent enrollment process works as expected. An agent pointing to a worker should be able to register itself into the master by starting Wazuh-agent process.""" From e293cb4e3fb9f94430842425ea83cc2d06f1e205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Wed, 3 Apr 2024 11:06:44 +0100 Subject: [PATCH 18/18] style: remove extra white space --- .../test_cluster/test_agent_enrollment/test_agent_enrollment.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py b/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py index 1126656086..7fc9b2b1bf 100644 --- a/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py +++ b/tests/system/test_cluster/test_agent_enrollment/test_agent_enrollment.py @@ -40,7 +40,6 @@ def clean_environment(): def test_agent_enrollment(clean_environment): """Check agent enrollment process works as expected. An agent pointing to a worker should be able to register itself into the master by starting Wazuh-agent process.""" - # Clean ossec.log and cluster.log host_manager.clear_file(host='wazuh-master', file_path=os.path.join(WAZUH_LOGS_PATH, 'ossec.log')) host_manager.clear_file(host='wazuh-worker1', file_path=os.path.join(WAZUH_LOGS_PATH, 'ossec.log'))