From 25b976e5fdc3d5b8eff8494021b8cc4b696c99d8 Mon Sep 17 00:00:00 2001
From: Yaroslav Dynnikov <yaroslav.dynnikov@gmail.com>
Date: Fri, 18 Nov 2022 18:16:01 +0300
Subject: [PATCH] test: killing a supervisor should be noticed by child

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

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.
---
 test/int/test_supervisor.py | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/test/int/test_supervisor.py b/test/int/test_supervisor.py
index e8608768a9..87202f3f4e 100644
--- a/test/int/test_supervisor.py
+++ b/test/int/test_supervisor.py
@@ -20,7 +20,8 @@ def instance(cluster: Cluster):
 
 
 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):
@@ -38,13 +39,28 @@ def test_instance_kill(instance: Instance):
     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):
     # Scenario: suspending of child process prevents the parent process from interrupting
     #   Given an instance
-    #   When child process is stopped
+    #   When child process is stopped with SIGSTOP
     #   And parent process got SIGINT
     #   Then parent process keep living
-    #   When child process is continued
+    #   When child process is continued with SIGCONT
     #   Then parent process gracefully exits
 
     assert instance.process
-- 
GitLab