Пример #1
0
    def test_write_and_reconnect(self):
        with scribed_sandbox(self.scribe_port, self.scribe_logdir):
            logger = self.create_logger()
            logger.log_line('foo', '1')
            logger.log_line('foo', '2')
            logger.log_line('foo', u'☃')
            wait_on_log_data(
                get_log_path(self.scribe_logdir, 'foo'),
                u'1\n2\n☃\n'.encode('UTF-8'),
            )

        # make sure we haven't logged any errors
        assert not any(is_error for (is_error, msg) in self.status_reports)

        # write some more data, make sure we ignore that scribe server is
        # down, don't block too long
        self.timed_writes(logger, 10000, 2.0)

        # make sure we didn't log too many error reports
        assert len(self.status_reports) < 10
        # make sure we did log at least one error
        assert any(is_error for (is_error, msg) in self.status_reports)

        with scribed_sandbox(self.scribe_port, self.scribe_logdir):
            logger.log_line('foo', '3')
            logger.log_line('foo', '4')
            wait_on_log_data(
                get_log_path(self.scribe_logdir, 'foo'),
                u'1\n2\n☃\n3\n4\n'.encode('UTF-8'),
            )
Пример #2
0
    def setup_sandbox(self):
        self.scribe_logdir = tempfile.mkdtemp()
        self.stream = "foo"
        self.scribe_port = find_open_port()
        self.log_path = get_log_path(self.scribe_logdir, self.stream)

        self.logger = ScribeLogger("localhost", self.scribe_port, retry_interval=10, report_status=mock.Mock())

        with scribed_sandbox(self.scribe_port, self.scribe_logdir):
            yield
        shutil.rmtree(self.scribe_logdir)
Пример #3
0
    def test_init_while_down(self):
        logger = self.create_logger()
        self.timed_writes(logger, 10000, 2.0)

        # make sure we didn't log too many error reports
        assert len(self.status_reports) < 10
        # make sure we did log at least one error
        assert any(is_error for (is_error, msg) in self.status_reports)

        with scribed_sandbox(self.scribe_port, self.scribe_logdir):
            logger.log_line('bar', 'A')
            logger.log_line('bar', 'B')
            wait_on_log_data(get_log_path(self.scribe_logdir, 'bar'), b'A\nB\n')
Пример #4
0
    def test_init_while_down(self):
        logger = self.create_logger()
        self.timed_writes(logger, 10000, 2.0)

        # make sure we didn't log too many error reports
        assert len(self.status_reports) < 10
        # make sure we did log at least one error
        assert any(is_error for (is_error, msg) in self.status_reports)

        with scribed_sandbox(self.scribe_port, self.scribe_logdir):
            logger.log_line('bar', 'A')
            logger.log_line('bar', 'B')
            wait_on_log_data(get_log_path(self.scribe_logdir, 'bar'), b'A\nB\n')
Пример #5
0
    def test_write_and_reconnect(self):
        with scribed_sandbox(self.scribe_port, self.scribe_logdir):
            logger = self.create_logger()
            logger.log_line('foo', '1')
            logger.log_line('foo', '2')
            wait_on_log_data(get_log_path(self.scribe_logdir, 'foo'), b'1\n2\n')

        # make sure we haven't logged any errors
        assert not any(is_error for (is_error, msg) in self.status_reports)

        # write some more data, make sure we ignore that scribe server is
        # down, don't block too long
        self.timed_writes(logger, 10000, 2.0)

        # make sure we didn't log too many error reports
        assert_lt(len(self.status_reports), 10)
        # make sure we did log at least one error
        assert any(is_error for (is_error, msg) in self.status_reports)

        with scribed_sandbox(self.scribe_port, self.scribe_logdir):
            logger.log_line('foo', '3')
            logger.log_line('foo', '4')
            wait_on_log_data(get_log_path(self.scribe_logdir, 'foo'), b'1\n2\n3\n4\n')
Пример #6
0
    def setup_sandbox(self):
        self.scribe_logdir = tempfile.mkdtemp()
        self.stream = 'foo'
        self.scribe_port = find_open_port()
        self.log_path = get_log_path(self.scribe_logdir, self.stream)

        self.logger = ScribeLogger('localhost',
                                   self.scribe_port,
                                   retry_interval=10,
                                   report_status=mock.Mock())

        with scribed_sandbox(self.scribe_port, self.scribe_logdir):
            yield
        shutil.rmtree(self.scribe_logdir)