-
Notifications
You must be signed in to change notification settings - Fork 32
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
System Test: Module (WAZUH-DB) - The agent with state different than never_connected is added to a "group_test" group by API #2657
System Test: Module (WAZUH-DB) - The agent with state different than never_connected is added to a "group_test" group by API #2657
Conversation
tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py
Outdated
Show resolved
Hide resolved
tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py
Outdated
Show resolved
Hide resolved
tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py
Outdated
Show resolved
Hide resolved
tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py
Outdated
Show resolved
Hide resolved
tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py
Outdated
Show resolved
Hide resolved
tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py
Outdated
Show resolved
Hide resolved
tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py
Outdated
Show resolved
Hide resolved
tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py
Outdated
Show resolved
Hide resolved
tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py
Outdated
Show resolved
Hide resolved
response = host_manager.make_api_call('wazuh-master', method='PUT', | ||
endpoint=f'/agents/{agent_id}/group/group_test?pretty=true', | ||
token=token) | ||
print(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there tests that use other methods like "PUT"
? If this is the case, we could add method_name
on a file with each one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response = host_manager.make_api_call('wazuh-master', method='PUT', | ||
endpoint=f'/agents/{agent_id}/group/group_test?pretty=true', | ||
token=token) | ||
print(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response = host_manager.make_api_call('wazuh-master', method='PUT', | |
endpoint=f'/agents/{agent_id}/group/group_test?pretty=true', | |
token=token) | |
print(response) | |
response = host_manager.make_api_call('wazuh-master', method='PUT', | |
endpoint=f'/agents/{agent_id}/group/group_test?pretty=true', | |
token=token) |
tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py
Outdated
Show resolved
Hide resolved
tests/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py
Outdated
Show resolved
Hide resolved
# Delete group of agent | ||
delete_group_of_agents('wazuh-master', 'group_test', host_manager) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section should always be executed whether it fails or not. Add this inside a finally
section .
Tests Results
|
def test_assign_agent_to_a_group(agent_target, initial_status, clean_environment, test_infra_managers, test_infra_agents, | ||
host_manager): | ||
''' | ||
description: Check agent enrollment process and new group assignment works as expected in a cluster environment. | ||
Check that when an agent pointing to a master/worker node is registered, and when | ||
it's assigned to a new group using API the change is sync with the cluster. | ||
wazuh_min_version: 4.4.0 | ||
parameters: | ||
- agent_target: | ||
type: string | ||
brief: name of the host where the agent will register | ||
- initial_status: | ||
type: string | ||
brief: status of the agent when the assign the new group | ||
- clean_enviroment: | ||
type: fixture | ||
brief: Reset the wazuh log files at the start of the test. Remove all registered agents from master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There aren't the variables(test_infra_managers, test_infra_agents, host_manager) defined as parameters of the documentation.
In this PR the test suite for
The agent with state different than never_connected is added to a "group_test" group by API
is added. A total of new test cases covering different modes and combinations of options.Cases:
- The agent is active and registers with group to the
master
node using API- The agent is disconnected and registers with group to the
master
node using API- The agent is active and registers with group to the
worker
node using API- The agent is disconnected and registers with group to the
worker
node using APIConfiguration options
In order to run the test, first the environment located in
/test/system/provisioning/enrollment_cluster
must be enabled with:sudo ansible-playbook -i inventory.yml playbook.yml --extra-vars='{"wazuh_branch": "dev-10771-agent-groups-files-to-wazuh-db"}'
Local Internal Options: No Local Internal Options used
Tests Results
Required
pycodestyle --max-line-length=120 --show-source --show-pep8 file.py
.