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

Unified Diff: dashboard/dashboard/add_histograms_test.py

Issue 2989143002: Plumb SparseDiagnostics by Name (Closed)
Patch Set: Rebase onto master Created 3 years, 4 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 | « dashboard/dashboard/add_histograms.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dashboard/dashboard/add_histograms_test.py
diff --git a/dashboard/dashboard/add_histograms_test.py b/dashboard/dashboard/add_histograms_test.py
index 1d5c9dbb8459b77d8a5077dfeb9857a28963f8dc..66826b181edae81f7582eb3912a2886399c1d7c7 100644
--- a/dashboard/dashboard/add_histograms_test.py
+++ b/dashboard/dashboard/add_histograms_test.py
@@ -21,6 +21,7 @@ from dashboard.common import utils
from dashboard.models import histogram
from tracing.value import histogram as histogram_module
from tracing.value import histogram_set
+from tracing.value.diagnostics import reserved_infos
GOOGLER_USER = users.User(email='sullivan@chromium.org',
@@ -503,6 +504,197 @@ class AddHistogramsTest(testing_common.TestCase):
])
self.testapp.post('/add_histograms', {'data': data}, status=400)
+ def testPostHistogram_AddsSparseDiagnosticByName(self):
+ data = json.dumps([
+ {
+ 'type': 'GenericSet',
+ 'guid': 'cabb59fe-4bcf-4512-881c-d038c7a80635',
+ 'values': ['alice@chromium.org']
+ },
+ {
+ 'benchmarkName': 'benchmark',
+ 'canonicalUrl': '',
+ 'guid': '0bc1021b-8107-4db7-bc8c-49d7cf53c5ae',
+ 'label': '',
+ 'legacyTIRLabel': '',
+ 'storyDisplayName': 'story',
+ 'type': 'TelemetryInfo'
+ }, {
+ 'angle': [],
+ 'catapult': [],
+ 'chromium': [],
+ 'chromiumCommitPosition': [424242],
+ 'guid': '25f0a111-9bb4-4cea-b0c1-af2609623160',
+ 'skia': [],
+ 'type': 'RevisionInfo',
+ 'v8': [],
+ 'webrtc': []
+ }, {
+ 'buildNumber': 0,
+ 'buildbotMasterName': '',
+ 'buildbotName': 'buildbotmaster1',
+ 'displayBotName': 'bot',
+ 'displayMasterName': 'master',
+ 'guid': 'e9c2891d-2b04-413f-8cf4-099827e67626',
+ 'logUri': '',
+ 'type': 'BuildbotInfo'
+ }, {
+ 'binBoundaries': [1, [1, 1000, 20]],
+ 'diagnostics': {
+ 'buildbot': 'e9c2891d-2b04-413f-8cf4-099827e67626',
+ 'revisions': '25f0a111-9bb4-4cea-b0c1-af2609623160',
+ 'telemetry': '0bc1021b-8107-4db7-bc8c-49d7cf53c5ae',
+ 'owners': 'cabb59fe-4bcf-4512-881c-d038c7a80635'
+ },
+ 'guid': '4989617a-14d6-4f80-8f75-dafda2ff13b0',
+ 'name': 'foo',
+ 'unit': 'count'}
+ ])
+
+ self.testapp.post('/add_histograms', {'data': data})
+
+ diagnostics = histogram.SparseDiagnostic.query().fetch()
+ params_by_guid = self.TaskParamsByGuid()
+
+ params = params_by_guid['4989617a-14d6-4f80-8f75-dafda2ff13b0']
+ hist = json.loads(params['data'][0])
+ owners_info = hist['diagnostics'][reserved_infos.OWNERS.name]
+ self.assertEqual(2, len(diagnostics))
+ self.assertEqual(reserved_infos.OWNERS.name, diagnostics[0].name)
+ self.assertEqual(['alice@chromium.org'], diagnostics[0].data['values'])
+ self.assertEqual('cabb59fe-4bcf-4512-881c-d038c7a80635', owners_info)
+
+ def testPostHistogram_AddsSparseDiagnosticByName_OnlyOnce(self):
+ data = json.dumps([
+ {
+ 'type': 'GenericSet',
+ 'guid': 'cabb59fe-4bcf-4512-881c-d038c7a80635',
+ 'values': ['alice@chromium.org']
+ },
+ {
+ 'benchmarkName': 'benchmark',
+ 'canonicalUrl': '',
+ 'guid': '0bc1021b-8107-4db7-bc8c-49d7cf53c5ae',
+ 'label': '',
+ 'legacyTIRLabel': '',
+ 'storyDisplayName': 'story',
+ 'type': 'TelemetryInfo'
+ }, {
+ 'angle': [],
+ 'catapult': [],
+ 'chromium': [],
+ 'chromiumCommitPosition': [424242],
+ 'guid': '25f0a111-9bb4-4cea-b0c1-af2609623160',
+ 'skia': [],
+ 'type': 'RevisionInfo',
+ 'v8': [],
+ 'webrtc': []
+ }, {
+ 'buildNumber': 0,
+ 'buildbotMasterName': '',
+ 'buildbotName': 'buildbotmaster1',
+ 'displayBotName': 'bot',
+ 'displayMasterName': 'master',
+ 'guid': 'e9c2891d-2b04-413f-8cf4-099827e67626',
+ 'logUri': '',
+ 'type': 'BuildbotInfo'
+ }, {
+ 'binBoundaries': [1, [1, 1000, 20]],
+ 'diagnostics': {
+ 'buildbot': 'e9c2891d-2b04-413f-8cf4-099827e67626',
+ 'revisions': '25f0a111-9bb4-4cea-b0c1-af2609623160',
+ 'telemetry': '0bc1021b-8107-4db7-bc8c-49d7cf53c5ae',
+ 'owners': 'cabb59fe-4bcf-4512-881c-d038c7a80635'
+ },
+ 'guid': '4989617a-14d6-4f80-8f75-dafda2ff13b0',
+ 'name': 'foo',
+ 'unit': 'count'
+ }, {
+ 'binBoundaries': [1, [1, 1000, 20]],
+ 'diagnostics': {
+ 'buildbot': 'e9c2891d-2b04-413f-8cf4-099827e67626',
+ 'revisions': '25f0a111-9bb4-4cea-b0c1-af2609623160',
+ 'telemetry': '0bc1021b-8107-4db7-bc8c-49d7cf53c5ae',
+ 'owners': 'cabb59fe-4bcf-4512-881c-d038c7a80635'
+ },
+ 'guid': '5239617a-14d6-4f80-8f75-dafda2ff13b1',
+ 'name': 'bar',
+ 'unit': 'count'
+ }])
+
+ self.testapp.post('/add_histograms', {'data': data})
+
+ diagnostics = histogram.SparseDiagnostic.query().fetch()
+
+ self.assertEqual(2, len(diagnostics))
+ self.assertEqual(reserved_infos.OWNERS.name, diagnostics[0].name)
+ self.assertNotEqual(reserved_infos.OWNERS.name, diagnostics[1].name)
+
+ def testPostHistogram_AddsSparseDiagnosticByName_ErrorsIfDiverging(self):
+ data = json.dumps([
+ {
+ 'type': 'GenericSet',
+ 'guid': 'cabb59fe-4bcf-4512-881c-d038c7a80635',
+ 'values': ['alice@chromium.org']
+ }, {
+ 'type': 'GenericSet',
+ 'guid': '7c5bd92f-4146-411b-9192-248ffc1be92c',
+ 'values': ['bob@chromium.org']
+ }, {
+ 'benchmarkName': 'benchmark',
+ 'canonicalUrl': '',
+ 'guid': '0bc1021b-8107-4db7-bc8c-49d7cf53c5ae',
+ 'label': '',
+ 'legacyTIRLabel': '',
+ 'storyDisplayName': 'story',
+ 'type': 'TelemetryInfo'
+ }, {
+ 'angle': [],
+ 'catapult': [],
+ 'chromium': [],
+ 'chromiumCommitPosition': [424242],
+ 'guid': '25f0a111-9bb4-4cea-b0c1-af2609623160',
+ 'skia': [],
+ 'type': 'RevisionInfo',
+ 'v8': [],
+ 'webrtc': []
+ }, {
+ 'buildNumber': 0,
+ 'buildbotMasterName': '',
+ 'buildbotName': 'buildbotmaster1',
+ 'displayBotName': 'bot',
+ 'displayMasterName': 'master',
+ 'guid': 'e9c2891d-2b04-413f-8cf4-099827e67626',
+ 'logUri': '',
+ 'type': 'BuildbotInfo'
+ }, {
+ 'binBoundaries': [1, [1, 1000, 20]],
+ 'diagnostics': {
+ 'buildbot': 'e9c2891d-2b04-413f-8cf4-099827e67626',
+ 'revisions': '25f0a111-9bb4-4cea-b0c1-af2609623160',
+ 'telemetry': '0bc1021b-8107-4db7-bc8c-49d7cf53c5ae',
+ 'owners': 'cabb59fe-4bcf-4512-881c-d038c7a80635'
+ },
+ 'guid': '4989617a-14d6-4f80-8f75-dafda2ff13b0',
+ 'name': 'foo',
+ 'unit': 'count'
+ }, {
+ 'binBoundaries': [1, [1, 1000, 20]],
+ 'diagnostics': {
+ 'buildbot': 'e9c2891d-2b04-413f-8cf4-099827e67626',
+ 'revisions': '25f0a111-9bb4-4cea-b0c1-af2609623160',
+ 'telemetry': '0bc1021b-8107-4db7-bc8c-49d7cf53c5ae',
+ 'owners': '7c5bd92f-4146-411b-9192-248ffc1be92c'
+ },
+ 'guid': 'bda61ae3-0178-43f8-8aec-3ab78b9a2e18',
+ 'name': 'foo',
+ 'unit': 'count'
+ }])
+
+ self.assertRaises(
+ Exception,
+ self.testapp.post, '/add_histograms', {'data': data})
+
def testFindHistogramLevelSparseDiagnostics(self):
hist = histogram_module.Histogram('hist', 'count')
histograms = histogram_set.HistogramSet([hist])
« no previous file with comments | « dashboard/dashboard/add_histograms.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698