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) - Sync of agents registered on nodes after seconds #2761

Merged
merged 9 commits into from
Apr 11, 2022

Conversation

Deblintrake09
Copy link
Contributor

@Deblintrake09 Deblintrake09 commented Apr 6, 2022

In this PR the test suite for test_groups_sync_default.py is added. A total of 2 new test cases cover that when having a cluster, and a series of agents is registered over time, the group data is synchronized as expected.

Related issues #2514 #10771

Cases:

  • Agent group data is force sync over time:
    - Forty agents are registered to master and they have the default group assigned in the cluster

Configuration options

In order to run the test, first the environment located in /test/system/provisioning/big_cluster_40_agents 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_groups_sync_default.py Debian - Manager Local 🟢 🟢 🟢 05/04/2022 @Deblintrake09

  • 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 6 to 7
brief: This tests check that when a cluster has a series of agents registered and connecting one after the other,
and it is unable to do a Sync, that after a expected time, a Sync is forced and the DB is Synched.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
brief: This tests check that when a cluster has a series of agents registered and connecting one after the other,
and it is unable to do a Sync, that after a expected time, a Sync is forced and the DB is Synched.
brief: These tests check that when a cluster has a series of agents registered and connecting one after the other,
and it is unable to do a Sync, that after an expected time, a Sync is forced and the DB is Synched.

parameters:
- agent_host:
type: List
brief: name of the host where the agent will register en each case
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
brief: name of the host where the agent will register en each case
brief: name of the host where the agent will register in each case

Comment on lines 68 to 70
@pytest.mark.parametrize("test_infra_managers",[test_infra_managers])
@pytest.mark.parametrize("test_infra_agents",[test_infra_agents])
@pytest.mark.parametrize("host_manager",[host_manager])
Copy link
Contributor

Choose a reason for hiding this comment

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

Add space after comma in order to follow pycodestyle

Suggested change
@pytest.mark.parametrize("test_infra_managers",[test_infra_managers])
@pytest.mark.parametrize("test_infra_agents",[test_infra_agents])
@pytest.mark.parametrize("host_manager",[host_manager])
@pytest.mark.parametrize("test_infra_managers", [test_infra_managers])
@pytest.mark.parametrize("test_infra_agents", [test_infra_agents])
@pytest.mark.parametrize("host_manager", [host_manager])

test_infra_managers = ["wazuh-master", "wazuh-worker1", "wazuh-worker2"]
agents_in_cluster = 40
test_infra_agents=[]
for x in range(agents_in_cluster):
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove space at the end of the line in order to follow pycodestyle

Suggested change
for x in range(agents_in_cluster):
for x in range(agents_in_cluster):

# Hosts
test_infra_managers = ["wazuh-master", "wazuh-worker1", "wazuh-worker2"]
agents_in_cluster = 40
test_infra_agents=[]
Copy link
Contributor

Choose a reason for hiding this comment

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

Add space before and after equal symbol in order to follow pycodestyle

Suggested change
test_infra_agents=[]
test_infra_agents = []

'''
description: Check that after a long time when the manager has been unable to synchronize de databases, because
new agents are being continually added, database synchronization is forced and the expected information is in
all nodes after the expected sync time. For this, an agent is restarted and connects to the agent every roughly 10
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove space at the end of line in order to follow pycodestyle

Suggested change
all nodes after the expected sync time. For this, an agent is restarted and connects to the agent every roughly 10
all nodes after the expected sync time. For this, an agent is restarted and connects to the agent every roughly 10

'''

# Register agents in manager
agent_data=[]
Copy link
Contributor

Choose a reason for hiding this comment

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

Add space before and after equal symbol in order to follow pycodestyle

Suggested change
agent_data=[]
agent_data = []

while time.time() < end_time:
if active_agent < agents_in_cluster:
host_manager.run_command(test_infra_agents[active_agent], f'{WAZUH_PATH}/bin/wazuh-control start')
active_agent = active_agent +1
Copy link
Contributor

Choose a reason for hiding this comment

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

missing whitespace around the operator

Suggested change
active_agent = active_agent +1
active_agent = active_agent + 1

@CamiRomero
Copy link
Contributor

Tests Results

Test Path Os/Type Execution Type Results Date By
test/system/test_cluster/test_agent_groups/test_groups_sync_default.py Debian - Manager Local 🟢🟢 🟢 11/04/2022 @CamiRomero

@CamiRomero CamiRomero merged commit 428bc48 into system_test_wazuh_db Apr 11, 2022
@CamiRomero CamiRomero deleted the tmp-2514-test-group-synchro-default branch April 11, 2022 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System Test - Wazuh DB (T2): Sync of agents registered on nodes after seconds
3 participants