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

System Test: Module (WAZUH-DB) - The agent with state different than never_connected is added to a "group_test" group by API #2657

Merged

Conversation

CamiRomero
Copy link
Contributor

@CamiRomero CamiRomero commented Mar 9, 2022

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.

Related issues #2508 #10771

Cases:

  • Assign agent with API:
    - 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 API

Configuration 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

Test Path Os/Type Execution Type Results Date By
test/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py CentOS - Manager Local 🟢[:large_blue_circle:][:large_blue_circle:] 09/03/2022 @CamiRomero

Required

  • Proven that tests pass when they have to pass.
  • Proven that tests fail when they have to fail.
  • Python codebase satisfies PEP-8 style style guide. pycodestyle --max-line-length=120 --show-source --show-pep8 file.py.
  • Python codebase is documented following the Google Style for Python docstrings.

Comment on lines 120 to 123
response = host_manager.make_api_call('wazuh-master', method='PUT',
endpoint=f'/agents/{agent_id}/group/group_test?pretty=true',
token=token)
print(response)
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 120 to 123
response = host_manager.make_api_call('wazuh-master', method='PUT',
endpoint=f'/agents/{agent_id}/group/group_test?pretty=true',
token=token)
print(response)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Comment on lines 129 to 130
# Delete group of agent
delete_group_of_agents('wazuh-master', 'group_test', host_manager)
Copy link
Member

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 .

@Deblintrake09
Copy link
Contributor

Deblintrake09 commented Mar 15, 2022

Tests Results

Test Path Os/Type Execution Type Results Date By
test/system/test_cluster/test_agent_groups/test_assign_agent_to_a_group_api.py CentOS - Manager Local 🟢🟢🟢 15/03/2022 @Deblintrake09

Comment on lines +74 to +90
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.
Copy link
Member

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.

@damarisg damarisg merged commit f2764fe into system_test_wazuh_db Mar 16, 2022
@damarisg damarisg deleted the 2506_system_test_assign_agent_to_a_group_api branch March 16, 2022 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants