Skip to content

Commit

Permalink
enhancement(#4843): More dynamic waits
Browse files Browse the repository at this point in the history
  • Loading branch information
pro-akim committed Mar 19, 2024
1 parent 080b7a2 commit 11b6ac8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from ..helpers.manager import WazuhManager
from ..helpers.agent import WazuhAgent
from ..helpers.generic import HostConfiguration, CheckFiles, HostInformation, GeneralComponentActions
from ..helpers.executor import WazuhAPI
from ..helpers.constants import WAZUH_ROOT


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import pytest
import time

from ..helpers.manager import WazuhManager, WazuhAPI
from ..helpers.agent import WazuhAgent, WazuhAPI
from ..helpers.generic import HostConfiguration, CheckFiles, HostInformation, GeneralComponentActions
from ..helpers.constants import WAZUH_ROOT
from ..helpers.generic import GeneralComponentActions
from ..helpers.utils import dynamic_wait

@pytest.fixture
Expand Down Expand Up @@ -67,6 +65,7 @@ def test_isActive(wazuh_params):
wazuh_api = WazuhAPI(wazuh_params['master'])
for agent_names, agent_params in wazuh_params['agents'].items():
assert GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent')

expected_condition_func = lambda: 'active' == WazuhAgent.get_agent_status(wazuh_api, agent_names)
dynamic_wait(expected_condition_func, cycles=10, waiting_time=20)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import pytest

from ..helpers.manager import WazuhManager
from ..helpers.agent import WazuhAgent
from ..helpers.generic import HostConfiguration, CheckFiles, HostInformation, GeneralComponentActions
from ..helpers.constants import WAZUH_ROOT
from ..helpers.generic import GeneralComponentActions


@pytest.fixture
Expand Down
12 changes: 6 additions & 6 deletions deployability/modules/testing/tests/test_agent/test_stop.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import pytest

from ..helpers.manager import WazuhManager, WazuhAPI
from ..helpers.agent import WazuhAgent
from ..helpers.generic import HostConfiguration, CheckFiles, HostInformation, GeneralComponentActions
from ..helpers.constants import WAZUH_ROOT

from ..helpers.agent import WazuhAgent, WazuhAPI
from ..helpers.generic import GeneralComponentActions
from ..helpers.utils import dynamic_wait

@pytest.fixture
def wazuh_params(request):
Expand Down Expand Up @@ -56,5 +54,7 @@ def test_stop(wazuh_params):

for agent_names, agent_params in wazuh_params['agents'].items():
assert 'inactive' in GeneralComponentActions.get_component_status(agent_params, 'wazuh-agent')
assert 'disconnected' == WazuhAgent.get_agent_status(wazuh_api, agent_names)
assert not GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent')

expected_condition_func = lambda: 'disconnected' == WazuhAgent.get_agent_status(wazuh_api, agent_names)
dynamic_wait(expected_condition_func, cycles=10, waiting_time=20)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from ..helpers.manager import WazuhManager, WazuhAPI
from ..helpers.agent import WazuhAgent
from ..helpers.generic import HostConfiguration, CheckFiles, HostInformation, GeneralComponentActions
from ..helpers.generic import CheckFiles, HostInformation, GeneralComponentActions
from ..helpers.utils import dynamic_wait
from ..helpers.constants import WAZUH_ROOT


Expand Down Expand Up @@ -97,4 +98,6 @@ def test_isActive(wazuh_params):
wazuh_api = WazuhAPI(wazuh_params['master'])
for agent_names, agent_params in wazuh_params['agents'].items():
assert not GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent')
assert 'disconnected' == WazuhAgent.get_agent_status(wazuh_api, agent_names)

expected_condition_func = lambda: 'disconnected' == WazuhAgent.get_agent_status(wazuh_api, agent_names)
dynamic_wait(expected_condition_func, cycles=10, waiting_time=20)

0 comments on commit 11b6ac8

Please sign in to comment.