|
@@ -683,8 +683,10 @@ class SubprocessTests(unittest.TestCase):
|
|
instance.dispatchers = {'foo':dispatcher}
|
|
instance.dispatchers = {'foo':dispatcher}
|
|
from supervisor.states import ProcessStates
|
|
from supervisor.states import ProcessStates
|
|
instance.state = ProcessStates.RUNNING
|
|
instance.state = ProcessStates.RUNNING
|
|
|
|
+ instance.laststopreport = time.time()
|
|
instance.stop()
|
|
instance.stop()
|
|
self.assertEqual(instance.administrative_stop, 1)
|
|
self.assertEqual(instance.administrative_stop, 1)
|
|
|
|
+ self.assertEqual(instance.laststopreport, 0)
|
|
self.assertTrue(instance.delay)
|
|
self.assertTrue(instance.delay)
|
|
self.assertEqual(options.logger.data[0], 'killing test (pid 11) with '
|
|
self.assertEqual(options.logger.data[0], 'killing test (pid 11) with '
|
|
'signal SIGTERM')
|
|
'signal SIGTERM')
|
|
@@ -707,6 +709,35 @@ class SubprocessTests(unittest.TestCase):
|
|
self.assertEqual(exc.args[0], 'Assertion failed for test: '
|
|
self.assertEqual(exc.args[0], 'Assertion failed for test: '
|
|
'STOPPED not in RUNNING STARTING STOPPING')
|
|
'STOPPED not in RUNNING STARTING STOPPING')
|
|
|
|
|
|
|
|
+ def test_stop_report_logs_nothing_if_not_stopping_state(self):
|
|
|
|
+ options = DummyOptions()
|
|
|
|
+ config = DummyPConfig(options, 'test', '/test')
|
|
|
|
+ instance = self._makeOne(config)
|
|
|
|
+ instance.pid = 11
|
|
|
|
+ dispatcher = DummyDispatcher(writable=True)
|
|
|
|
+ instance.dispatchers = {'foo':dispatcher}
|
|
|
|
+ from supervisor.states import ProcessStates
|
|
|
|
+ instance.state = ProcessStates.STOPPED
|
|
|
|
+ instance.stop_report()
|
|
|
|
+ self.assertEqual(len(options.logger.data), 0)
|
|
|
|
+
|
|
|
|
+ def test_stop_report_logs_throttled_by_laststopreport(self):
|
|
|
|
+ options = DummyOptions()
|
|
|
|
+ config = DummyPConfig(options, 'test', '/test')
|
|
|
|
+ instance = self._makeOne(config)
|
|
|
|
+ instance.pid = 11
|
|
|
|
+ dispatcher = DummyDispatcher(writable=True)
|
|
|
|
+ instance.dispatchers = {'foo':dispatcher}
|
|
|
|
+ from supervisor.states import ProcessStates
|
|
|
|
+ instance.state = ProcessStates.STOPPING
|
|
|
|
+ self.assertEqual(instance.laststopreport, 0)
|
|
|
|
+ instance.stop_report()
|
|
|
|
+ self.assertEqual(len(options.logger.data), 1)
|
|
|
|
+ self.assertEqual(options.logger.data[0], 'waiting for test to stop')
|
|
|
|
+ self.assertNotEqual(instance.laststopreport, 0)
|
|
|
|
+ instance.stop_report()
|
|
|
|
+ self.assertEqual(len(options.logger.data), 1) # throttled
|
|
|
|
+
|
|
def test_give_up(self):
|
|
def test_give_up(self):
|
|
options = DummyOptions()
|
|
options = DummyOptions()
|
|
config = DummyPConfig(options, 'test', '/test')
|
|
config = DummyPConfig(options, 'test', '/test')
|