Skip to content

Commit

Permalink
tests: verify SN can be stopped using SIGTERM
Browse files Browse the repository at this point in the history
Signed-off-by: Evgeniy Zayats <zayatsevgeniy@nspcc.io>
  • Loading branch information
Evgeniy Zayats committed Nov 4, 2024
1 parent d5d7798 commit d834456
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions neofs-testlib/neofs_testlib/env/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pytest_tests/tests/failovers/test_failover_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit d834456

Please sign in to comment.