Пример #1
0
 def test_invalidate_address(self):
     """ Test the invalidation of addresses. """
     from supervisor.states import ProcessStates
     from supvisors.process import ProcessStatus
     # create conflict directly with 3 process info
     info = any_process_info_by_state(ProcessStates.BACKOFF)
     process = ProcessStatus(info['group'], info['name'], self.supvisors)
     process.add_info('10.0.0.1', info)
     process.add_info('10.0.0.2',
                      any_process_info_by_state(ProcessStates.RUNNING))
     process.add_info('10.0.0.3',
                      any_process_info_by_state(ProcessStates.STARTING))
     # check the conflict
     self.assertTrue(process.conflicting())
     self.assertEqual(ProcessStates.RUNNING, process.state)
     # invalidate RUNNING one
     process.invalidate_address('10.0.0.2', False)
     # check state became UNKNOWN on invalidated address
     self.assertEqual(ProcessStates.UNKNOWN,
                      process.infos['10.0.0.2']['state'])
     # check the conflict
     self.assertTrue(process.conflicting())
     # check new synthetic state
     self.assertEqual(ProcessStates.BACKOFF, process.state)
     # invalidate BACKOFF one
     process.invalidate_address('10.0.0.1', False)
     # check state became UNKNOWN on invalidated address
     self.assertEqual(ProcessStates.UNKNOWN,
                      process.infos['10.0.0.1']['state'])
     # check 1 address: no conflict
     self.assertFalse(process.conflicting())
     # check synthetic state (running process)
     self.assertEqual(ProcessStates.STARTING, process.state)
     # invalidate STARTING one
     process.invalidate_address('10.0.0.3', True)
     # check state became UNKNOWN on invalidated address
     self.assertEqual(ProcessStates.UNKNOWN,
                      process.infos['10.0.0.3']['state'])
     # check 0 address: no conflict
     self.assertFalse(process.conflicting())
     # check that synthetic state became FATAL
     self.assertEqual(ProcessStates.FATAL, process.state)
     # check that failure_handler is notified
     self.assertEqual(
         [call(process)],
         self.supvisors.failure_handler.add_default_job.call_args_list)
     # add one STOPPING
     process.add_info('10.0.0.4',
                      any_process_info_by_state(ProcessStates.STOPPING))
     # check state STOPPING
     self.assertEqual(ProcessStates.STOPPING, process.state)
     # invalidate STOPPING one
     process.invalidate_address('10.0.0.4', False)
     # check state became UNKNOWN on invalidated address
     self.assertEqual(ProcessStates.UNKNOWN,
                      process.infos['10.0.0.4']['state'])
     # check that synthetic state became STOPPED
     self.assertEqual(ProcessStates.STOPPED, process.state)
Пример #2
0
 def test_invalidate_address(self):
     """ Test the invalidation of addresses. """
     from supervisor.states import ProcessStates
     from supvisors.process import ProcessStatus
     # create conflict directly with 3 process info
     info = any_process_info_by_state(ProcessStates.BACKOFF)
     process = ProcessStatus(info['group'], info['name'], self.supvisors)
     process.add_info('10.0.0.1', info)
     process.add_info('10.0.0.2', any_process_info_by_state(ProcessStates.RUNNING))
     process.add_info('10.0.0.3', any_process_info_by_state(ProcessStates.STARTING))
     # check the conflict
     self.assertTrue(process.conflicting())
     self.assertEqual(ProcessStates.RUNNING, process.state)
     # invalidate RUNNING one
     process.invalidate_address('10.0.0.2', False)
     # check state became UNKNOWN on invalidated address
     self.assertEqual(ProcessStates.UNKNOWN, process.infos['10.0.0.2']['state'])
     # check the conflict
     self.assertTrue(process.conflicting())
     # check new synthetic state
     self.assertEqual(ProcessStates.BACKOFF, process.state)
     # invalidate BACKOFF one
     process.invalidate_address('10.0.0.1', False)
     # check state became UNKNOWN on invalidated address
     self.assertEqual(ProcessStates.UNKNOWN, process.infos['10.0.0.1']['state'])
     # check 1 address: no conflict
     self.assertFalse(process.conflicting())
     # check synthetic state (running process)
     self.assertEqual(ProcessStates.STARTING, process.state)
     # invalidate STARTING one
     process.invalidate_address('10.0.0.3', True)
     # check state became UNKNOWN on invalidated address
     self.assertEqual(ProcessStates.UNKNOWN, process.infos['10.0.0.3']['state'])
     # check 0 address: no conflict
     self.assertFalse(process.conflicting())
     # check that synthetic state became FATAL
     self.assertEqual(ProcessStates.FATAL, process.state)
     # check that failure_handler is notified
     self.assertEqual([call(process)], self.supvisors.failure_handler.add_default_job.call_args_list)
     # add one STOPPING
     process.add_info('10.0.0.4', any_process_info_by_state(ProcessStates.STOPPING))
     # check state STOPPING
     self.assertEqual(ProcessStates.STOPPING, process.state)
     # invalidate STOPPING one
     process.invalidate_address('10.0.0.4', False)
     # check state became UNKNOWN on invalidated address
     self.assertEqual(ProcessStates.UNKNOWN, process.infos['10.0.0.4']['state'])
     # check that synthetic state became STOPPED
     self.assertEqual(ProcessStates.STOPPED, process.state)
Пример #3
0
 def test_invalidate_address(self):
     """ Test the invalidation of addresses. """
     from supervisor.states import ProcessStates
     from supvisors.process import ProcessStatus
     # create conflict directly with 3 process info
     info = any_process_info_by_state(ProcessStates.BACKOFF)
     process = ProcessStatus(info['group'], info['name'], self.supvisors)
     process.add_info('10.0.0.1', info)
     process.add_info('10.0.0.2', any_process_info_by_state(ProcessStates.RUNNING))
     process.add_info('10.0.0.3', any_process_info_by_state(ProcessStates.STARTING))
     # check the conflict
     self.assertTrue(process.conflicting())
     self.assertEqual(ProcessStates.RUNNING, process.state)
     # invalidate RUNNING one
     process.invalidate_address('10.0.0.2')
     # check UNKNOWN
     self.assertEqual(ProcessStates.UNKNOWN, process.infos['10.0.0.2']['state'])
     # check the conflict
     self.assertTrue(process.conflicting())
     # check new synthetic state
     self.assertEqual(ProcessStates.BACKOFF, process.state)
     # invalidate BACKOFF one
     process.invalidate_address('10.0.0.1')
     # check UNKNOWN
     self.assertEqual(ProcessStates.UNKNOWN, process.infos['10.0.0.1']['state'])
     # check 1 address: no conflict
     self.assertFalse(process.conflicting())
     # check state (running process)
     self.assertEqual(ProcessStates.STARTING, process.state)
     # invalidate STARTING one
     process.invalidate_address('10.0.0.3')
     # check UNKNOWN
     self.assertEqual(ProcessStates.UNKNOWN, process.infos['10.0.0.3']['state'])
     # check 0 address: no conflict
     self.assertFalse(process.conflicting())
     # check state FATAL
     self.assertEqual(ProcessStates.FATAL, process.state)
     # check mark_for_restart
     self.assertFalse(process.mark_for_restart)
     # add one STOPPING
     process.add_info('10.0.0.4', any_process_info_by_state(ProcessStates.STOPPING))
     # check state STOPPING
     self.assertEqual(ProcessStates.STOPPING, process.state)
     # invalidate STOPPING one
     process.invalidate_address('10.0.0.4')
     # check UNKNOWN
     self.assertEqual(ProcessStates.UNKNOWN, process.infos['10.0.0.4']['state'])
     # check state STOPPED
     self.assertEqual(ProcessStates.STOPPED, process.state)
Пример #4
0
 def test_conflicting(self):
     """ Test the process conflicting rules. """
     from supervisor.states import ProcessStates
     from supvisors.process import ProcessStatus
     # when there is only one STOPPED process info, there is no conflict
     info = any_process_info_by_state(ProcessStates.STOPPED)
     process = ProcessStatus(info['group'], info['name'], self.supvisors)
     process.add_info('10.0.0.1', info)
     self.assertFalse(process.conflicting())
     # the addition of a running address, still no conflict
     process.addresses.add('10.0.0.2')
     self.assertFalse(process.conflicting())
     # the addition of a new running address raises a conflict
     process.addresses.add('10.0.0.4')
     self.assertTrue(process.conflicting())
     # remove the first running address to solve the conflict
     process.addresses.remove('10.0.0.2')
     self.assertFalse(process.conflicting())
Пример #5
0
 def test_conflicting(self):
     """ Test the process conflicting rules. """
     from supervisor.states import ProcessStates
     from supvisors.process import ProcessStatus
     # when there is only one STOPPED process info, there is no conflict
     info = any_process_info_by_state(ProcessStates.STOPPED)
     process = ProcessStatus(info['group'], info['name'], self.supvisors)
     process.add_info('10.0.0.1', info)
     self.assertFalse(process.conflicting())
     # the addition of a running address, still no conflict
     process.addresses.add('10.0.0.2')
     self.assertFalse(process.conflicting())
     # the addition of a new running address raises a conflict
     process.addresses.add('10.0.0.4')
     self.assertTrue(process.conflicting())
     # remove the first running address to solve the conflict
     process.addresses.remove('10.0.0.2')
     self.assertFalse(process.conflicting())