Skip to content

Commit

Permalink
TESTS: exception handling while spawning fcgi-program which address a…
Browse files Browse the repository at this point in the history
…lready bound to another process
  • Loading branch information
cod1k committed Jan 27, 2023
1 parent cd1aaf5 commit 3285628
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion supervisor/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3285628

Please sign in to comment.