Beispiel #1
0
  def testCreateStoppageAlert_DoesNotCreateLargeGroups(self):
    # First, create |_MAX_GROUP_SIZE| alerts; all of them can be created
    # and they all belong to the same group.
    tests = map(str, range(stoppage_alert._MAX_GROUP_SIZE))
    testing_common.AddTests(['M'], ['b'], {'suite': {t: {} for t in tests}})
    test_paths = ['M/b/suite/' + t for t in tests]
    rows = []
    alerts = []
    for path in test_paths:
      rows = testing_common.AddRows(path, [1])
      test = utils.TestKey(path).get()
      new_alert = stoppage_alert.CreateStoppageAlert(test, rows[0])
      self.assertIsNotNone(new_alert)
      new_alert.put()
      alerts.append(new_alert)
    self.assertEqual(stoppage_alert._MAX_GROUP_SIZE, len(alerts))
    self.assertTrue(all(a.group == alerts[0].group for a in alerts))

    # Making one more stoppage alert that belongs to this group fails.
    testing_common.AddTests(['M'], ['b'], {'suite': {'another': {}}})
    test_path = 'M/b/suite/another'
    rows = testing_common.AddRows(test_path, [1])
    test = utils.TestKey(test_path).get()
    new_alert = stoppage_alert.CreateStoppageAlert(test, rows[0])
    self.assertIsNone(new_alert)
 def _AddSampleData(self):
     """Adds a Test and Row entities, and returns the Test key."""
     testing_common.AddTests(['M'], ['b'], {'suite': {'foo': {}}})
     test_path = 'M/b/suite/foo'
     rows_dict = {x: {'value': y} for x, y in _SAMPLE_SERIES}
     testing_common.AddRows(test_path, rows_dict)
     return utils.TestKey(test_path)
Beispiel #3
0
  def testGet_OldUriWithNestedSubtestAndMissingSubTestParam(self):
    self._AddTestSuites()
    testing_common.AddRows(
        ('ChromiumGPU/linux-release/scrolling_benchmark/average_commit_time/'
         'answers.yahoo.com'),
        {200})

    expected_state = {
        'charts': [
            [[('ChromiumGPU/linux-release/scrolling_benchmark/'
               'average_commit_time/answers.yahoo.com'),
              ['answers.yahoo.com']]],
        ]
    }

    response = self.testapp.get(
        '/report'
        '?masters=ChromiumGPU&bots=linux-release'
        '&tests=scrolling_benchmark')

    # We expect to get a URL redirect with an sid.
    location = response.headers.get('location')
    self.assertIn('sid=', location)

    state_id = location.split('sid=')[1]
    state = ndb.Key(page_state.PageState, state_id).get()
    self.assertEqual(json.dumps(expected_state, separators=(',', ':')),
                     state.value)
 def testStartNewBisectForBug_WithDefaultRevs_StartsBisect(
         self, mock_perform_bisect):
     testing_common.AddTests(['ChromiumPerf'], ['linux-release'],
                             {'sunspider': {
                                 'score': {}
                             }})
     test_key = utils.TestKey('ChromiumPerf/linux-release/sunspider/score')
     testing_common.AddRows(
         'ChromiumPerf/linux-release/sunspider/score', {
             1199: {
                 'a_default_rev': 'r_foo',
                 'r_foo': '9e29b5bcd08357155b2859f87227d50ed60cf857'
             },
             1250: {
                 'a_default_rev': 'r_foo',
                 'r_foo': 'fc34e5346446854637311ad7793a95d56e314042'
             }
         })
     anomaly.Anomaly(bug_id=333,
                     test=test_key,
                     start_revision=1200,
                     end_revision=1250,
                     median_before_anomaly=100,
                     median_after_anomaly=200).put()
     auto_bisect.StartNewBisectForBug(333)
     job = try_job.TryJob.query(try_job.TryJob.bug_id == 333).get()
     mock_perform_bisect.assert_called_once_with(job)
    def testGet_WithAncestor_AllAlertsUpdated(self):
        testing_common.AddTests(['M'], ['b1', 'b2'],
                                {'foo': {
                                    'bar': {},
                                    'baz': {}
                                }})
        testing_common.AddRows(
            'M/b1/foo/bar', {i
                             for i in range(1431001000, 1432001000, 6000)})
        test_key = utils.TestKey('M/b1/foo/bar')
        # range(1431001000, 1431081000, 6000) includes 14 numbers.
        for i in range(1431001000, 1431081000, 6000):
            anomaly.Anomaly(start_revision=i,
                            end_revision=i + 12000,
                            test=test_key,
                            median_before_anomaly=100,
                            median_after_anomaly=200).put()

        self.testapp.post('/shrink_timestamp_revisions', {'ancestor': 'M'})
        self.ExecuteTaskQueueTasks('/shrink_timestamp_revisions',
                                   shrink_timestamp_revisions._QUEUE_NAME)

        anomalies = anomaly.Anomaly.query().fetch()
        self.assertEqual(14, len(anomalies))
        for a in anomalies:
            self.assertLess(a.start_revision, 300000)
            self.assertLess(a.end_revision, 300000)
    def testPost_WithAncestor_AllRowsMoved(self):
        testing_common.AddTests(['M'], ['b1', 'b2'],
                                {'foo': {
                                    'bar': {},
                                    'baz': {}
                                }})
        for test_path in ('M/b1/foo/bar', 'M/b1/foo/baz', 'M/b2/foo/bar'):
            # range(1425001000, 1430001000, 6000) includes 834 numbers.
            testing_common.AddRows(
                test_path, {i
                            for i in range(1425001000, 1430001000, 6000)})

        self.testapp.post('/shrink_timestamp_revisions', {'ancestor': 'M/b1'})
        self.ExecuteTaskQueueTasks('/shrink_timestamp_revisions',
                                   shrink_timestamp_revisions._QUEUE_NAME)

        b1_bar_rows = graph_data.Row.query(graph_data.Row.parent_test == utils.
                                           TestKey('M/b1/foo/bar')).fetch()
        b1_baz_rows = graph_data.Row.query(graph_data.Row.parent_test == utils.
                                           TestKey('M/b1/foo/baz')).fetch()
        b2_bar_rows = graph_data.Row.query(graph_data.Row.parent_test == utils.
                                           TestKey('M/b2/foo/bar')).fetch()
        self.assertGreater(len(b1_bar_rows), 600)
        self.assertGreater(len(b1_baz_rows), 600)
        self.assertEqual(834, len(b2_bar_rows))
        for r in b1_bar_rows:
            self.assertLess(r.revision, 300000)
        for r in b1_baz_rows:
            self.assertLess(r.revision, 300000)
        for r in b2_bar_rows:
            self.assertGreater(r.revision, 300000)
Beispiel #7
0
    def _AddTestData(self,
                     series,
                     sheriff_key,
                     improvement_direction=anomaly.UP):
        """Adds one sample Test and associated data.

    Args:
      series: Either a list of values, or a list of (x, y) pairs.
      sheriff_key: A Sheriff entity key.
      improvement_direction: One of {anomaly.UP, anomaly.DOWN, anomaly.UNKNOWN}.

    Returns:
      The Test entity key of the Test that was added.
    """
        testing_common.AddTests(['M'], ['b'], {'benchmark': {'t': {}}})
        test_path = 'M/b/benchmark/t'
        test = utils.TestKey(test_path).get()
        test.improvement_direction = improvement_direction
        test.sheriff = sheriff_key
        sheriff_entity = sheriff_key.get()
        sheriff_entity.patterns.append(test.test_path)
        sheriff_entity.put()
        if series and isinstance(series[0], (int, float)):
            series = enumerate(series, start=1)
        testing_common.AddRows(test_path, {x: {'value': y} for x, y in series})
        return test.put()
    def _AddMockData(self):
        """Adds sample TestMetadata and Row entities."""
        testing_common.AddTests(*_MOCK_DATA)

        # Add 50 Row entities to some of the tests.
        for test_path in _TESTS_WITH_ROWS:
            testing_common.AddRows(test_path, range(15000, 15100, 2))
Beispiel #9
0
 def testPointInfoDict_RowHasNoTracingUri_ResultHasNoTracingUri(self):
     testing_common.AddTests(['Master'], ['b'], {'my_suite': {}})
     rows = testing_common.AddRows('Master/b/my_suite', [345])
     # This row has no a_tracing_uri property, so there should be no
     # trace annotation returned by _PointInfoDict.
     point_info = graph_json._PointInfoDict(rows[0], {})
     self.assertFalse(hasattr(rows[0], 'a_tracing_uri'))
     self.assertNotIn('a_tracing_uri', point_info)
  def _AddMockData(self):
    """Adds sample TestMetadata and Row entities."""
    testing_common.AddTests(*_MOCK_DATA)

    recent = datetime.timedelta(days=5)
    for test_path in _TESTS_WITH_NEW_ROWS:
      testing_common.AddRows(
          test_path,
          {x: {'timestamp': datetime.datetime.now() - recent} for x in range(
              15000, 15100, 2)})

    too_long = datetime.timedelta(days=190)
    for test_path in _TESTS_WITH_OLD_ROWS:
      testing_common.AddRows(
          test_path,
          {x: {'timestamp': datetime.datetime.now() - too_long} for x in range(
              15000, 15100, 2)})
Beispiel #11
0
 def testGet_WithStoppageAlert_ChangesAlertBugId(self):
     test_keys = self._AddTests()
     rows = testing_common.AddRows(utils.TestPath(test_keys[0]), {10, 20})
     alert_key = stoppage_alert.CreateStoppageAlert(test_keys[0].get(),
                                                    rows[0]).put()
     self.testapp.get('/associate_alerts?bug_id=123&keys=%s' %
                      alert_key.urlsafe())
     self.assertEqual(123, alert_key.get().bug_id)
 def _AddStoppageAlerts(self):
     testing_common.AddTests(
         ['ChromiumGPU'], ['linux-release'],
         {'scrolling_benchmark': {
             'dropped_foo': {},
             'dropped_bar': {},
         }})
     foo_path = 'ChromiumGPU/linux-release/scrolling_benchmark/dropped_foo'
     bar_path = 'ChromiumGPU/linux-release/scrolling_benchmark/dropped_bar'
     foo_test = utils.TestKey(foo_path).get()
     bar_test = utils.TestKey(bar_path).get()
     foo_row = testing_common.AddRows(foo_path, {200})[0]
     bar_row = testing_common.AddRows(bar_path, {200})[0]
     foo_alert_key = stoppage_alert.CreateStoppageAlert(foo_test,
                                                        foo_row).put()
     bar_alert_key = stoppage_alert.CreateStoppageAlert(bar_test,
                                                        bar_row).put()
     return [foo_alert_key.get(), bar_alert_key.get()]
 def testGetOrCreateAncestors_UpdatesStoppageAlert(self):
     testing_common.AddTests(['M'], ['b'], {'suite': {'foo': {}}})
     row = testing_common.AddRows('M/b/suite/foo', {123})[0]
     test = utils.TestKey('M/b/suite/foo').get()
     alert_key = stoppage_alert.CreateStoppageAlert(test, row).put()
     test.stoppage_alert = alert_key
     test.put()
     add_point_queue._GetOrCreateAncestors('M', 'b', 'suite/foo')
     self.assertIsNone(test.key.get().stoppage_alert)
     self.assertTrue(alert_key.get().recovered)
 def _AddSampleData(self):
     """Puts a Test and Row in the datastore and returns the entities."""
     testing_common.AddTests(['M'], ['b'], {'suite': {'foo': {}}})
     sheriff.Sheriff(id='Foo', patterns=['*/*/*/*']).put()
     test_path = 'M/b/suite/foo'
     test_key = utils.TestKey(test_path)
     test = test_key.get()
     testing_common.AddRows(test_path, {100})
     row = graph_data.Row.query().get()
     return test, row
 def testPost_WithBugIdParameter_ListsStoppageAlerts(self):
     test_keys = self._AddTests()
     bug_data.Bug(id=123).put()
     row = testing_common.AddRows(utils.TestPath(test_keys[0]), {100})[0]
     alert = stoppage_alert.CreateStoppageAlert(test_keys[0].get(), row)
     alert.bug_id = 123
     alert.put()
     response = self.testapp.post('/group_report?bug_id=123')
     alert_list = self.GetJsonValue(response, 'alert_list')
     self.assertEqual(1, len(alert_list))
Beispiel #16
0
 def testPost_StoppageAlerts_EmbedsStoppageAlertListAndOneTable(self):
     sheriff.Sheriff(id='Sheriff', patterns=['M/b/*/*']).put()
     testing_common.AddTests(['M'], ['b'], {'foo': {'bar': {}}})
     test_key = utils.TestKey('M/b/foo/bar')
     rows = testing_common.AddRows('M/b/foo/bar', {9800, 9802})
     for row in rows:
         stoppage_alert.CreateStoppageAlert(test_key.get(), row).put()
     response = self.testapp.post('/alerts?sheriff=Sheriff')
     stoppage_alert_list = self.GetJsonValue(response,
                                             'stoppage_alert_list')
     self.assertEqual(2, len(stoppage_alert_list))
Beispiel #17
0
 def testGetGraphJson_ManyUnselected_ReturnsNothing(self):
   testing_common.AddTests(
       ['M'], ['b'], {'suite': {str(i): {} for i in range(100)}})
   test_paths = ['M/b/suite/%s' % i for i in range(100)]
   for p in test_paths:
     testing_common.AddRows(p, [1])
   response = graph_json.GetGraphJson(
       test_path_dict={p: [] for p in test_paths}, is_selected=False)
   self.assertEqual(
       {'data': {}, 'annotations': {}, 'error_bars': {}},
       json.loads(response))
Beispiel #18
0
 def testGet_StoppageAlerts_EmbedsStoppageAlertListAndOneTable(self):
     sheriff.Sheriff(id='Sheriff', patterns=['M/b/*/*']).put()
     testing_common.AddTests(['M'], ['b'], {'foo': {'bar': {}}})
     test_key = utils.TestKey('M/b/foo/bar')
     rows = testing_common.AddRows('M/b/foo/bar', {9800, 9802})
     for row in rows:
         stoppage_alert.CreateStoppageAlert(test_key.get(), row).put()
     response = self.testapp.get('/alerts?sheriff=Sheriff')
     stoppage_alert_list = self.GetEmbeddedVariable(response,
                                                    'STOPPAGE_ALERT_LIST')
     self.assertEqual(2, len(stoppage_alert_list))
     self.assertEqual(1, len(response.html('alerts-table')))
 def _AddSampleData(self):
     """Puts a TestMetadata and Row in the datastore and returns the entities."""
     testing_common.AddTests(['M'], ['b'],
                             {'suite': {
                                 'foo': {},
                                 'bar': {},
                                 'baz': {}
                             }})
     sheriff.Sheriff(email='*****@*****.**',
                     id='Foo',
                     patterns=['*/*/*/*'],
                     stoppage_alert_delay=3).put()
     for name in ('foo', 'bar', 'baz'):
         test_path = 'M/b/suite/%s' % name
         testing_common.AddRows(test_path, {100})
Beispiel #20
0
  def _AddSampleData(self):
    """Adds sample data to the datastore, used in test methods below.

    All entities added here are added with internal_only=False.
    """
    testing_common.AddTests(
        ['ChromiumPerf', 'ChromiumGPU'],
        ['win7', 'mac'],
        {'scrolling': {'first_paint': {}}})
    test_paths = [
        'ChromiumPerf/win7/scrolling/first_paint',
        'ChromiumPerf/mac/scrolling/first_paint',
        'ChromiumGPU/win7/scrolling/first_paint',
        'ChromiumGPU/mac/scrolling/first_paint',
    ]
    for path in test_paths:
      testing_common.AddRows(path, [15000, 15005, 15010, 15015])
      anomaly.Anomaly(
          test=utils.TestKey(path),
          start_revision=15001,
          end_revision=15005,
          median_before_anomaly=100,
          median_after_anomaly=200).put()