wazuh / wazuh-qa

Wazuh - Quality Assurance
GNU General Public License v2.0
63 stars 30 forks source link

Agents are not being restarted after manager change in E2E vulnerability detection tests #5345

Closed Rebits closed 2 weeks ago

Rebits commented 3 weeks ago

Description

It has been detected in Release 4.8.0 - RC 1 - Vulnerability Detection E2E tests, that the test case test_change_agent_manager is truncating the agent/manager logs, making difficult to get any information of the environment in case of failure.

santipadilla commented 3 weeks ago

Investigating the truncation process, we can see that:

  1. In conftest.py file, clean_environment_logs and clean_environment_logs_function: both functions perform similar actions but have a different scope. They manage logs by deleting them at the end of their scope using truncate_remote_host_group_files.

  2. In logs.py file, truncate_remote_host_group_files: this function directly handles log deletion. It takes parameters to decide which host group and file types should be truncated.

  3. In file.py file, truncate_file: this function performs the action of opening the specified file in write mode, which automatically truncates the file.

To carry out this issue a conditional will be added to the clean_environment_logs function so that when the test_change_agent_manager case is performed it avoids truncation.

santipadilla commented 3 weeks ago

Test before changes

report.zip

Test after changes

report.zip

santipadilla commented 3 weeks ago

Changes made in this branch: fix/5345-skip-truncate-test-change-agent-manager In this PR: https://github.com/wazuh/wazuh-qa/pull/5355

rafabailon commented 3 weeks ago

LGTM

santipadilla commented 3 weeks ago

Moved ETA due to final review

Rebits commented 2 weeks ago

During a meeting with @santipadilla, we identified that the new agent configuration isn't properly applied after the configured agent is permuted because the agent isn't restarted following the change. It's likely that the restart agent call was inadvertently omitted during a merge or PR review.

The solution appears straightforward: ensure that agents are restarted after the permutate_manager fixture is applied.

Updated the issue title accordingly

[!WARNING] It's imperative to rerun this test in the E2E environment. Unfortunately, a current bug in RC1 (https://github.com/wazuh/wazuh/issues/23301) is hindering the appearance of some vulnerabilities. Therefore, we'll need to wait until this issue is resolved before verifying if there are any product-related issues concerning the manager change.

santipadilla commented 2 weeks ago

Update

Test before modifying permutate_agents_managers fixture

report.zip

Test after modifying permutate_agents_managers fixture

report.zip

Test with only test_change_agent_manager case

report.zip

santipadilla commented 2 weeks ago

New changes made in this branch: fix/5345-skip-truncate-test-change-agent-manager In this PR: https://github.com/wazuh/wazuh-qa/pull/5355