Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: infra_libs/event_mon/test/monitoring_test.py

Issue 2041103004: Report buildbucket ID for all builds (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # -*- encoding:utf-8 -*- 1 # -*- encoding:utf-8 -*-
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import unittest 6 import unittest
7 7
8 from infra_libs import event_mon 8 from infra_libs import event_mon
9 from infra_libs.event_mon import config, router 9 from infra_libs.event_mon import config, router
10 from infra_libs.event_mon import monitoring 10 from infra_libs.event_mon import monitoring
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 patch_url = 'http://foo.bar/123#456' 306 patch_url = 'http://foo.bar/123#456'
307 log_event = monitoring.get_build_event( 307 log_event = monitoring.get_build_event(
308 'BUILD', 'bot.host.name', 'build_name', patch_url=patch_url).log_event() 308 'BUILD', 'bot.host.name', 'build_name', patch_url=patch_url).log_event()
309 self.assertIsInstance(log_event, LogRequestLite.LogEventLite) 309 self.assertIsInstance(log_event, LogRequestLite.LogEventLite)
310 310
311 # Check that source_extension deserializes to the right thing. 311 # Check that source_extension deserializes to the right thing.
312 event = ChromeInfraEvent.FromString(log_event.source_extension) 312 event = ChromeInfraEvent.FromString(log_event.source_extension)
313 self.assertTrue(event.HasField('build_event')) 313 self.assertTrue(event.HasField('build_event'))
314 self.assertEquals(event.build_event.patch_url, patch_url) 314 self.assertEquals(event.build_event.patch_url, patch_url)
315 315
316 def test_get_build_event_with_bbucket_id(self):
317 log_event = monitoring.get_build_event(
318 'BUILD', 'bot.host.name', 'build_name', bbucket_id=123).log_event()
319 self.assertIsInstance(log_event, LogRequestLite.LogEventLite)
320
321 # Check that source_extension deserializes to the right thing.
322 event = ChromeInfraEvent.FromString(log_event.source_extension)
323 self.assertTrue(event.HasField('build_event'))
324 self.assertEquals(event.build_event.bbucket_id, 123)
325
326 # Try invalid value. This should not throw any exceptions.
327 log_event = monitoring.get_build_event(
328 'BUILD', 'bot.host.name', 'build_name', bbucket_id='foo').log_event()
329 self.assertIsInstance(log_event, LogRequestLite.LogEventLite)
330
316 def test_get_build_event_invalid_type(self): 331 def test_get_build_event_invalid_type(self):
317 # An invalid type is a critical error. 332 # An invalid type is a critical error.
318 log_event = monitoring.get_build_event('INVALID_TYPE', 333 log_event = monitoring.get_build_event('INVALID_TYPE',
319 'bot.host.name', 334 'bot.host.name',
320 'build_name').log_event() 335 'build_name').log_event()
321 self.assertIsNone(log_event) 336 self.assertIsNone(log_event)
322 337
323 def test_get_build_event_invalid_build_name(self): 338 def test_get_build_event_invalid_build_name(self):
324 # an invalid builder name is not a critical error. 339 # an invalid builder name is not a critical error.
325 hostname = 'bot.host.name' 340 hostname = 'bot.host.name'
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 'BUILD', 1229 'BUILD',
1215 'bot2.host.name', 1230 'bot2.host.name',
1216 'build_name2', 1231 'build_name2',
1217 build_number=1, 1232 build_number=1,
1218 build_scheduling_time=123456789, 1233 build_scheduling_time=123456789,
1219 result='FAILURE', 1234 result='FAILURE',
1220 timestamp_kind='POINT', 1235 timestamp_kind='POINT',
1221 event_timestamp=None), 1236 event_timestamp=None),
1222 ] 1237 ]
1223 self.assertTrue(monitoring.send_events(events)) 1238 self.assertTrue(monitoring.send_events(events))
OLDNEW
« infra/tools/send_monitoring_event/send_event.py ('K') | « infra_libs/event_mon/monitoring.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698