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

Refactor test_remove_audit to retry package installation if busy #3562

Merged
merged 4 commits into from
Nov 4, 2022
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 @@ -34,6 +34,7 @@ Release report: TBD

### Changed

- Improve `test_remove_audit` FIM test to retry install and remove command ([#3562](https:/wazuh/wazuh-qa/pull/3562)) \- (Tests)
- Skip unstable integration tests for gcloud ([#3531](https:/wazuh/wazuh-qa/pull/3531)) \- (Tests)
- Skip unstable integration test for agentd ([#3538](https:/wazuh/wazuh-qa/pull/3538))
- Update wazuhdb_getconfig and EPS limit integration tests ([#3146](https:/wazuh/wazuh-qa/pull/3146)) \- (Tests)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
from distro import id
from wazuh_testing.tools.configuration import load_wazuh_configurations, check_apply_test
from wazuh_testing.tools.monitoring import FileMonitor
from wazuh_testing.tools.utils import retry

# Marks

Expand All @@ -88,6 +89,21 @@
configurations = load_wazuh_configurations(configurations_path, __name__)


# Function

@retry(subprocess.CalledProcessError, attempts=5, delay=10)
def run_process(command_list):
"""Execute the command_list command

Args:
command_list (list): Command to be executed.

Returns:
subprocess.CompletedProcess: Command executed.
"""
return subprocess.run(command_list, check=True)


# Fixtures

@pytest.fixture(scope='module', params=configurations)
Expand Down Expand Up @@ -115,13 +131,13 @@ def uninstall_install_audit():
raise ValueError(f"Linux distro ({linux_distro}) not supported for uninstall/install audit")

# Uninstall audit
process = subprocess.run([package_management, "remove", audit, option], check=True)
process = run_process([package_management, "remove", audit, option])

yield

# Install audit and start the service
process = subprocess.run([package_management, "install", audit, option], check=True)
process = subprocess.run(["service", "auditd", "start"], check=True)
process = run_process([package_management, "install", audit, option])
process = run_process(["service", "auditd", "start"])


# Test
Expand Down