예제 #1
0
def ErrorRecord(**kwargs):
    """Returns an ErrorRecord filled with default dummy values."""
    vals = {
        'request_id': 'a',
        'start_time': None,
        'exception_time': None,
        'latency': 0,
        'mcycles': 0,
        'ip': '0.0.1.0',
        'nickname': None,
        'referrer': None,
        'user_agent': 'Comodore64',
        'host': 'localhost',
        'resource': '/foo',
        'method': 'GET',
        'task_queue_name': None,
        'was_loading_request': False,
        'version': 'v1',
        'module': 'default',
        'handler_module': 'main.app',
        'gae_version': '1.9.0',
        'instance': '123',
        'status': 200,
        'message': u'Failed',
    }
    vals.update(kwargs)
    signature, exception_type = logscraper._signature_from_message(
        vals['message'])
    return logscraper._ErrorRecord(signature=signature,
                                   exception_type=exception_type,
                                   **vals)
예제 #2
0
def ErrorRecord(**kwargs):
  """Returns an ErrorRecord filled with default dummy values."""
  vals = {
      'request_id': '123',
      'start_time': None,
      'exception_time': None,
      'latency': 0,
      'mcycles': 0,
      'ip': '0.0.1.0',
      'nickname': None,
      'referrer': None,
      'user_agent': 'Comodore64',
      'host': 'localhost',
      'resource': '/foo',
      'method': 'GET',
      'task_queue_name': None,
      'was_loading_request': False,
      'version': 'v1',
      'module': 'default',
      'handler_module': 'main.app',
      'gae_version': '1.9.0',
      'instance': '123',
      'status': 200,
      'message': (
          u'Traceback (most recent call last):\n'
          '  File "handlers_frontend.py", line 461, in post\n'
          '    for entry_info, exists in self.check_entry_infos('
              'entries, namespace):\n'
          '  File "handlers_frontend.py", line 343, in check_entry_infos\n'
          '    future = ndb.Future.wait_any(futures)\n'
          '  File "appengine/ext/ndb/tasklets.py", line 338, in wait_any\n'
          '    ev.run1()\n'
          '  File "appengine/ext/ndb/eventloop.py", line 235, in run1\n'
          '    delay = self.run0()\n'
          '  File "appengine/ext/ndb/eventloop.py", line 197, in run0\n'
          '    callback(*args, **kwds)\n'
          '  File "appengine/ext/ndb/tasklets.py", line 474, in '
              '_on_future_completion\n'
          '    self._help_tasklet_along(ns, ds_conn, gen, val)\n'
          '  File "appengine/ext/ndb/tasklets.py", line 371, in '
              '_help_tasklet_along\n'
          '    value = gen.send(val)\n'
          '  File "appengine/ext/ndb/context.py", line 751, in get\n'
          '    pbs = entity._to_pb(set_key=False).SerializePartialToString()\n'
          '  File "appengine/ext/ndb/model.py", line 3069, in _to_pb\n'
          '    prop._serialize(self, pb, projection=self._projection)\n'
          '  File "appengine/ext/ndb/model.py", line 1374, in _serialize\n'
          '    self._db_set_value(v, p, val)\n'
          '  File "appengine/ext/ndb/model.py", line 2042, in _db_set_value\n'
          '    p.set_meaning(entity_pb.Property.GD_WHEN)\n'
          'DeadlineExceededError\n')
  }
  vals.update(kwargs)
  signature, exception_type = logscraper._signature_from_message(
      vals['message'])
  return logscraper._ErrorRecord(
      signature=signature, exception_type=exception_type, **vals)
예제 #3
0
    def test_signatures(self):
        messages = [
            (
                (u'\nTraceback (most recent call last):\n'
                 '  File \"appengine/runtime/wsgi.py\", line 239, in Handle\n'
                 '    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())'
                 '\n'
                 '  File \"appengine/ext/ndb/utils.py\", line 28, in wrapping\n'
                 '    def wrapping_wrapper(wrapper):\n'
                 'DeadlineExceededError'),
                '[email protected]:28',
                'DeadlineExceededError',
            ),
            (
                (u'\nTraceback (most recent call last):\n'
                 '  File \"handlers.py\", line 19, in get\n'
                 '    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())'
                 '\n'
                 '  File \"appengine/runtime/wsgi.py\", line 239, in Handle\n'
                 '    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())'
                 '\n'
                 '  File \"appengine/ext/ndb/utils.py\", line 28, in wrapping\n'
                 '    def wrapping_wrapper(wrapper):\n'
                 'DeadlineExceededError'),
                'DeadlineExceededError@get',
                'DeadlineExceededError',
            ),
            (
                (u'\'error\' is undefined\n'
                 'Traceback (most recent call last):\n'
                 '  File \"third_party/webapp2-2.5/webapp2.py\", line 1535, in __call__'
                 '\n'
                 '    rv = self.handle_exception(request, response, e)\n'
                 '  File \"third_party/jinja2-2.6/jinja2/environment.py\", line 894, in '
                 'render\n'
                 '    return self.environment.handle_exception(exc_info, True)\n'
                 '  File \"<template>\", line 6, in top-level template code\n'
                 '  File \"third_party/jinja2-2.6/jinja2/environment.py\", line 372, in '
                 'getattr\n'
                 '    return getattr(obj, attribute)\n'
                 'UndefinedError: \'error\' is undefined'),
                'UndefinedError@top-level template code',
                'UndefinedError',
            ),
            (
                (u'\nTraceback (most recent call last):\n'
                 '  File \"api.py\", line 74\n'
                 '    class ErrorReportingInfo(ndb.Model):\n'
                 '        ^\n'
                 'SyntaxError: invalid syntax'),
                '[email protected]:74',
                'SyntaxError',
            ),
            (
                u'Ovérwhelmingly long message' * 100,
                u'hash:35961a207a9d344444128405dbdbc00f294263be',
                None,
            ),
            (
                (u'Ovérwhelmingly long message' * 100 + '\n' +
                 'Traceback (most recent call last):\n'
                 '  File \"appengine/runtime/wsgi.py\", line 239, in Handle\n'
                 '    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())'
                 '\n'
                 '  File \"appengine/ext/ndb/utils.py\", line 28, in wrapping\n'
                 '    def wrapping_wrapper(wrapper):\n'
                 'DeadlineExceededError'),
                u'[email protected]:28',
                u'DeadlineExceededError',
            ),
        ]

        for (message, expected_signature, excepted_exception) in messages:
            signature, exception_type = logscraper._signature_from_message(
                message)
            self.assertEqual(expected_signature, signature)
            self.assertEqual(excepted_exception, exception_type)
예제 #4
0
  def test_signatures(self):
    messages = [
      (
        (u'\nTraceback (most recent call last):\n'
        '  File \"appengine/runtime/wsgi.py\", line 239, in Handle\n'
        '    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())'
            '\n'
        '  File \"appengine/ext/ndb/utils.py\", line 28, in wrapping\n'
        '    def wrapping_wrapper(wrapper):\n'
        'DeadlineExceededError'),
        '[email protected]:28',
        'DeadlineExceededError',
      ),
      (
        (u'\nTraceback (most recent call last):\n'
        '  File \"handlers.py\", line 19, in get\n'
        '    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())'
            '\n'
        '  File \"appengine/runtime/wsgi.py\", line 239, in Handle\n'
        '    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())'
            '\n'
        '  File \"appengine/ext/ndb/utils.py\", line 28, in wrapping\n'
        '    def wrapping_wrapper(wrapper):\n'
        'DeadlineExceededError'),
        'DeadlineExceededError@get',
        'DeadlineExceededError',
      ),
      (
        (u'\'error\' is undefined\n'
        'Traceback (most recent call last):\n'
        '  File \"third_party/webapp2-2.5/webapp2.py\", line 1535, in __call__'
            '\n'
        '    rv = self.handle_exception(request, response, e)\n'
        '  File \"third_party/jinja2-2.6/jinja2/environment.py\", line 894, in '
            'render\n'
        '    return self.environment.handle_exception(exc_info, True)\n'
        '  File \"<template>\", line 6, in top-level template code\n'
        '  File \"third_party/jinja2-2.6/jinja2/environment.py\", line 372, in '
            'getattr\n'
        '    return getattr(obj, attribute)\n'
        'UndefinedError: \'error\' is undefined'),
        'UndefinedError@top-level template code',
        'UndefinedError',
      ),
      (
        (u'\nTraceback (most recent call last):\n'
        '  File \"api.py\", line 74\n'
        '    class ErrorReportingInfo(ndb.Model):\n'
        '        ^\n'
        'SyntaxError: invalid syntax'),
        '[email protected]:74',
        'SyntaxError',
      ),
      (
        u'Ovérwhelmingly long message' * 100,
        u'hash:35961a207a9d344444128405dbdbc00f294263be',
        None,
      ),
      (
        (u'Ovérwhelmingly long message' * 100 + '\n' +
        'Traceback (most recent call last):\n'
        '  File \"appengine/runtime/wsgi.py\", line 239, in Handle\n'
        '    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())'
            '\n'
        '  File \"appengine/ext/ndb/utils.py\", line 28, in wrapping\n'
        '    def wrapping_wrapper(wrapper):\n'
        'DeadlineExceededError'),
        u'[email protected]:28',
        u'DeadlineExceededError',
      ),
    ]

    for (message, expected_signature, excepted_exception) in messages:
      signature, exception_type = logscraper._signature_from_message(message)
      self.assertEqual(expected_signature, signature)
      self.assertEqual(excepted_exception, exception_type)