| Index: dashboard/dashboard/find_anomalies_test.py
|
| diff --git a/dashboard/dashboard/find_anomalies_test.py b/dashboard/dashboard/find_anomalies_test.py
|
| index 277170cff02418a5b4ccbe4d7b9dbacafa1ff89f..5ecdb082c5cc62cc15feabe1535b8f87c52183ef 100644
|
| --- a/dashboard/dashboard/find_anomalies_test.py
|
| +++ b/dashboard/dashboard/find_anomalies_test.py
|
| @@ -16,6 +16,7 @@ from dashboard.models import anomaly
|
| from dashboard.models import graph_data
|
| from dashboard.models import histogram
|
| from dashboard.models import sheriff
|
| +from tracing.value.diagnostics import reserved_infos
|
|
|
| # Sample time series.
|
| _TEST_ROW_DATA = [
|
| @@ -483,13 +484,19 @@ class ProcessAlertsTest(testing_common.TestCase):
|
| self.assertEqual(alert.display_end, 302)
|
|
|
| def testMakeAnomalyEntity_AddsOwnership(self):
|
| - data = json.dumps({
|
| - 'type': 'Ownership',
|
| - 'guid': 'eb212e80-db58-4cbd-b331-c2245ecbb826',
|
| - 'emails': ['alice@chromium.org', 'bob@chromium.org'],
|
| - 'component': 'fooBar'
|
| - })
|
| + data_samples = [
|
| + {
|
| + 'type': 'GenericSet',
|
| + 'guid': 'eb212e80-db58-4cbd-b331-c2245ecbb826',
|
| + 'values': ['alice@chromium.org', 'bob@chromium.org']
|
| + },
|
| + {
|
| + 'type': 'GenericSet',
|
| + 'guid': 'eb212e80-db58-4cbd-b331-c2245ecbb827',
|
| + 'values': ['abc']
|
| + }]
|
|
|
| + test_key = utils.TestKey('ChromiumPerf/linux/page_cycler_v2/cnn')
|
| testing_common.AddTests(
|
| ['ChromiumPerf'],
|
| ['linux'], {
|
| @@ -500,12 +507,17 @@ class ProcessAlertsTest(testing_common.TestCase):
|
| 'nytimes': {},
|
| },
|
| })
|
| - test_key = utils.TestKey('ChromiumPerf/linux/page_cycler_v2/cnn')
|
| test = test_key.get()
|
| testing_common.AddRows(test.test_path, [100, 200, 300, 400])
|
| +
|
| entity = histogram.SparseDiagnostic(
|
| - data=data, test=test_key, id='abc', start_revision=1,
|
| - end_revision=sys.maxint)
|
| + data=json.dumps(data_samples[0]), test=test_key, start_revision=1,
|
| + end_revision=sys.maxint, id='sampleOwners', name='owners')
|
| + entity.put()
|
| +
|
| + entity = histogram.SparseDiagnostic(
|
| + data=json.dumps(data_samples[1]), test=test_key, start_revision=1,
|
| + end_revision=sys.maxint, id='sampleComponent', name='bug components')
|
| entity.put()
|
|
|
| alert = find_anomalies._MakeAnomalyEntity(
|
| @@ -513,11 +525,98 @@ class ProcessAlertsTest(testing_common.TestCase):
|
| test,
|
| list(graph_data.Row.query()))
|
|
|
| - self.assertEqual(alert.ownership['component'], 'fooBar')
|
| + self.assertEqual(alert.ownership['component'], 'abc')
|
| self.assertListEqual(alert.ownership['emails'],
|
| ['alice@chromium.org', 'bob@chromium.org'])
|
|
|
|
|
| +class GetMostRecentDiagnosticValueByNameTest(testing_common.TestCase):
|
| + def setUp(self):
|
| + super(GetMostRecentDiagnosticValueByNameTest, self).setUp()
|
| + self.SetCurrentUser('foo@bar.com', is_admin=True)
|
| +
|
| + def testGetMostRecentDiagnosticValueByName_ReturnAllData(self):
|
| + owners_name = reserved_infos.OWNERS.name
|
| + bug_components_name = reserved_infos.BUG_COMPONENTS.name
|
| +
|
| + data_samples = [
|
| + {
|
| + 'type': 'GenericSet',
|
| + 'guid': 'eb212e80-db58-4cbd-b331-c2245ecbb826',
|
| + 'values': ['alice@chromium.org']
|
| + },
|
| + {
|
| + 'type': 'GenericSet',
|
| + 'guid': 'eb212e80-db58-4cbd-b331-c2245ecbb827',
|
| + 'values': ['abc']
|
| + }]
|
| +
|
| + test_key = utils.TestKey('Chromium/win7/foo')
|
| + entity = histogram.SparseDiagnostic(
|
| + data=json.dumps(data_samples[0]), test=test_key, start_revision=1,
|
| + end_revision=sys.maxint, id='sampleOwners', name=owners_name)
|
| + entity.put()
|
| +
|
| + entity = histogram.SparseDiagnostic(
|
| + data=json.dumps(data_samples[1]), test=test_key, start_revision=1,
|
| + end_revision=sys.maxint, id='sampleComponent', name=bug_components_name)
|
| + entity.put()
|
| +
|
| + owners_lookup_result = find_anomalies.GetMostRecentDiagnosticValueByName(
|
| + test_key, owners_name)
|
| +
|
| + component_lookup_result = find_anomalies.GetMostRecentDiagnosticValueByName(
|
| + test_key, bug_components_name)
|
| +
|
| + self.assertEqual(owners_lookup_result, ['alice@chromium.org'])
|
| + self.assertEqual(component_lookup_result, ['abc'])
|
| +
|
| + def testGetMostRecentDiagnosticValueByName_ReturnsNoneIfNoneFound(self):
|
| + owners_name = reserved_infos.OWNERS.name
|
| +
|
| + data_sample = {
|
| + 'type': 'GenericSet',
|
| + 'guid': 'eb212e80-db58-4cbd-b331-c2245ecbb826',
|
| + 'values': ['alice@chromium.org']
|
| + }
|
| +
|
| + test_key = utils.TestKey('Chromium/win7/foo')
|
| + entity = histogram.SparseDiagnostic(
|
| + data=json.dumps(data_sample), test=test_key, start_revision=1,
|
| + end_revision=sys.maxint, id='sampleOwners', name=owners_name)
|
| + entity.put()
|
| +
|
| + owners_lookup_result = find_anomalies.GetMostRecentDiagnosticValueByName(
|
| + test_key, owners_name)
|
| +
|
| + component_lookup_result = find_anomalies.GetMostRecentDiagnosticValueByName(
|
| + test_key, reserved_infos.BUG_COMPONENTS.name)
|
| +
|
| + self.assertEqual(owners_lookup_result, ['alice@chromium.org'])
|
| + self.assertIsNone(component_lookup_result)
|
| +
|
| + def testGetMostRecentDiagnosticValueByName_ReturnsNoneIfNoName(self):
|
| + data_sample = {
|
| + 'guid': 'abc',
|
| + 'osName': 'linux',
|
| + 'type': 'DeviceInfo'
|
| + }
|
| +
|
| + test_key = utils.TestKey('Chromium/win7/foo')
|
| + entity = histogram.SparseDiagnostic(
|
| + data=json.dumps(data_sample), test=test_key, start_revision=1,
|
| + end_revision=sys.maxint, id='foobar')
|
| + entity.put()
|
| +
|
| + owners_lookup_result = find_anomalies.GetMostRecentDiagnosticValueByName(
|
| + test_key, reserved_infos.OWNERS.name)
|
| +
|
| + component_lookup_result = find_anomalies.GetMostRecentDiagnosticValueByName(
|
| + test_key, reserved_infos.BUG_COMPONENTS.name)
|
| +
|
| + self.assertIsNone(owners_lookup_result)
|
| + self.assertIsNone(component_lookup_result)
|
| +
|
| class GetMostRecentDiagnosticDataTest(testing_common.TestCase):
|
| def setUp(self):
|
| super(GetMostRecentDiagnosticDataTest, self).setUp()
|
|
|