From d834456e5afdf46edf6bd43e9e28bcb1f8107628 Mon Sep 17 00:00:00 2001 From: Evgeniy Zayats Date: Mon, 4 Nov 2024 16:11:45 -0500 Subject: [PATCH] tests: verify SN can be stopped using SIGTERM Signed-off-by: Evgeniy Zayats --- neofs-testlib/neofs_testlib/env/env.py | 17 ++++++++++------- .../tests/failovers/test_failover_storage.py | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/neofs-testlib/neofs_testlib/env/env.py b/neofs-testlib/neofs_testlib/env/env.py index 8e55cf75e..836f3fee4 100644 --- a/neofs-testlib/neofs_testlib/env/env.py +++ b/neofs-testlib/neofs_testlib/env/env.py @@ -60,14 +60,17 @@ class WalletType(Enum): ALPHABET = 2 -def terminate_process(process: Popen): +def terminate_process(process: Popen, force=True): process.terminate() try: process.wait(timeout=60) except TimeoutExpired as e: logger.info(f"Didn't manage to terminate process gracefully: {e}") - process.kill() - process.wait(timeout=60) + if force: + process.kill() + process.wait(timeout=60) + else: + raise AssertionError("Process was not terminated by SIGTERM") class NeoFSEnv: @@ -977,9 +980,9 @@ def start(self, fresh=True): allure.attach(str(self), f"sn_{self.sn_number}", allure.attachment_type.TEXT, ".txt") @allure.step("Stop storage node") - def stop(self): + def stop(self, force=True): logger.info(f"Stopping Storage Node:{self}") - terminate_process(self.process) + terminate_process(self.process, force=force) self.process = None @allure.step("Kill storage node") @@ -1132,10 +1135,10 @@ def start(self, fresh=True): raise e @allure.step("Stop s3 gw") - def stop(self): + def stop(self, force=True): logger.info(f"Stopping s3 gw:{self}") self.process.terminate() - terminate_process(self.process) + terminate_process(self.process, force=force) self.process = None @retry(wait=wait_fixed(10), stop=stop_after_attempt(10), reraise=True) diff --git a/pytest_tests/tests/failovers/test_failover_storage.py b/pytest_tests/tests/failovers/test_failover_storage.py index df9e9ca35..3e100835c 100644 --- a/pytest_tests/tests/failovers/test_failover_storage.py +++ b/pytest_tests/tests/failovers/test_failover_storage.py @@ -56,7 +56,7 @@ def test_storage_node_failover( if hard_restart: node_to_stop.kill() else: - node_to_stop.stop() + node_to_stop.stop(force=False) stopped_nodes.append(node_to_stop) object_nodes_after_stop = wait_object_replication(