diff --git a/src/cli/nomos_cli.py b/src/cli/nomos_cli.py index 36286b0..df9dab9 100644 --- a/src/cli/nomos_cli.py +++ b/src/cli/nomos_cli.py @@ -113,3 +113,6 @@ class NomosCli: @retry(stop=stop_after_delay(5), wait=wait_fixed(0.1), reraise=True) def kill(self): self._container = kill(self._container) + + def name(self): + return self._container_name diff --git a/src/steps/common.py b/src/steps/common.py index 2ca8f56..1e3cb60 100644 --- a/src/steps/common.py +++ b/src/steps/common.py @@ -91,8 +91,8 @@ class StepsCommon: delay(5) @pytest.fixture(scope="function") - def init_client_nodes(self, request): - logger.debug(f"Running fixture init: {inspect.currentframe().f_code.co_name}") + def setup_client_nodes(self, request): + logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}") if hasattr(request, "param"): num_clients = request.param @@ -101,6 +101,5 @@ class StepsCommon: for i in range(num_clients): cli_node = NomosCli(command="client_node") + cli_node.run() self.client_nodes.append(cli_node) - - delay(1) diff --git a/tests/conftest.py b/tests/conftest.py index 66d83d4..3145fb2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -71,6 +71,7 @@ def attach_logs_on_fail(request): @pytest.fixture(scope="function", autouse=True) def close_open_nodes(attach_logs_on_fail): DS.nomos_nodes = [] + DS.client_nodes = [] yield logger.debug(f"Running fixture teardown: {inspect.currentframe().f_code.co_name}") crashed_containers = [] @@ -80,7 +81,14 @@ def close_open_nodes(attach_logs_on_fail): except Exception as ex: if "No such container" in str(ex): crashed_containers.append(node.image) - logger.error(f"Failed to stop container because of error {ex}") + logger.error(f"Failed to stop node container because of error {ex}") + for node in DS.client_nodes: + try: + node.stop() + except Exception as ex: + if "No such container" in str(ex): + crashed_containers.append(node.name()) + logger.error(f"Failed to stop client node container because of error {ex}") assert not crashed_containers, f"Containers {crashed_containers} crashed during the test!!!" diff --git a/tests/dos_robustness/test_high_load_dos.py b/tests/dos_robustness/test_high_load_dos.py index ab5f258..5e73dd6 100644 --- a/tests/dos_robustness/test_high_load_dos.py +++ b/tests/dos_robustness/test_high_load_dos.py @@ -112,7 +112,7 @@ class TestHighLoadDos(StepsDataAvailability): assert failure_ratio_w < 0.20, f"Dispersal failure ratio {failure_ratio_w} too high" assert failure_ratio_r < 0.20, f"Data download failure ratio {failure_ratio_r} too high" - @pytest.mark.usefixtures("setup_2_node_cluster", "init_client_nodes") + @pytest.mark.usefixtures("setup_2_node_cluster", "setup_client_nodes") def test_sustained_high_rate_multiple_clients(self): timeout = 60 start_time = time.time() @@ -121,8 +121,6 @@ class TestHighLoadDos(StepsDataAvailability): successful_downloads = 0 unsuccessful_downloads = 0 - self.client_nodes[0].run() - while True: if time.time() - start_time > timeout: break