From 328562866dd676891c059a22e93549aef54cfe26 Mon Sep 17 00:00:00 2001 From: cod1k Date: Fri, 27 Jan 2023 18:36:03 +0200 Subject: [PATCH] TESTS: exception handling while spawning fcgi-program which address already bound to another process --- supervisor/tests/test_process.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/supervisor/tests/test_process.py b/supervisor/tests/test_process.py index d9370e24c..cd9e49961 100644 --- a/supervisor/tests/test_process.py +++ b/supervisor/tests/test_process.py @@ -20,7 +20,7 @@ from supervisor.tests.base import DummyProcessGroup from supervisor.tests.base import DummyFCGIProcessGroup -from supervisor.process import Subprocess +from supervisor.process import Subprocess, ProcessStates from supervisor.options import BadCommand class SubprocessTests(unittest.TestCase): @@ -1799,6 +1799,18 @@ def test_before_spawn_gets_socket_ref(self): instance.before_spawn() self.assertFalse(instance.fcgi_sock is None) + def test_before_spawn_failure_sets_fatal_state(self): + options = DummyOptions() + config = DummyPConfig(options, 'good', '/good/filename', uid=1) + instance = self._makeOne(config) + instance.group = Mock() + socket_manager = Mock() + instance.group.attach_mock(socket_manager, 'socket_manager') + socket_manager.attach_mock(Mock(side_effect=Exception), 'get_socket') + self.assertEqual(instance.state, ProcessStates.STOPPED) + instance.spawn() + self.assertEqual(instance.state, ProcessStates.FATAL) + def test_after_finish_removes_socket_ref(self): options = DummyOptions() config = DummyPConfig(options, 'good', '/good/filename', uid=1)