Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test_assign_groups_guess #3901

Merged
merged 7 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Release report: TBD

### Changed

- Improve `test_assign_groups_guess` ([#3901](https:/wazuh/wazuh-qa/pull/3901)) \- (Tests)
- Update `test_cluster_worker_logs_order` test ([#3896](https:/wazuh/wazuh-qa/pull/3896)) \- (Tests)
- Fix `test_agent_groups` ([#3889](https:/wazuh/wazuh-qa/pull/3889)) \- (Tests + Framework)
- Increase NVE download feed test timeout([#3769](https:/wazuh/wazuh-qa/pull/3769)) \- (Tests)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
block: |
authd.debug=2
wazuh_clusterd.debug=2
remoted.debug=2

- name: Start Wazuh
command: /var/ossec/bin/wazuh-control restart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
block: |
authd.debug=2
wazuh_clusterd.debug=2
remoted.debug=2

- name: Restart Wazuh
command: /var/ossec/bin/wazuh-control restart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
check_keys_file, delete_group_of_agents, remove_cluster_agents,
assign_agent_to_new_group, restart_cluster)
from wazuh_testing.tools.system import HostManager
from wazuh_testing.tools.file import replace_regex_in_file
from wazuh_testing.tools.monitoring import HostMonitor
from wazuh_testing.tools import WAZUH_PATH


Expand All @@ -59,6 +61,9 @@

inventory_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
'provisioning', 'enrollment_cluster', 'inventory.yml')
data_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')
master_messages_path = os.path.join(data_path, 'guess_group_messages_master.yaml')
worker_messages_path = os.path.join(data_path, 'guess_group_messages_worker.yaml')
host_manager = HostManager(inventory_path)
local_path = os.path.dirname(os.path.abspath(__file__))
tmp_path = os.path.join(local_path, 'tmp')
Expand All @@ -67,7 +72,7 @@
# Variables
remoted_guess_agent_groups = 'remoted.guess_agent_group='
# this timeout is temporality, this test will be update
timeout = 60
timeout = 20


# Tests
Expand All @@ -88,15 +93,6 @@ def test_assign_agent_to_a_group(agent_target, status_guess_agent_group, clean_e
- clean_enviroment:
type: Fixture
brief: Reset the wazuh log files at the start of the test. Remove all registered agents from master.
- test_infra_managers
type: List
brief: List of manager hosts in enviroment.
- test_infra_agents
type: List
brief: List of agent hosts in enviroment.
- host_manager
type: HostManager object
brief: Handles connection the enviroment's hosts.
assertions:
- Verify that after registering the agent key file exists in all nodes.
- Verify that after registering the agent appears as never_connected in all nodes.
Expand Down Expand Up @@ -154,8 +150,19 @@ def test_assign_agent_to_a_group(agent_target, status_guess_agent_group, clean_e
# Check if remoted.guess_agent_group is disabled
if(int(status_guess_agent_group) == 0):
group_id = 'default'
# Run the callback checks for the ossec.log
if(agent_target == 'wazuh-master'):
jmv74211 marked this conversation as resolved.
Show resolved Hide resolved
messages_path = master_messages_path
else:
messages_path = worker_messages_path

replace_regex_in_file(['AGENT_ID', 'GROUP_ID'], [agent_id, group_id], messages_path)
HostMonitor(inventory_path=inventory_path,
messages_path=messages_path,
tmp_path=tmp_path).run(update_position=True)
check_agent_groups(agent_id, group_id, test_infra_managers, host_manager)

finally:
# Delete group of agent
delete_group_of_agents(test_infra_managers[0], group_id, host_manager)
replace_regex_in_file([agent_id, group_id], ['AGENT_ID', 'GROUP_ID'], messages_path)