diff options
Diffstat (limited to 'app/tests/test_backends_servers.py')
| -rw-r--r-- | app/tests/test_backends_servers.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/tests/test_backends_servers.py b/app/tests/test_backends_servers.py index 8eaf53f..ab05eed 100644 --- a/app/tests/test_backends_servers.py +++ b/app/tests/test_backends_servers.py @@ -35,6 +35,23 @@ class StartTests(unittest.TestCase): self.assertTrue(servers.start(self.spec)) mk.assert_not_called() + def test_refuses_to_double_start_while_previous_boot_is_alive(self): + """A live pid file blocks a second spawn of the same server. + + A previous ``start`` whose server is still booting must not be + orphaned by a duplicate process on the same port. + """ + pid_file = self.dir / "test-server.pid" + pid_file.write_text("4242", encoding="utf-8") + with patch.object(servers, "LOG_DIR", self.dir), \ + patch.object(servers, "_pid_alive", return_value=True), \ + patch("subprocess.Popen") as mk, \ + patch("backends.common.server_running", return_value=False): + ok = servers.start(self.spec) + self.assertFalse(ok) + mk.assert_not_called() + self.assertTrue(pid_file.exists()) + def test_happy_path_spawns_and_polls_until_ready(self): proc = MagicMock() proc.pid = 4242 |
