You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2021/04/05 21:48:09 UTC

[airflow] 10/16: Finish quarantine for test_should_force_kill_process (#15081)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v2-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 657e707aac3862af3a452ce39e56ff46cfa3d14c
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Sat Apr 3 12:49:40 2021 +0200

    Finish quarantine for test_should_force_kill_process (#15081)
    
    Changing the test to check actual PID of the process to kill
    
    (cherry picked from commit de22fc7fae05a4521870869f1035f5e4859e877f)
---
 tests/utils/test_process_utils.py | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/tests/utils/test_process_utils.py b/tests/utils/test_process_utils.py
index 2c14ae4..21d6cdd 100644
--- a/tests/utils/test_process_utils.py
+++ b/tests/utils/test_process_utils.py
@@ -136,23 +136,21 @@ class TestKillChildProcessesByPids(unittest.TestCase):
         num_process = subprocess.check_output(["ps", "-ax", "-o", "pid="]).decode().count("\n")
         assert before_num_process == num_process
 
-    @pytest.mark.quarantined
     def test_should_force_kill_process(self):
-        before_num_process = subprocess.check_output(["ps", "-ax", "-o", "pid="]).decode().count("\n")
 
         process = multiprocessing.Process(target=my_sleep_subprocess_with_signals, args=())
         process.start()
         sleep(0)
 
-        num_process = subprocess.check_output(["ps", "-ax", "-o", "pid="]).decode().count("\n")
-        assert before_num_process + 1 == num_process
+        all_processes = subprocess.check_output(["ps", "-ax", "-o", "pid="]).decode().splitlines()
+        assert str(process.pid) in map(lambda x: x.strip(), all_processes)
 
         with self.assertLogs(process_utils.log) as cm:
             process_utils.kill_child_processes_by_pids([process.pid], timeout=0)
         assert any("Killing child PID" in line for line in cm.output)
-
-        num_process = subprocess.check_output(["ps", "-ax", "-o", "pid="]).decode().count("\n")
-        assert before_num_process == num_process
+        sleep(0)
+        all_processes = subprocess.check_output(["ps", "-ax", "-o", "pid="]).decode().splitlines()
+        assert str(process.pid) not in map(lambda x: x.strip(), all_processes)
 
 
 class TestPatchEnviron(unittest.TestCase):