test: stop client nodes after test

This commit is contained in:
Roman 2025-03-05 05:20:51 +00:00
parent 6ff8510d61
commit c4fad7ac84
No known key found for this signature in database
GPG Key ID: BB3828275C58EFF1
4 changed files with 16 additions and 8 deletions

View File

@ -113,3 +113,6 @@ class NomosCli:
@retry(stop=stop_after_delay(5), wait=wait_fixed(0.1), reraise=True) @retry(stop=stop_after_delay(5), wait=wait_fixed(0.1), reraise=True)
def kill(self): def kill(self):
self._container = kill(self._container) self._container = kill(self._container)
def name(self):
return self._container_name

View File

@ -91,8 +91,8 @@ class StepsCommon:
delay(5) delay(5)
@pytest.fixture(scope="function") @pytest.fixture(scope="function")
def init_client_nodes(self, request): def setup_client_nodes(self, request):
logger.debug(f"Running fixture init: {inspect.currentframe().f_code.co_name}") logger.debug(f"Running fixture setup: {inspect.currentframe().f_code.co_name}")
if hasattr(request, "param"): if hasattr(request, "param"):
num_clients = request.param num_clients = request.param
@ -101,6 +101,5 @@ class StepsCommon:
for i in range(num_clients): for i in range(num_clients):
cli_node = NomosCli(command="client_node") cli_node = NomosCli(command="client_node")
cli_node.run()
self.client_nodes.append(cli_node) self.client_nodes.append(cli_node)
delay(1)

View File

@ -71,6 +71,7 @@ def attach_logs_on_fail(request):
@pytest.fixture(scope="function", autouse=True) @pytest.fixture(scope="function", autouse=True)
def close_open_nodes(attach_logs_on_fail): def close_open_nodes(attach_logs_on_fail):
DS.nomos_nodes = [] DS.nomos_nodes = []
DS.client_nodes = []
yield yield
logger.debug(f"Running fixture teardown: {inspect.currentframe().f_code.co_name}") logger.debug(f"Running fixture teardown: {inspect.currentframe().f_code.co_name}")
crashed_containers = [] crashed_containers = []
@ -80,7 +81,14 @@ def close_open_nodes(attach_logs_on_fail):
except Exception as ex: except Exception as ex:
if "No such container" in str(ex): if "No such container" in str(ex):
crashed_containers.append(node.image) 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!!!" assert not crashed_containers, f"Containers {crashed_containers} crashed during the test!!!"

View File

@ -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_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" 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): def test_sustained_high_rate_multiple_clients(self):
timeout = 60 timeout = 60
start_time = time.time() start_time = time.time()
@ -121,8 +121,6 @@ class TestHighLoadDos(StepsDataAvailability):
successful_downloads = 0 successful_downloads = 0
unsuccessful_downloads = 0 unsuccessful_downloads = 0
self.client_nodes[0].run()
while True: while True:
if time.time() - start_time > timeout: if time.time() - start_time > timeout:
break break