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

Unified Diff: infra_libs/event_mon/test/monitoring_test.py

Issue 2108803004: Add support for build category in BuildEvent (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Addressed comments Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « infra_libs/event_mon/monitoring.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra_libs/event_mon/test/monitoring_test.py
diff --git a/infra_libs/event_mon/test/monitoring_test.py b/infra_libs/event_mon/test/monitoring_test.py
index 055122ba5c2314b093dc27c360fc5118630b9257..51316be2fa9c9f5180fb9b4cd1bec924bbd3ad22 100644
--- a/infra_libs/event_mon/test/monitoring_test.py
+++ b/infra_libs/event_mon/test/monitoring_test.py
@@ -328,6 +328,35 @@ class GetBuildEventTest(unittest.TestCase):
'BUILD', 'bot.host.name', 'build_name', bbucket_id='foo').log_event()
self.assertIsInstance(log_event, LogRequestLite.LogEventLite)
+ def test_get_build_event_with_category(self):
+ log_event = monitoring.get_build_event(
+ 'BUILD', 'bot.host.name', 'build_name',
+ category='git_cl_try').log_event()
+ self.assertIsInstance(log_event, LogRequestLite.LogEventLite)
+
+ # Check that source_extension deserializes to the right thing.
+ event = ChromeInfraEvent.FromString(log_event.source_extension)
+ self.assertTrue(event.HasField('build_event'))
+ self.assertEquals(
+ event.build_event.category, BuildEvent.CATEGORY_GIT_CL_TRY)
+
+ # Try unknown value. Should produce CATEGORY_UNKNOWN.
+ log_event = monitoring.get_build_event(
+ 'BUILD', 'bot.host.name', 'build_name', category='foobar').log_event()
+ self.assertIsInstance(log_event, LogRequestLite.LogEventLite)
+ event = ChromeInfraEvent.FromString(log_event.source_extension)
+ self.assertTrue(event.HasField('build_event'))
+ self.assertEquals(
+ event.build_event.category, BuildEvent.CATEGORY_UNKNOWN)
+
+ # Try empty value. Should not set category.
+ log_event = monitoring.get_build_event(
+ 'BUILD', 'bot.host.name', 'build_name', category='').log_event()
+ self.assertIsInstance(log_event, LogRequestLite.LogEventLite)
+ event = ChromeInfraEvent.FromString(log_event.source_extension)
+ self.assertTrue(event.HasField('build_event'))
+ self.assertFalse(event.build_event.HasField('category'))
+
def test_get_build_event_invalid_type(self):
# An invalid type is a critical error.
log_event = monitoring.get_build_event('INVALID_TYPE',
« 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