-
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 Tests: Module (FIM) - FIM Files Events: System test for FIM synchronization process #2536
Conversation
…2434-fim-synchronizaton-agent-stopped
…2434-fim-synchronizaton-agent-stopped
type: system | ||
brief: Check that when FIM is activated, and the agent is running, the agent and manager are synchronization when | ||
a change is performed in a monitored folder. | ||
tier: 1 |
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.
tier: 1 | |
tier: 0 |
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 is not part of this PR. I applied the change in 2443
|
||
import pytest |
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.
import pytest | |
import pytest | |
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 is not part of this PR. I applied the change in #2443
''' | ||
The test will monitor a directory. | ||
Finally, it will verify that the FIM event is generated | ||
in agent and manager side. | ||
''' |
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.
Add the comments as shown in the schema 2.0
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 was worked in PR [2443](This is not part of this PR. 2443
type: system | ||
brief: Check that when FIM is activated, and the agent is running, the agent and manager are synchronization when | ||
a change is performed in a monitored folder. | ||
tier: 1 |
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.
tier: 1 | |
tier: 0 |
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.
Done in commit 83482
Description: The test will monitor a directory and apply changes when agent is stopped. | ||
Finally, it will verify that the FIM 'Synchronization' event is generated | ||
in agent and manager side. |
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.
The synchronization is when the agent and manager are running again, right?
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.
Done in commit 71e04
@pytest.mark.parametrize('host', ['wazuh-agent1', 'wazuh-manager']) | ||
@pytest.mark.parametrize('case', ['add', 'modify', 'delete']) | ||
@pytest.mark.parametrize('folder_path', ['testdir1']) | ||
def test_Synchronization_create_file_agent_stopped(folder_path, case, host): |
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.
def test_Synchronization_create_file_agent_stopped(folder_path, case, host): | |
def test_synchronization_create_file_agent_stopped(folder_path, case, host): |
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.
Done in commit 7ae07
testinfra_hosts = ["wazuh-manager", "wazuh-agent1"] | ||
|
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.
When do you use it?
|
||
|
||
# Hosts | ||
testinfra_hosts = ["wazuh-manager", "wazuh-agent1"] |
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.
When do you use it?
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.
Done in commit 080c1
|
||
clean_logs(host_manager) | ||
|
||
# Stop agent |
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 are 2 cases: the agent stops and the manager stops.
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.
Done in commit 1321a
@pytest.mark.parametrize('host', ['wazuh-agent1', 'wazuh-manager']) | ||
@pytest.mark.parametrize('case', ['add', 'modify', 'delete']) | ||
@pytest.mark.parametrize('folder_path', ['testdir1']) | ||
def test_Synchronization_create_file_agent_stopped(folder_path, case, host): |
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.
The name should be representative. It doesn't just create a file (it also modifies and deletes it) and, the description says that it is when the manager or agent stops (2 cases). However, the test name only talks about agent stopped.
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.
Done in commit 7ae07
|
…zuh/wazuh-qa into 2434-fim-synchronizaton-agent-stopped
tests/system/test_fim/__init__.py
Outdated
def create_folder_file(host_manager, folder_path): | ||
# Create folder | ||
host_manager.run_command('wazuh-agent1', f'mkdir {folder_path}') | ||
|
||
# Create file | ||
host_manager.run_command('wazuh-agent1', f'touch {folder_path}/{folder_path}.txt') | ||
|
||
|
||
def wait_for_fim_scan_end(HostMonitor, inventory_path, messages_path, tmp_path): | ||
HostMonitor(inventory_path=inventory_path, | ||
messages_path=messages_path, | ||
tmp_path=tmp_path).run() | ||
|
||
|
||
def clean_logs(host_manager): | ||
host_manager.clear_file(host='wazuh-manager', file_path=os.path.join(WAZUH_LOGS_PATH, 'ossec.log')) | ||
host_manager.clear_file(host='wazuh-agent1', file_path=os.path.join(WAZUH_LOGS_PATH, 'ossec.log')) | ||
|
||
|
||
def query_db(host_manager, script, db_path, query): | ||
return host_manager.run_command('wazuh-manager', "python {} --db_path {} --query {}".format(script, db_path, query)) |
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.
Comments are necessary for each method. Why don't you have them here?
…zuh/wazuh-qa into 2434-fim-synchronizaton-agent-stopped
|
|
|
Description
While developing wazuh/wazuh#9103 we are planning to develop some system tests to check that the FIM database agent and the manager database are synchronized.
The changes made are as follows:
Configuration options
In order to run the test, first the environment located in /test/system/provisioning/one_manager_agent must be enabled with:
sudo ansible-playbook -i inventory.yml playbook.yml --extra-vars='{"wazuh_branch": "4.2"}'
Logs example
Tests
pycodestyle --max-line-length=120 --show-source --show-pep8 file.py
.