def test_waiting_for_zombie_process_finishes_immediately(self) -> None: with subprocess.Popen(["true"]) as process: wait_until_process_is_zombie(process) stop_watch = StopWatch() with stop_watch.measure(): wait_for_shutdown(process.pid, timeout=5) self.assertLessEqual(stop_watch.elapsed, 3)
def test_waiting_for_alive_unreaped_child_process_kills_with_sigkill( self) -> None: process = subprocess.Popen(["sleep", "30"]) # Don't reap the process yet. wait_for_shutdown(process.pid, timeout=1) returncode = process.wait() self.assertEqual(returncode, -signal.SIGKILL, "Process should have exited with SIGKILL")
def test_waiting_for_exited_process_finishes_immediately(self) -> None: process = AutoReapingChildProcess(["true"]) process.wait() stop_watch = StopWatch() with stop_watch.measure(): wait_for_shutdown(process.pid, timeout=5) self.assertLessEqual(stop_watch.elapsed, 3)
def test_killed_daemon_is_not_running(self) -> None: with self.spawn_fake_edenfs(self.temp_dir) as daemon_pid: os.kill(daemon_pid, signal.SIGKILL) wait_for_shutdown(pid=daemon_pid, timeout=5) status_process = self.spawn_status([]) status_process.expect_exact("edenfs not running") self.assert_process_fails(status_process, exit_code=1)
def test_killed_daemon_is_not_running(self) -> None: with self.spawn_fake_edenfs(self.temp_dir) as daemon_pid: os.kill(daemon_pid, signal.SIGKILL) wait_for_shutdown(pid=daemon_pid, timeout=5) status_process = self.spawn_status([]) status_process.expect_exact("edenfs not running") self.assert_process_fails(status_process, exit_code=1)
def test_waiting_for_alive_process_kills_with_sigkill(self) -> None: process = AutoReapingChildProcess(["sleep", "30"]) wait_for_shutdown(process.pid, timeout=1) returncode = process.wait() self.assertEqual(returncode, -signal.SIGKILL, "Process should have exited with SIGKILL")
def test_waiting_for_exiting_process_finishes_without_sigkill( self) -> None: process = AutoReapingChildProcess(["sleep", "1"]) wait_for_shutdown(process.pid, timeout=5) returncode = process.wait() self.assertEqual(returncode, 0, "Process should have exited cleanly")