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

Improve the agent_files_deletion test #2296

Merged
merged 9 commits into from
Jan 11, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def register_agent():
"""Restart the removed agent to trigger auto-enrollment."""
yield
host_manager.get_host(agent_host).ansible('command', f'service wazuh-agent restart', check=False)
sleep(15)
yanazaeva marked this conversation as resolved.
Show resolved Hide resolved


def test_agent_files_deletion(register_agent):
Expand All @@ -40,6 +41,7 @@ def test_agent_files_deletion(register_agent):
master_token = host_manager.get_api_token(master_host)
response = host_manager.make_api_call(host=master_host, method='GET', token=master_token,
endpoint=f'/agents?select=id,name&q=manager={worker_host}')
juliamagan marked this conversation as resolved.
Show resolved Hide resolved

assert response['status'] == 200, f'Failed when trying to obtain agent ID: {response}'
juliamagan marked this conversation as resolved.
Show resolved Hide resolved
try:
agent_id = response['json']['data']['affected_items'][0]['id']
Expand All @@ -57,6 +59,7 @@ def test_agent_files_deletion(register_agent):
f'{file["path"].format(id=agent_id, name=agent_name)}'

# Check that agent information exists in global.db
sleep(time_to_sync)
yanazaeva marked this conversation as resolved.
Show resolved Hide resolved
for host in managers_hosts:
for query in db_queries:
result = host_manager.run_command(
Expand Down