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

Update API performance tests #1881

Merged
merged 2 commits into from
Sep 27, 2021
Merged
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
files_to_sync = [os.path.join(WAZUH_PATH, "etc", "lists", "test_file"),
os.path.join(WAZUH_PATH, "etc", "rules", "test_file"),
os.path.join(WAZUH_PATH, "etc", "decoders", "test_file"),
os.path.join(directories_to_create[1], 'merged.mg')]
os.path.join(directories_to_create[1], 'merged.mg'),
os.path.join(directories_to_create[0], 'test_file')]

# Files inside directories where not 'all' files have to be synchronized, according to cluster.json.
files_not_to_sync = [os.path.join(WAZUH_PATH, "etc", "test_file"),
Expand All @@ -37,7 +38,6 @@
os.path.join(WAZUH_PATH, "etc", "lists", 'test.tmp'),
os.path.join(WAZUH_PATH, "etc", "lists", 'test.lock'),
os.path.join(WAZUH_PATH, "etc", "lists", 'test.swp'),
os.path.join(directories_to_create[0], 'test_file'),
os.path.join(directories_to_create[1], 'test_file')]

# merged.mg and agent.conf files that must be created after creating a group folder.
Expand Down Expand Up @@ -84,7 +84,7 @@ def test_missing_file(clean_files):
assert perm == '660', f"{file} permissions were expected to be '660' in {host}, but they are {perm}."
# Check that files which should not be synchronized are not sent to the workers. For example, only
# merged.mg file inside /var/ossec/etc/shared/ directory should be synchronized, but nothing else.
for file in files_not_to_sync + [agent_conf_file]:
for file in files_not_to_sync:
result = host_manager.run_command(host, f'ls {file}')
assert result == '', f"File {file} was expected not to be copied in {host}, but it was."

Expand Down Expand Up @@ -124,6 +124,13 @@ def test_shared_files():
assert agent_conf_content in result, f'File {merged_mg_file} inside {host} should contain ' \
f'{agent_conf_content}, but it has: {result} '

# Check whether the agent.conf file is correctly updated in master and synchronized in workers or not.
agent_conf_content = host_manager.run_command(test_hosts[0], f'cat {agent_conf_file}')
for host in test_hosts:
result = host_manager.run_command(host, f'cat {agent_conf_file}')
assert agent_conf_content in result, f'File {agent_conf_file} inside {host} should contain ' \
f'{agent_conf_content}, but it has: {result} '

# Update the content of files in the worker node.
for host in worker_hosts:
for file in files_to_sync:
Expand Down Expand Up @@ -187,7 +194,7 @@ def test_extra_valid_files(clean_files):
# Check the client.keys files is correctly updated in the workers.
worker_client_keys = host_manager.run_command(host, f'cat {client_keys_path}')
assert master_client_keys == worker_client_keys, f'The client.keys file is not the same in the master and' \
f'ind the {host} ->' \
f'in the {host} ->' \
f'\nMaster client keys:\n{master_client_keys}' \
f'\nWorker client keys:\n{worker_client_keys}'

Expand Down