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

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

Issue 1815413002: Add support for patch_url field in BuildEvent (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Added test Created 4 years, 9 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
« no previous file with comments | « infra_libs/event_mon/monitoring.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 self.assertTrue(log_event.HasField('event_time_ms')) 295 self.assertTrue(log_event.HasField('event_time_ms'))
296 self.assertTrue(log_event.HasField('source_extension')) 296 self.assertTrue(log_event.HasField('source_extension'))
297 297
298 # Check that source_extension deserializes to the right thing. 298 # Check that source_extension deserializes to the right thing.
299 event = ChromeInfraEvent.FromString(log_event.source_extension) 299 event = ChromeInfraEvent.FromString(log_event.source_extension)
300 self.assertTrue(event.HasField('build_event')) 300 self.assertTrue(event.HasField('build_event'))
301 self.assertEquals(event.build_event.type, BuildEvent.BUILD) 301 self.assertEquals(event.build_event.type, BuildEvent.BUILD)
302 self.assertEquals(event.build_event.host_name, hostname) 302 self.assertEquals(event.build_event.host_name, hostname)
303 self.assertEquals(event.build_event.build_name, build_name) 303 self.assertEquals(event.build_event.build_name, build_name)
304 304
305 def test_get_build_event_with_patch_url(self):
306 patch_url = 'http://foo.bar/123#456'
307 log_event = monitoring.get_build_event(
308 'BUILD', 'bot.host.name', 'build_name', patch_url=patch_url).log_event()
309 self.assertIsInstance(log_event, LogRequestLite.LogEventLite)
310
311 # Check that source_extension deserializes to the right thing.
312 event = ChromeInfraEvent.FromString(log_event.source_extension)
313 self.assertTrue(event.HasField('build_event'))
314 self.assertEquals(event.build_event.patch_url, patch_url)
315
305 def test_get_build_event_invalid_type(self): 316 def test_get_build_event_invalid_type(self):
306 # An invalid type is a critical error. 317 # An invalid type is a critical error.
307 log_event = monitoring.get_build_event('INVALID_TYPE', 318 log_event = monitoring.get_build_event('INVALID_TYPE',
308 'bot.host.name', 319 'bot.host.name',
309 'build_name').log_event() 320 'build_name').log_event()
310 self.assertIsNone(log_event) 321 self.assertIsNone(log_event)
311 322
312 def test_get_build_event_invalid_build_name(self): 323 def test_get_build_event_invalid_build_name(self):
313 # an invalid builder name is not a critical error. 324 # an invalid builder name is not a critical error.
314 hostname = 'bot.host.name' 325 hostname = 'bot.host.name'
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 'BUILD', 1189 'BUILD',
1179 'bot2.host.name', 1190 'bot2.host.name',
1180 'build_name2', 1191 'build_name2',
1181 build_number=1, 1192 build_number=1,
1182 build_scheduling_time=123456789, 1193 build_scheduling_time=123456789,
1183 result='FAILURE', 1194 result='FAILURE',
1184 timestamp_kind='POINT', 1195 timestamp_kind='POINT',
1185 event_timestamp=None), 1196 event_timestamp=None),
1186 ] 1197 ]
1187 self.assertTrue(monitoring.send_events(events)) 1198 self.assertTrue(monitoring.send_events(events))
OLDNEW
« no previous file with comments | « infra_libs/event_mon/monitoring.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698