Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: verify SN can be stopped using SIGTERM #892

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if it fails, we're stuck here, right? Maybe it's better to pass/check some return code when node is killed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, if it fails - we will get a TimeoutError after 60 seconds

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flag is about what to do when we get this TimeoutError - with force - we use kill, without force - we raise an error

stopped_nodes.append(node_to_stop)

object_nodes_after_stop = wait_object_replication(
Expand Down
Loading