Ejemplo n.º 1
0
 def test_deregister(self):
     """Verify that register and deregister don't blow up"""
     with contextlib.closing(impl_memory.MemoryBackend()) as be:
         flow = lf.Flow("test")
         flow.add(SleepyTask("test-1", sleep_for=0.1))
         (lb, fd) = persistence_utils.temporary_flow_detail(be)
         e = self._make_engine(flow, fd, be)
         l = timing.DurationListener(e)
         l.register()
         l.deregister()
Ejemplo n.º 2
0
 def test_flow_duration(self):
     with contextlib.closing(impl_memory.MemoryBackend()) as be:
         flow = lf.Flow("test")
         flow.add(SleepyTask("test-1", sleep_for=0.1))
         (lb, fd) = persistence_utils.temporary_flow_detail(be)
         e = self._make_engine(flow, fd, be)
         with timing.DurationListener(e):
             e.run()
         self.assertIsNotNone(fd)
         self.assertIsNotNone(fd.meta)
         self.assertIn('duration', fd.meta)
         self.assertGreaterEqual(0.1, fd.meta['duration'])
Ejemplo n.º 3
0
 def test_record_ending_exception(self, mocked_warn):
     with contextlib.closing(impl_memory.MemoryBackend()) as be:
         flow = lf.Flow("test")
         flow.add(test_utils.TaskNoRequiresNoReturns("test-1"))
         (lb, fd) = persistence_utils.temporary_flow_detail(be)
         e = self._make_engine(flow, fd, be)
         duration_listener = timing.DurationListener(e)
         with mock.patch.object(duration_listener._engine.storage,
                                'update_atom_metadata') as mocked_uam:
             mocked_uam.side_effect = exc.StorageFailure('Woot!')
             with duration_listener:
                 e.run()
     mocked_warn.assert_called_once_with(mock.ANY,
                                         mock.ANY,
                                         'test-1',
                                         exc_info=True)