Beispiel #1
0
 def test_recording_messages_after_starting(self):
     self.send_message(PAUSE)
     self.trigger_flush()
     sleep(0.5)
     self.assert_flush(0)
     self.send_message(START)
     self.trigger_flush()
     assert_poll(lambda: self.count_traces() == self.flush_interval,
                 'Logger did not flush after setting it back to active')
Beispiel #2
0
    def test_flush_calls_writer(self):
        written = list()

        class DummyWriter(TraceWriter):
            def write(self, buffer):
                written.extend(buffer)

        self.logger.writer = DummyWriter()

        self.trigger_flush()

        assert_poll(lambda: len(written) == self.flush_interval)
Beispiel #3
0
    def test_discarding_messages_in_paused_state(self, flush):
        self.send_message(PAUSE)
        assert_poll(lambda: not self.logger.running,
                    'Logger running after PAUSE')

        self.queue.put(traces[0])
        self.queue.put(traces[1])

        sleep(0.5)
        self.assertEqual(0, len(self.logger.buffer),
                         'buffer should not be filled when logger is paused')

        self.send_message(START)
        assert_poll(lambda: self.logger.running,
                    'Logger not running after START')

        self.queue.put(traces[2])
        assert_poll(lambda: len(self.logger.buffer) == 1,
                    'buffer should contain one message after started')
Beispiel #4
0
 def test_flush_after_pause(self):
     self.send_message(ServiceRequestTrace('client', 'service', 'host', 1, 1, 1))
     self.send_message(PAUSE)
     assert_poll(lambda: self.count_traces() == 1, 'Logger did not flush after PAUSE')
Beispiel #5
0
 def test_flush_after_flush_msg(self):
     self.send_message(ServiceRequestTrace('client', 'service', 'host', 1, 1, 1))
     self.send_message(FLUSH)
     assert_poll(lambda: self.count_traces() == 1, 'Not flushed after FLUSH')
Beispiel #6
0
 def test_flush(self):
     self.trigger_flush()
     assert_poll(lambda: self.count_traces() == self.flush_interval, 'Logger did not write out traces')
Beispiel #7
0
 def test_not_running_after_pause(self):
     self.send_message(PAUSE)
     assert_poll(lambda: not self.logger.running, 'Logger running after PAUSE')
Beispiel #8
0
 def test_running_after_start(self):
     self.send_message(START)
     assert_poll(lambda: self.logger.running, 'Logger not running after START')
Beispiel #9
0
 def test_flushed_after_poison(self, flush):
     self.send_message(POISON)
     assert_poll(lambda: flush.called_once(), 'Flush was not called after POISON')
Beispiel #10
0
 def test_closed_after_poison(self):
     self.send_message(POISON)
     assert_poll(lambda: self.logger.closed, 'POISON didnt close logger')
Beispiel #11
0
 def test_flush_called_after_flush_msg(self, flush):
     self.send_message(FLUSH)
     assert_poll(lambda: flush.called_once(), 'Flush was not called after triggering FLUSH')
Beispiel #12
0
 def test_flush_called(self, flush):
     self.trigger_flush()
     assert_poll(lambda: flush.called_once(), 'Flush was not called after triggering flush')