Example #1
0
 def test_memory(self):
     channel = self._channel()
     self.assertDictEqual({}, dict(channel.tracker))
     fo = StringIO(self.read_fixture('sources', 'nginx-access.log'))
     list(slurp.consume([fo], [channel]))
     self.assertDictEqual({
         '<memory>'.format(self.fixture()): 1449,
     }, dict(channel.tracker))
Example #2
0
 def test_memory(self):
     channel = self._channel()
     self.assertDictEqual({}, dict(channel.tracker))
     fo = StringIO(self.read_fixture('sources', 'nginx-access.log'))
     list(slurp.consume([fo], [channel]))
     self.assertDictEqual({
         '<memory>'.format(self.fixture()): 1449,
     }, dict(channel.tracker))
Example #3
0
 def test_stream(self):
     channel = self._channel()
     self.assertDictEqual({}, dict(channel.tracker))
     with self.open_fixture('sources', 'nginx-access.log') as fo:
         list(slurp.consume([fo], [channel]))
     self.assertDictEqual({
         '{0}/sources/nginx-access.log'.format(self.fixture()): 1449,
     }, dict(channel.tracker))
Example #4
0
 def test_stream(self):
     channel = self._channel()
     self.assertDictEqual({}, dict(channel.tracker))
     with self.open_fixture('sources', 'nginx-access.log') as fo:
         list(slurp.consume([fo], [channel]))
     self.assertDictEqual(
         {
             '{0}/sources/nginx-access.log'.format(self.fixture()): 1449,
         }, dict(channel.tracker))
Example #5
0
 def test_pattern_errors(self):
     channel = self._channel(strict=False)
     del channel.sources[:]
     channel.add_source('ts', ['*/nginx-*'], r'98\.210\.157\.178\s+-\s+z')
     results = list(
         slurp.consume([self.fixture('sources', 'nginx-access.log')], [channel])
     )
     matches = [
         ('ts', '{0}/sources/nginx-access.log'.format(self.fixture()))
     ]
     self.assertItemsEqual([
         ('tc', matches, 2, 536, 0),
     ], results)
     self.assertDictEqual({
         '{0}/sources/nginx-access.log'.format(self.fixture()): 1449,
     }, dict(channel.tracker))
Example #6
0
 def test_pattern_errors(self):
     channel = self._channel(strict=False)
     del channel.sources[:]
     channel.add_source('ts', ['*/nginx-*'], r'98\.210\.157\.178\s+-\s+z')
     results = list(
         slurp.consume([self.fixture('sources', 'nginx-access.log')],
                       [channel]))
     matches = [('ts',
                 '{0}/sources/nginx-access.log'.format(self.fixture()))]
     self.assertItemsEqual([
         ('tc', matches, 2, 536, 0),
     ], results)
     self.assertDictEqual(
         {
             '{0}/sources/nginx-access.log'.format(self.fixture()): 1449,
         }, dict(channel.tracker))
Example #7
0
 def test_count(self):
     channel = self._channel()
     self.assertDictEqual({}, dict(channel.tracker))
     results = list(slurp.consume(
         [self.fixture('sources', 'nginx-access.log'),
          self.fixture('sources', 'error.log'),
          self.fixture('sources', 'nginx-error.log'),
          ],
         [channel],
     ))
     matches = [
         ('ts', '{0}/sources/nginx-access.log'.format(self.fixture())),
         ('ts', '{0}/sources/nginx-error.log'.format(self.fixture()))
     ]
     self.assertItemsEqual([('tc', matches, 9, 2589, 0)], results)
     self.assertDictEqual({
         '{0}/sources/nginx-access.log'.format(self.fixture()): 1449,
         '{0}/sources/nginx-error.log'.format(self.fixture()): 1140,
     }, dict(channel.tracker))
Example #8
0
    def test_sink_errors(self):
        class _Sink(slurp.Sink):
            def __call__(self, form, block):
                poop

        channel = self._channel(sink=_Sink('tk'), strict=False)
        results = list(
            slurp.consume([self.fixture('sources', 'nginx-access.log')],
                          [channel]))
        matches = [
            ('ts', '{0}/sources/nginx-access.log'.format(self.fixture())),
        ]
        self.assertItemsEqual([
            ('tc', matches, 0, 0, 6),
        ], results)
        self.assertDictEqual(
            {
                '{0}/sources/nginx-access.log'.format(self.fixture()): 1449,
            }, dict(channel.tracker))
Example #9
0
    def test_sink_errors(self):

        class _Sink(slurp.Sink):

            def __call__(self, form, block):
                poop

        channel = self._channel(sink=_Sink('tk'), strict=False)
        results = list(
            slurp.consume([self.fixture('sources', 'nginx-access.log')], [channel])
        )
        matches = [
            ('ts', '{0}/sources/nginx-access.log'.format(self.fixture())),
        ]
        self.assertItemsEqual([
            ('tc', matches, 0, 0, 6),
        ], results)
        self.assertDictEqual({
            '{0}/sources/nginx-access.log'.format(self.fixture()): 1449,
        }, dict(channel.tracker))
Example #10
0
 def test_count(self):
     channel = self._channel()
     self.assertDictEqual({}, dict(channel.tracker))
     results = list(
         slurp.consume(
             [
                 self.fixture('sources', 'nginx-access.log'),
                 self.fixture('sources', 'error.log'),
                 self.fixture('sources', 'nginx-error.log'),
             ],
             [channel],
         ))
     matches = [
         ('ts', '{0}/sources/nginx-access.log'.format(self.fixture())),
         ('ts', '{0}/sources/nginx-error.log'.format(self.fixture()))
     ]
     self.assertItemsEqual([('tc', matches, 9, 2589, 0)], results)
     self.assertDictEqual(
         {
             '{0}/sources/nginx-access.log'.format(self.fixture()): 1449,
             '{0}/sources/nginx-error.log'.format(self.fixture()): 1140,
         }, dict(channel.tracker))