Skip to content
Snippets Groups Projects
Commit 25b976e5 authored by Yaroslav Dynnikov's avatar Yaroslav Dynnikov
Browse files

test: killing a supervisor should be noticed by child

An important test case (5b5d25f3) went missing after migration from
luatest to pytest (b6630a41).

Conftest operates subprocesses in a different way than luatest helpers
did: luatest used to signal a signal process (supervisor), while
`instance.kill()` signals the whole process group.
parent 79af50db
No related branches found
No related tags found
1 merge request!366test: killing a supervisor should be noticed by child
Pipeline #13569 passed
...@@ -20,7 +20,8 @@ def instance(cluster: Cluster): ...@@ -20,7 +20,8 @@ def instance(cluster: Cluster):
def assert_all_pids_down(pids): def assert_all_pids_down(pids):
assert all(map(lambda pid: not pid_alive(pid), pids)) for pid in pids:
assert not pid_alive(pid)
def test_instance_kill(instance: Instance): def test_instance_kill(instance: Instance):
...@@ -38,13 +39,28 @@ def test_instance_kill(instance: Instance): ...@@ -38,13 +39,28 @@ def test_instance_kill(instance: Instance):
retrying(lambda: assert_all_pids_down(pids)) retrying(lambda: assert_all_pids_down(pids))
def test_sigkill_parent(instance: Instance):
# Scenario: killing a supervisor should be noticed by child
# Given an instance
# When parent process is killed with SIGKILL
# Then child process gracefully exits
assert instance.process
pids = pgrep_tree(instance.process.pid)
os.kill(instance.process.pid, signal.SIGKILL)
os.waitpid(instance.process.pid, 0)
retrying(lambda: assert_all_pids_down(pids))
def test_sigint_parent(instance: Instance): def test_sigint_parent(instance: Instance):
# Scenario: suspending of child process prevents the parent process from interrupting # Scenario: suspending of child process prevents the parent process from interrupting
# Given an instance # Given an instance
# When child process is stopped # When child process is stopped with SIGSTOP
# And parent process got SIGINT # And parent process got SIGINT
# Then parent process keep living # Then parent process keep living
# When child process is continued # When child process is continued with SIGCONT
# Then parent process gracefully exits # Then parent process gracefully exits
assert instance.process assert instance.process
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment