def test_removeProcessFromGroup_raises_bad_name_when_process_does_not_exist(self):
        pconfig = DummyPConfig(None, 'foo', '/bin/foo')
        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {}

        supervisord = DummySupervisor(process_groups = {'group_name': pgroup})
        interface = self.makeOne(supervisord)

        self.assertRPCError(SupervisorFaults.BAD_NAME,
                            interface.removeProcessFromGroup,
                            'group_name', 'nonexistant_process_name')
 def test_runforever_select_dispatcher_exitnow_via_write(self):
     options = DummyOptions()
     options.poller.result = [], [6]
     supervisord = self._makeOne(options)
     pconfig = DummyPConfig(options, 'foo', '/bin/foo',)
     gconfig = DummyPGroupConfig(options, pconfigs=[pconfig])
     pgroup = DummyProcessGroup(gconfig)
     from supervisor.medusa import asyncore_25 as asyncore
     exitnow = DummyDispatcher(readable=True, error=asyncore.ExitNow)
     pgroup.dispatchers = {6:exitnow}
     supervisord.process_groups = {'foo': pgroup}
     options.test = True
     self.assertRaises(asyncore.ExitNow, supervisord.runforever)
 def test_runforever_select_dispatcher_handle_error_via_write(self):
     options = DummyOptions()
     options.poller.result = [], [6]
     supervisord = self._makeOne(options)
     pconfig = DummyPConfig(options, 'foo', '/bin/foo',)
     gconfig = DummyPGroupConfig(options, pconfigs=[pconfig])
     pgroup = DummyProcessGroup(gconfig)
     notimpl = DummyDispatcher(readable=True, error=NotImplementedError)
     pgroup.dispatchers = {6:notimpl}
     supervisord.process_groups = {'foo': pgroup}
     options.test = True
     supervisord.runforever()
     self.assertEqual(notimpl.error_handled, True)
 def test_runforever_select_dispatcher_exitnow(self):
     options = DummyOptions()
     supervisord = self._makeOne(options)
     pconfig = DummyPConfig(options, 'foo', '/bin/foo',)
     gconfig = DummyPGroupConfig(options, pconfigs=[pconfig])
     pgroup = DummyProcessGroup(gconfig)
     from supervisor.medusa import asyncore_25 as asyncore
     exitnow = DummyDispatcher(readable=True, error=asyncore.ExitNow)
     pgroup.dispatchers = {6:exitnow}
     supervisord.process_groups = {'foo': pgroup}
     options.select_result = [6], [], []
     options.test = True
     self.assertRaises(asyncore.ExitNow, supervisord.runforever)
    def test_removeProcessFromGroup_deletes_the_process(self):
        pconfig = DummyPConfig(None, "foo", "/bin/foo")
        process = DummyProcess(pconfig, ProcessStates.STOPPED)
        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {"process_name": process}
        supervisord = DummySupervisor(process_groups={"group_name": pgroup})
        interface = self.makeOne(supervisord)
        result = interface.removeProcessFromGroup("group_name", "process_name")

        self.assertTrue(result)
        self.assertTrue(pgroup.processes.get("process_name") is None)
        self.assertEqual("removeProcessFromGroup", interface.update_text)
Beispiel #6
0
    def test_removeProcessFromGroup_raises_bad_name_when_process_does_not_exist(
            self):
        pconfig = DummyPConfig(None, 'foo', '/bin/foo')
        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {}

        supervisord = DummySupervisor(process_groups={'group_name': pgroup})
        interface = self.makeOne(supervisord)

        self.assertRPCError(SupervisorFaults.BAD_NAME,
                            interface.removeProcessFromGroup, 'group_name',
                            'nonexistant_process_name')
 def test_runforever_select_dispatcher_handle_error_via_write(self):
     options = DummyOptions()
     options.poller.result = [], [sys.stdout]
     supervisord = self._makeOne(options)
     pconfig = DummyPConfig(options, 'foo', '/bin/foo', )
     gconfig = DummyPGroupConfig(options, pconfigs=[pconfig])
     pgroup = DummyProcessGroup(gconfig)
     notimpl = DummyDispatcher(readable=True, error=NotImplementedError)
     pgroup.dispatchers = {sys.stdout: notimpl}
     supervisord.process_groups = {'foo': pgroup}
     options.test = True
     supervisord.runforever()
     self.assertEqual(notimpl.error_handled, True)
Beispiel #8
0
    def test_removeProcessFromGroup_transitions_process_group(self):
        pconfig = DummyPConfig(None, 'foo', '/bin/foo')
        process = DummyProcess(pconfig, ProcessStates.EXITED)

        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {'process_name': process}

        supervisord = DummySupervisor(process_groups={'group_name': pgroup})
        interface = self.makeOne(supervisord)

        result = interface.removeProcessFromGroup('group_name', 'process_name')
        self.assertTrue(result)
        self.assertTrue(pgroup.transitioned)
    def test_removeProcessFromGroup_transitions_process_group(self):
        pconfig = DummyPConfig(None, 'foo', '/bin/foo')
        process = DummyProcess(pconfig, ProcessStates.EXITED)

        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = { 'process_name': process }

        supervisord = DummySupervisor(process_groups = {'group_name': pgroup})
        interface = self.makeOne(supervisord)

        result = interface.removeProcessFromGroup('group_name', 'process_name')
        self.assertTrue(result)
        self.assertTrue(pgroup.transitioned)
Beispiel #10
0
    def test_removeProcessFromGroup_deletes_the_process(self):
        pconfig = DummyPConfig(None, 'foo', '/bin/foo')
        process = DummyProcess(pconfig, ProcessStates.STOPPED)

        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {'process_name': process}

        supervisord = DummySupervisor(process_groups={'group_name': pgroup})
        interface = self.makeOne(supervisord)

        result = interface.removeProcessFromGroup('group_name', 'process_name')
        self.assertTrue(result)
        self.assertTrue(pgroup.processes.get('process_name') is None)
        self.assertEqual('removeProcessFromGroup', interface.update_text)
    def test_removeProcessFromGroup_raises_still_running_when_process_has_pid(self):
        pconfig = DummyPConfig(None, 'foo', '/bin/foo')
        process = DummyProcess(pconfig)
        process.pid = 42

        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = { 'process_with_pid': process }

        supervisord = DummySupervisor(process_groups = {'group_name': pgroup})
        interface = self.makeOne(supervisord)

        self.assertRPCError(SupervisorFaults.STILL_RUNNING,
                            interface.removeProcessFromGroup,
                            'group_name', 'process_with_pid')
    def test_removeProcessFromGroup_deletes_the_process(self):
        pconfig = DummyPConfig(None, 'foo', '/bin/foo')
        process = DummyProcess(pconfig, ProcessStates.STOPPED)

        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = { 'process_name': process }

        supervisord = DummySupervisor(process_groups = {'group_name': pgroup})
        interface = self.makeOne(supervisord)

        result = interface.removeProcessFromGroup('group_name', 'process_name')
        self.assertTrue(result)
        self.assertTrue(pgroup.processes.get('process_name') is None)
        self.assertEqual('removeProcessFromGroup', interface.update_text)
 def test_exit_delayed(self):
     options = DummyOptions()
     supervisord = self._makeOne(options)
     pconfig = DummyPConfig(options, 'foo', '/bin/foo',)
     process = DummyProcess(pconfig)
     gconfig = DummyPGroupConfig(options, pconfigs=[pconfig])
     pgroup = DummyProcessGroup(gconfig)
     pgroup.unstopped_processes = [process]
     L = []
     def callback():
         L.append(1)
     supervisord.process_groups = {'foo': pgroup}
     supervisord.options.mood = 0
     supervisord.options.test = True
     supervisord.runforever()
     self.assertNotEqual(supervisord.lastshutdownreport, 0)
Beispiel #14
0
    def test_removeProcessFromGroup_raises_still_running_when_process_has_pid(
            self):
        pconfig = DummyPConfig(None, 'foo', '/bin/foo')
        process = DummyProcess(pconfig)
        process.pid = 42

        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {'process_with_pid': process}

        supervisord = DummySupervisor(process_groups={'group_name': pgroup})
        interface = self.makeOne(supervisord)

        self.assertRPCError(SupervisorFaults.STILL_RUNNING,
                            interface.removeProcessFromGroup, 'group_name',
                            'process_with_pid')
 def test_exit_delayed(self):
     options = DummyOptions()
     supervisord = self._makeOne(options)
     pconfig = DummyPConfig(options, 'foo', '/bin/foo',)
     process = DummyProcess(pconfig)
     gconfig = DummyPGroupConfig(options, pconfigs=[pconfig])
     pgroup = DummyProcessGroup(gconfig)
     pgroup.unstopped_processes = [process]
     L = []
     def callback():
         L.append(1)
     supervisord.process_groups = {'foo': pgroup}
     supervisord.options.mood = SupervisorStates.RESTARTING
     supervisord.options.test = True
     supervisord.runforever()
     self.assertNotEqual(supervisord.lastshutdownreport, 0)
    def test_addProgramToGroup_adds_all_processes_resulting_from_program_options(self):
        gconfig = DummyPGroupConfig(None, pconfigs=[])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {}

        supervisord = DummySupervisor(process_groups = {'group_name': pgroup})
        supervisord.options = supervisor.options.ServerOptions()

        interface = self.makeOne(supervisord)

        poptions = {'command': '/usr/bin/find /',
                    'process_name': 'find_%(process_num)d',
                    'numprocs': 3}
        self.assertTrue(interface.addProgramToGroup('group_name', 'new_process', poptions))
        self.assertEqual('addProgramToGroup', interface.update_text)

        self.assertEqual(3, len(pgroup.config.process_configs))
        self.assertEqual(3, len(pgroup.processes))
 def test_runforever_poll_dispatchers(self):
     options = DummyOptions()
     options.poller.result = [6], [7, 8]
     supervisord = self._makeOne(options)
     pconfig = DummyPConfig(options, 'foo', '/bin/foo',)
     gconfig = DummyPGroupConfig(options, pconfigs=[pconfig])
     pgroup = DummyProcessGroup(gconfig)
     readable = DummyDispatcher(readable=True)
     writable = DummyDispatcher(writable=True)
     error = DummyDispatcher(writable=True, error=OSError)
     pgroup.dispatchers = {6:readable, 7:writable, 8:error}
     supervisord.process_groups = {'foo': pgroup}
     options.test = True
     supervisord.runforever()
     self.assertEqual(pgroup.transitioned, True)
     self.assertEqual(readable.read_event_handled, True)
     self.assertEqual(writable.write_event_handled, True)
     self.assertEqual(error.error_handled, True)
 def test_runforever_select_dispatchers(self):
     options = DummyOptions()
     supervisord = self._makeOne(options)
     pconfig = DummyPConfig(options, 'foo', '/bin/foo',)
     gconfig = DummyPGroupConfig(options, pconfigs=[pconfig])
     pgroup = DummyProcessGroup(gconfig)
     readable = DummyDispatcher(readable=True)
     writable = DummyDispatcher(writable=True)
     error = DummyDispatcher(writable=True, error=OSError)
     pgroup.dispatchers = {6:readable, 7:writable, 8:error}
     supervisord.process_groups = {'foo': pgroup}
     options.select_result = [6], [7, 8], []
     options.test = True
     supervisord.runforever()
     self.assertEqual(pgroup.transitioned, True)
     self.assertEqual(readable.read_event_handled, True)
     self.assertEqual(writable.write_event_handled, True)
     self.assertEqual(error.error_handled, True)
    def test_addProgramToGroup_adds_new_process_config_to_group(self):
        pconfig = DummyPConfig(None, "foo", "/bin/foo")
        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {}

        supervisord = DummySupervisor(process_groups={"group_name": pgroup})
        supervisord.options = supervisor.options.ServerOptions()
        interface = self.makeOne(supervisord)
        poptions = {"command": "/usr/bin/find /"}

        self.assertTrue(
            interface.addProgramToGroup("new_process", poptions, "group_name"))
        self.assertEqual("addProgramToGroup", interface.update_text)

        config = pgroup.config.process_configs[1]
        self.assertEqual("new_process", config.name)
        self.assertTrue(isinstance(config, supervisor.options.ProcessConfig))
    def test_addProgramToGroup_adds_new_process_config_to_group(self):
        pconfig = DummyPConfig(None, 'foo', '/bin/foo')
        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {}

        supervisord = DummySupervisor(process_groups = {'group_name': pgroup})
        supervisord.options = supervisor.options.ServerOptions()

        interface = self.makeOne(supervisord)

        poptions = {'command': '/usr/bin/find /'}
        self.assertTrue(interface.addProgramToGroup('group_name', 'new_process', poptions))
        self.assertEqual('addProgramToGroup', interface.update_text)

        config = pgroup.config.process_configs[1]
        self.assertEqual('new_process', config.name)
        self.assertTrue(isinstance(config, supervisor.options.ProcessConfig))
Beispiel #21
0
    def test_addProgramToGroup_adds_new_process_config_to_group(self):
        pconfig = DummyPConfig(None, 'foo', '/bin/foo')
        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {}

        supervisord = DummySupervisor(process_groups={'group_name': pgroup})
        supervisord.options = supervisor.options.ServerOptions()

        interface = self.makeOne(supervisord)

        poptions = {'command': '/usr/bin/find /'}
        self.assertTrue(
            interface.addProgramToGroup('group_name', 'new_process', poptions))
        self.assertEqual('addProgramToGroup', interface.update_text)

        config = pgroup.config.process_configs[1]
        self.assertEqual('new_process', config.name)
        self.assertTrue(isinstance(config, supervisor.options.ProcessConfig))
    def test_addGroup_raises_already_added_when_group_already_exists(self):
        pconfig = DummyPConfig(None, "foo", "/bin/foo")
        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)

        supervisord = DummySupervisor(process_groups={"foo": pgroup})
        interface = self.makeOne(supervisord)

        self.assertRPCError(SupervisorFaults.ALREADY_ADDED, interface.addGroup,
                            "foo", 999)
    def test_addProgramToGroup_adds_all_processes_resulting_from_program_options(
            self):
        gconfig = DummyPGroupConfig(None, pconfigs=[])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {}
        supervisord = DummySupervisor(process_groups={"group_name": pgroup})
        supervisord.options = supervisor.options.ServerOptions()
        interface = self.makeOne(supervisord)
        poptions = {
            "command": "/usr/bin/find /",
            "process_name": "find_%(process_num)d",
            "numprocs": 3,
        }

        self.assertTrue(
            interface.addProgramToGroup("new_process", poptions, "group_name"))
        self.assertEqual("addProgramToGroup", interface.update_text)
        self.assertEqual(3, len(pgroup.config.process_configs))
        self.assertEqual(3, len(pgroup.processes))
    def test_addProgramToGroup_uses_process_name_from_options(self):
        gconfig = DummyPGroupConfig(None, pconfigs=[])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {}
        supervisord = DummySupervisor(process_groups={"group_name": pgroup})
        supervisord.options = supervisor.options.ServerOptions()
        interface = self.makeOne(supervisord)
        poptions = {"process_name": "renamed", "command": "/usr/bin/find /"}

        self.assertTrue(
            interface.addProgramToGroup("new_process", poptions, "group_name"))
        self.assertEqual("addProgramToGroup", interface.update_text)

        config = pgroup.config.process_configs[0]
        self.assertEqual("renamed", config.name)
        self.assertTrue(pgroup.processes.get("new_process") is None)
        self.assertTrue(
            isinstance(pgroup.processes.get("renamed"),
                       supervisor.process.Subprocess))
    def test_addProgramToGroup_uses_process_name_from_options(self):
        gconfig = DummyPGroupConfig(None, pconfigs=[])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {}

        supervisord = DummySupervisor(process_groups = {'group_name': pgroup})
        supervisord.options = supervisor.options.ServerOptions()

        interface = self.makeOne(supervisord)

        poptions = {'process_name': 'renamed', 'command': '/usr/bin/find /'}
        self.assertTrue(interface.addProgramToGroup('group_name', 'new_process', poptions))
        self.assertEqual('addProgramToGroup', interface.update_text)

        config = pgroup.config.process_configs[0]
        self.assertEqual('renamed', config.name)
        self.assertTrue(pgroup.processes.get('new_process') is None)
        self.assertTrue(isinstance(pgroup.processes.get('renamed'),
          supervisor.process.Subprocess))
Beispiel #26
0
    def test_addProgramToGroup_raises_bad_name_when_group_doesnt_exist(self):
        pconfig = DummyPConfig(None, 'foo', '/bin/foo')
        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)

        supervisord = DummySupervisor(process_groups={'foo': pgroup})
        interface = self.makeOne(supervisord)

        self.assertRPCError(SupervisorFaults.BAD_NAME,
                            interface.addProgramToGroup, 'nonexistant_group',
                            'foo', {})
Beispiel #27
0
    def test_addProgramToGroup_uses_process_name_from_options(self):
        gconfig = DummyPGroupConfig(None, pconfigs=[])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {}

        supervisord = DummySupervisor(process_groups={'group_name': pgroup})
        supervisord.options = supervisor.options.ServerOptions()

        interface = self.makeOne(supervisord)

        poptions = {'process_name': 'renamed', 'command': '/usr/bin/find /'}
        self.assertTrue(
            interface.addProgramToGroup('group_name', 'new_process', poptions))
        self.assertEqual('addProgramToGroup', interface.update_text)

        config = pgroup.config.process_configs[0]
        self.assertEqual('renamed', config.name)
        self.assertTrue(pgroup.processes.get('new_process') is None)
        self.assertTrue(
            isinstance(pgroup.processes.get('renamed'),
                       supervisor.process.Subprocess))
Beispiel #28
0
    def test_addProgramToGroup_adds_all_processes_resulting_from_program_options(
            self):
        gconfig = DummyPGroupConfig(None, pconfigs=[])
        pgroup = DummyProcessGroup(gconfig)
        pgroup.processes = {}

        supervisord = DummySupervisor(process_groups={'group_name': pgroup})
        supervisord.options = supervisor.options.ServerOptions()

        interface = self.makeOne(supervisord)

        poptions = {
            'command': '/usr/bin/find /',
            'process_name': 'find_%(process_num)d',
            'numprocs': 3
        }
        self.assertTrue(
            interface.addProgramToGroup('group_name', 'new_process', poptions))
        self.assertEqual('addProgramToGroup', interface.update_text)

        self.assertEqual(3, len(pgroup.config.process_configs))
        self.assertEqual(3, len(pgroup.processes))
Beispiel #29
0
    def test_addProgramToGroup_raises_incorrect_params_when_poptions_is_not_dict(
            self):
        pconfig = DummyPConfig(None, 'foo', '/bin/foo')
        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)

        supervisord = DummySupervisor(process_groups={'group_name': pgroup})
        supervisord.options = supervisor.options.ServerOptions()
        interface = self.makeOne(supervisord)

        bad_poptions = 42
        self.assertRPCError(SupervisorFaults.INCORRECT_PARAMETERS,
                            interface.addProgramToGroup, 'group_name',
                            'new_process', bad_poptions)
    def test_removeProcessFromGroup_raises_bad_name_when_group_doesnt_exist(
            self):
        pconfig = DummyPConfig(None, "foo", "/bin/foo")
        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)
        supervisord = DummySupervisor(process_groups={"group_name": pgroup})
        interface = self.makeOne(supervisord)

        self.assertRPCError(
            SupervisorFaults.BAD_NAME,
            interface.removeProcessFromGroup,
            "nonexistant_group_name",
            "process_name",
        )
Beispiel #31
0
    def test_getGroupNames_returns_group_names(self):
        pconfig = DummyPConfig(None, 'foo', '/bin/foo')
        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)

        pgroups = {'foo': pgroup, 'bar': pgroup}
        supervisord = DummySupervisor(process_groups=pgroups)
        interface = self.makeOne(supervisord)

        names = interface.getGroupNames()
        self.assertTrue(isinstance(names, list))
        self.assertEqual(2, len(names))
        names.index('foo')
        names.index('bar')
Beispiel #32
0
    def test_addProgramToGroup_raises_bad_name_when_process_already_exists(
            self):
        pconfig = DummyPConfig(None, 'process_that_exists', '/bin/foo')
        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)

        supervisord = DummySupervisor(process_groups={'group_name': pgroup})
        supervisord.options = supervisor.options.ServerOptions()
        interface = self.makeOne(supervisord)

        poptions = {'command': '/usr/bin/find /'}
        self.assertRPCError(SupervisorFaults.BAD_NAME,
                            interface.addProgramToGroup, 'group_name',
                            'process_that_exists', poptions)
 def test_exit(self):
     options = DummyOptions()
     supervisord = self._makeOne(options)
     pconfig = DummyPConfig(options, 'foo', '/bin/foo',)
     gconfig = DummyPGroupConfig(options, pconfigs=[pconfig])
     pgroup = DummyProcessGroup(gconfig)
     L = []
     def callback():
         L.append(1)
     supervisord.process_groups = {'foo': pgroup}
     supervisord.options.mood = SupervisorStates.RESTARTING
     supervisord.options.test = True
     from supervisor.medusa import asyncore_25 as asyncore
     self.assertRaises(asyncore.ExitNow, supervisord.runforever)
     self.assertEqual(pgroup.all_stopped, True)
    def test_addProgramToGroup_raises_incorrect_params_when_poptions_is_invalid(
            self):
        pconfig = DummyPConfig(None, "foo", "/bin/foo")
        gconfig = DummyPGroupConfig(None, pconfigs=[pconfig])
        pgroup = DummyProcessGroup(gconfig)

        supervisord = DummySupervisor(process_groups={"group_name": pgroup})
        supervisord.options = supervisor.options.ServerOptions()
        interface = self.makeOne(supervisord)
        poptions_missing_command = {}

        self.assertRPCError(
            SupervisorFaults.INCORRECT_PARAMETERS,
            interface.addProgramToGroup,
            "new_process",
            poptions_missing_command,
            "group_name",
        )
 def test_handle_sigusr2(self):
     options = DummyOptions()
     options._signal = signal.SIGUSR2
     pconfig1 = DummyPConfig(options, 'process1', 'process1',
                             '/bin/process1')
     process1 = DummyProcess(pconfig1, state=ProcessStates.STOPPING)
     process1.delay = time.time() - 1
     supervisord = self._makeOne(options)
     pconfigs = [DummyPConfig(options, 'foo', 'foo', '/bin/foo')]
     options.process_group_configs = DummyPGroupConfig(options,
                                                       'foo',
                                                       pconfigs=pconfigs)
     dummypgroup = DummyProcessGroup(options)
     supervisord.process_groups = {None: dummypgroup}
     supervisord.handle_signal()
     self.assertEqual(supervisord.options.mood, SupervisorStates.RUNNING)
     self.assertEqual(options.logs_reopened, True)
     self.assertEqual(options.logger.data[0],
                      'received SIGUSR2 indicating log reopen request')
     self.assertEqual(dummypgroup.logs_reopened, True)
 def test_runforever_stopping_emits_events(self):
     options = DummyOptions()
     supervisord = self._makeOne(options)
     gconfig = DummyPGroupConfig(options)
     pgroup = DummyProcessGroup(gconfig)
     supervisord.process_groups = {'foo': pgroup}
     supervisord.options.mood = SupervisorStates.SHUTDOWN
     L = []
     def callback(event):
         L.append(event)
     from supervisor import events
     events.subscribe(events.SupervisorStateChangeEvent, callback)
     from supervisor.medusa import asyncore_25 as asyncore
     options.test = True
     self.assertRaises(asyncore.ExitNow, supervisord.runforever)
     self.assertTrue(pgroup.all_stopped)
     self.assertTrue(isinstance(L[0], events.SupervisorRunningEvent))
     self.assertTrue(isinstance(L[0], events.SupervisorStateChangeEvent))
     self.assertTrue(isinstance(L[1], events.SupervisorStoppingEvent))
     self.assertTrue(isinstance(L[1], events.SupervisorStateChangeEvent))