Exemplo n.º 1
0
 def setUp(self):
   super(EventMonUploaderTest, self).setUp()
   tmp_handle, self.event_mon_file = tempfile.mkstemp()
   os.close(tmp_handle)
   event_mon.close()
   event_mon.setup_monitoring(
       run_type='file', hostname='test_host', output_file=self.event_mon_file)
Exemplo n.º 2
0
    def test_logging_on_appengine(self, environ):
        environ.get.return_value = 'Google App Engine/1.2.3'
        event_mon.setup_monitoring()
        self.assertIsInstance(config._router, router._LoggingStreamRouter)

        environ.get.return_value = 'Development/1.2'
        event_mon.setup_monitoring()
        self.assertIsInstance(config._router, router._LoggingStreamRouter)
Exemplo n.º 3
0
  def test_logging_on_appengine(self, environ):
    environ.get.return_value = 'Google App Engine/1.2.3'
    event_mon.setup_monitoring()
    self.assertIsInstance(config._router, router._LoggingStreamRouter)

    environ.get.return_value = 'Development/1.2'
    event_mon.setup_monitoring()
    self.assertIsInstance(config._router, router._LoggingStreamRouter)
Exemplo n.º 4
0
 def test_default_event(self):
     # The protobuf structure is actually an API not an implementation detail
     # so it's sane to test for changes.
     event_mon.setup_monitoring()
     event = event_mon.get_default_event()
     self.assertTrue(event.event_source.HasField('host_name'))
     self.assertFalse(event.event_source.HasField('service_name'))
     self.assertFalse(event.event_source.HasField('appengine_name'))
Exemplo n.º 5
0
 def test_default_event(self):
   # The protobuf structure is actually an API not an implementation detail
   # so it's sane to test for changes.
   event_mon.setup_monitoring()
   event = event_mon.get_default_event()
   self.assertTrue(event.event_source.HasField('host_name'))
   self.assertFalse(event.event_source.HasField('service_name'))
   self.assertFalse(event.event_source.HasField('appengine_name'))
Exemplo n.º 6
0
    def test_set_default_event(self):
        event_mon.setup_monitoring()
        orig_event = event_mon.get_default_event()

        # Set the new default event to something different from orig_event
        # to make sure it has changed.
        event = chrome_infra_log_pb2.ChromeInfraEvent()
        new_hostname = orig_event.event_source.host_name + '.foo'
        event.event_source.host_name = new_hostname
        event_mon.set_default_event(event)

        new_event = event_mon.get_default_event()
        self.assertEquals(new_event.event_source.host_name, new_hostname)
Exemplo n.º 7
0
  def test_set_default_event(self):
    event_mon.setup_monitoring()
    orig_event = event_mon.get_default_event()

    # Set the new default event to something different from orig_event
    # to make sure it has changed.
    event = chrome_infra_log_pb2.ChromeInfraEvent()
    new_hostname = orig_event.event_source.host_name + '.foo'
    event.event_source.host_name = new_hostname
    event_mon.set_default_event(event)

    new_event = event_mon.get_default_event()
    self.assertEquals(new_event.event_source.host_name, new_hostname)
Exemplo n.º 8
0
    def test_default_event_with_values(self):
        # The protobuf structure is actually an API not an implementation detail
        # so it's sane to test for changes.
        hostname = 'a'
        service_name = 'b'
        appengine_name = 'c'

        event_mon.setup_monitoring(hostname=hostname,
                                   service_name=service_name,
                                   appengine_name=appengine_name)
        event = event_mon.get_default_event()
        self.assertEquals(event.event_source.host_name, hostname)
        self.assertEquals(event.event_source.service_name, service_name)
        self.assertEquals(event.event_source.appengine_name, appengine_name)
Exemplo n.º 9
0
  def test_default_event_with_values(self):
    # The protobuf structure is actually an API not an implementation detail
    # so it's sane to test for changes.
    hostname = 'a'
    service_name = 'b'
    appengine_name = 'c'

    event_mon.setup_monitoring(
      hostname=hostname,
      service_name=service_name,
      appengine_name=appengine_name
    )
    event = event_mon.get_default_event()
    self.assertEquals(event.event_source.host_name, hostname)
    self.assertEquals(event.event_source.service_name, service_name)
    self.assertEquals(event.event_source.appengine_name, appengine_name)
Exemplo n.º 10
0
 def setUp(self):
     # Use the dry run mode instead of a mock.
     event_mon.setup_monitoring(run_type='dry')
Exemplo n.º 11
0
 def test_run_type_test(self):
     event_mon.setup_monitoring(run_type='test')
     self.assertIsInstance(config._router, router._HttpRouter)
Exemplo n.º 12
0
 def test_run_type_invalid(self):
     event_mon.setup_monitoring(run_type='invalid.')
     self.assertNotIsInstance(config._router, router._HttpRouter)
Exemplo n.º 13
0
 def test_get_default_event(self):
     event_mon.setup_monitoring()
     orig_event = config._cache['default_event']
     self.assertEqual(orig_event, event_mon.get_default_event())
     self.assertIsNot(orig_event, event_mon.get_default_event())
Exemplo n.º 14
0
    def test_set_default_event_bad_type(self):
        event_mon.setup_monitoring()

        # bad type
        with self.assertRaises(TypeError):
            event_mon.set_default_event({'hostname': 'foo'})
Exemplo n.º 15
0
 def test_run_type_invalid(self):
   event_mon.setup_monitoring(run_type='invalid.')
   self.assertFalse(isinstance(config._router, router._HttpRouter))
Exemplo n.º 16
0
 def test_run_type_test(self):
   event_mon.setup_monitoring(run_type='test', service_account_creds='creds')
   self.assertEquals(config._cache['service_account_creds'], 'creds')
Exemplo n.º 17
0
 def test_get_default_event(self):
   event_mon.setup_monitoring()
   orig_event = config._cache['default_event']
   self.assertEqual(orig_event, event_mon.get_default_event())
   self.assertIsNot(orig_event, event_mon.get_default_event())
Exemplo n.º 18
0
  def test_set_default_event_bad_type(self):
    event_mon.setup_monitoring()

    # bad type
    with self.assertRaises(TypeError):
      event_mon.set_default_event({'hostname': 'foo'})
Exemplo n.º 19
0
 def setUp(self):
   event_mon.setup_monitoring(run_type='dry')
Exemplo n.º 20
0
 def setUp(self):
   # Use the dry run mode instead of a mock.
   event_mon.setup_monitoring(run_type='dry')