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

Fix number of files and their size for test_zip_size_limit #5133

Merged
merged 6 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ All notable changes to this project will be documented in this file.

### Fixed

- Fix number of files and their size for `test_zip_size_limit` ([#5133](https://github.com/wazuh/wazuh-qa/pull/5133)) \- (Tests)
- Fix test_shutdown_message system test ([#5087](https://github.com/wazuh/wazuh-qa/pull/5087)) \- (Tests)
- Include timeout to test_authd system tests ([#5083](https://github.com/wazuh/wazuh-qa/pull/5083)) \- (Tests)
- Fix Vulnerability Detection mismatch in scans ([#5053](https://github.com/wazuh/wazuh-qa/pull/5053)) \- (Tests)
Expand Down
2 changes: 1 addition & 1 deletion tests/system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ In the event that the tests are to be executed using AWS EC2 instances:
|------------------------------|-------------------------------------------|
|Basic_cluster |Ubuntu 22.04.2 LTS C5.XLarge 15GB SSD |
|Big_cluster_40_agents |Ubuntu 22.04.2 LTS T3.Large 60GB SSD |
|Agentless_cluster |Ubuntu 22.04.2 LTS T3.Large 30GB SSD |
|Agentless_cluster |Ubuntu 22.04.2 LTS C5a.XLarge 30GB SSD |
|Four_manager_disconnected_node|Ubuntu 22.04.2 LTS T3.Large 30GB SSD |
|One_manager_agent |Ubuntu 22.04.2 LTS T3.Large 30GB SSD |
|Manager_agent |Ubuntu 22.04.2 LTS T3.Large 30GB SSD |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
timeout_receiving_file: 1
max_zip_size: 104857600 # 100 MB
min_zip_size: 15728640 # 15 MB
min_zip_size: 5242880 # 5 MB
compress_level: 0
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,13 @@
tmp_size_test_path = os.path.join(WAZUH_PATH, 'tmp')
dst_size_test_path = os.path.join(WAZUH_PATH, 'etc', 'rules')
big_file_name = 'test_file_too_big'
file_prefix = 'test_file_big_'
file_prefix = 'test_file_'

# merged.mg and agent.conf files that must be created after creating a group folder.
merged_mg_file = os.path.join(directories_to_create[0], 'merged.mg')
agent_conf_file = os.path.join(directories_to_create[0], 'agent.conf')


# Functions

def create_file(host, path, size):
"""Create file of fixed size.

Args:
host (str): Host where the file should be created.
path (str): Path and name where to create the file.
size (int, str): Size of the file (if nothing specified, in bytes)
"""
host_manager.run_command(host, f"fallocate -l {size} {path}")
host_manager.run_command(host, f"chown wazuh:wazuh {path}")


# Fixtures

@pytest.fixture(scope='function')
Expand Down Expand Up @@ -261,14 +247,16 @@ def test_zip_size_limit(clean_files, update_cluster_json):
- The workers end up receiving all the files that do not exceed the maximum size.
"""
too_big_size = configuration['max_zip_size'] + 1024
big_size = configuration['min_zip_size'] - 1024
big_filenames = {file_prefix + str(i) for i in range(10)}
big_filenames = {file_prefix + str(i+1) for i in range(140)}

# Create a tmp folder and all files inside in the master node.
host_manager.run_command(test_hosts[0], f"mkdir {tmp_size_test_path}")
create_file(test_hosts[0], os.path.join(tmp_size_test_path, big_file_name), too_big_size)
for filename in big_filenames:
create_file(test_hosts[0], os.path.join(tmp_size_test_path, filename), big_size)
host_manager.run_command(test_hosts[0], f"fallocate -l {too_big_size} {tmp_size_test_path}/{big_file_name}")
host_manager.run_command(test_hosts[0], f"chown wazuh:wazuh {tmp_size_test_path}/{big_file_name}")
host_manager.run_shell(test_hosts[0],
f"for i in `seq 1 140`; do fallocate -l 1M {tmp_size_test_path}/{file_prefix}$i; done")
host_manager.run_shell(test_hosts[0],
f"for i in `seq 1 140`; do chown wazuh:wazuh {tmp_size_test_path}/{file_prefix}$i; done")

# Move files from tmp folder to destination folder. This way, all files are synced at the same time.
host_manager.run_shell(test_hosts[0], f"mv {os.path.join(tmp_size_test_path, 'test_*')} {dst_size_test_path}")
Expand Down
Loading