Example #1
0
    def _AddMockData(self):
        """Adds sample Test, Row, and Anomaly entities."""
        testing_common.AddTests(*_MOCK_DATA)

        # Add 50 Row entities to one of the tests.
        # Also add 2 Anomaly entities.
        test_path = 'ChromiumPerf/mac/SunSpider/Total/t'
        test_key = utils.TestKey(test_path)
        test_container_key = utils.GetTestContainerKey(test_key)
        for rev in range(15000, 15100, 2):
            graph_data.Row(id=rev, parent=test_container_key,
                           value=(rev * 2)).put()
            if rev % 50 == 0:
                anomaly.Anomaly(start_revision=(rev - 2),
                                end_revision=rev,
                                median_before_anomaly=100,
                                median_after_anomaly=50,
                                test=test_key).put()
Example #2
0
 def _AddMockInternalData(self):
     master = graph_data.Master(id='ChromiumPerf').put()
     bots = []
     for name in ['win7', 'mac']:
         bot = graph_data.Bot(id=name, parent=master,
                              internal_only=True).put()
         bots.append(bot)
         test = graph_data.Test(id='dromaeo',
                                parent=bot,
                                internal_only=True).put()
         dom_test = graph_data.Test(id='dom', parent=test,
                                    has_rows=True).put()
         test_container_key = utils.GetTestContainerKey(dom_test)
         for i in range(1, 50):
             graph_data.Row(parent=test_container_key,
                            id=i,
                            value=float(i * 2),
                            error=(i + 10),
                            internal_only=True).put()
Example #3
0
    def _AddTestColumns(self, start_rev=15000, end_rev=16500, step=3):
        """Adds a bunch of test data to the mock datastore.

    In particular, add Rows with revisions in the given range (but skipping
    some numbers, so the revisions are non-contiguous) under the dromaeo/dom
    test for winXP, win7, mac.

    Args:
      start_rev: Starting revision number.
      end_rev: Ending revision number.
      step: Difference between adjacent revisions.
    """
        master = graph_data.Master(id='ChromiumGPU')
        master.put()
        bots = []
        rows = []
        for name in ['winXP', 'win7', 'mac']:
            bot = graph_data.Bot(id=name, parent=master.key)
            bot.put()
            bots.append(bot)
            test = graph_data.TestMetadata(id='ChromiumGPU/%s/dromaeo' % name)
            test.put()
            for sub_name in ['dom', 'jslib']:
                sub_test = graph_data.TestMetadata(
                    id='%s/%s' % (test.key.id(), sub_name),
                    improvement_direction=anomaly.UP,
                    has_rows=True).put()
                test_container_key = utils.GetTestContainerKey(sub_test)
                for i in range(start_rev, end_rev, step):
                    # Add Rows for one bot with revision numbers that aren't lined up
                    # with the other bots.
                    rev = i + 1 if name == 'mac' else i
                    row = graph_data.Row(
                        parent=test_container_key,
                        id=rev,
                        value=float(i * 2),
                        r_webkit=int(i * 0.25),
                        a_str='some_string',
                        buildnumber=i - start_rev,
                        a_tracing_uri='http://trace/%d' % i,
                        a_trace_rerun_options={'foo': '--foo'})
                    rows.append(row)
        ndb.put_multi(rows)
Example #4
0
def _GetRevisionForBisect(revision, test_key):
    """Gets a start or end revision value which can be used when bisecting.

  Note: This logic is parallel to that in elements/chart-container.html
  in the method getRevisionForBisect.

  Args:
    revision: The ID of a Row, not necessarily an actual revision number.
    test_key: The ndb.Key for a Test.

  Returns:
    An int or string value which can be used when bisecting.
  """
    row_parent_key = utils.GetTestContainerKey(test_key)
    row = graph_data.Row.get_by_id(revision, parent=row_parent_key)
    if row and hasattr(row, 'a_default_rev') and hasattr(
            row, row.a_default_rev):
        return getattr(row, row.a_default_rev)
    return revision
Example #5
0
 def testProcessTest_CreatesAnAnomaly(self):
   testing_common.AddTests(
       ['ChromiumGPU'], ['linux-release'], {
           'scrolling_benchmark': {'ref': {}},
       })
   ref = utils.TestKey(
       'ChromiumGPU/linux-release/scrolling_benchmark/ref').get()
   test_container_key = utils.GetTestContainerKey(ref.key)
   for row in _TEST_ROW_DATA:
     graph_data.Row(id=row[0], value=row[1], parent=test_container_key).put()
   sheriff.Sheriff(
       email='*****@*****.**', id='sheriff', patterns=[ref.test_path]).put()
   ref.put()
   find_anomalies.ProcessTest(ref.key)
   new_anomalies = anomaly.Anomaly.query().fetch()
   self.assertEqual(1, len(new_anomalies))
   self.assertEqual(anomaly.UP, new_anomalies[0].direction)
   self.assertEqual(241536, new_anomalies[0].start_revision)
   self.assertEqual(241537, new_anomalies[0].end_revision)
Example #6
0
    def _AddTestData(self,
                     test_name,
                     rows,
                     improvement_direction=anomaly.UNKNOWN,
                     config=None):
        testing_common.AddTests(['ChromiumGPU'], ['linux-release'], {
            'scrolling_benchmark': {
                test_name: {},
            },
        })
        test = utils.TestKey('ChromiumGPU/linux-release/scrolling_benchmark/' +
                             test_name).get()
        test.improvement_direction = improvement_direction
        test_container_key = utils.GetTestContainerKey(test.key)

        sheriff_entity = self.sheriff.get()
        if sheriff_entity.patterns:
            sheriff_entity.patterns.append(test.test_path)
        else:
            sheriff_entity.patterns = [test.test_path]
        sheriff_entity.put()

        for row in rows:
            graph_data.Row(id=row[0], value=row[1],
                           parent=test_container_key).put()

        # Add test config.
        if not config:
            config = {
                'max_window_size': 50,
                'multiple_of_std_dev': 3.5,
                'min_relative_change': 0.1,
                'min_absolute_change': 1.0,
                'min_segment_size': 3,
            }
        anomaly_config.AnomalyConfig(id='config_' + test_name,
                                     config=config,
                                     patterns=[test.test_path]).put()

        test.put()
        return test
Example #7
0
    def _AddTestData(self,
                     test_name,
                     rows,
                     sheriff_key_key,
                     improvement_direction=anomaly.UNKNOWN):
        """Adds a sample Test and associated data and returns the Test."""

        testing_common.AddTests(['ChromiumGPU'], ['linux-release'], {
            'scrolling_benchmark': {
                test_name: {},
            },
        })
        test = utils.TestKey('ChromiumGPU/linux-release/scrolling_benchmark/' +
                             test_name).get()
        test.improvement_direction = improvement_direction
        test_container_key = utils.GetTestContainerKey(test.key)

        sheriff_key = sheriff_key_key.get()
        if sheriff_key.patterns:
            sheriff_key.patterns.append(test.test_path)
        else:
            sheriff_key.patterns = [test.test_path]
        sheriff_key.put()

        for row in rows:
            graph_data.Row(id=row[0], value=row[1],
                           parent=test_container_key).put()

        # Add test config.
        overridden_config = {
            'min_relative_change': 0.1,
            'min_absolute_change': 10.0
        }
        anomaly_config.AnomalyConfig(id='config_' + test_name,
                                     config=overridden_config,
                                     patterns=[test.test_path]).put()

        test.put()

        return test
Example #8
0
  def testPost_MigratesStoppageAlerts(self):
    testing_common.AddTests(['Master'], ['b'], {'suite': {'foo': {}}})
    test_path = 'Master/b/suite/foo'
    test_key = utils.TestKey(test_path)
    test_container_key = utils.GetTestContainerKey(test_key)
    row_key = graph_data.Row(id=100, parent=test_container_key, value=5).put()
    stoppage_alert.CreateStoppageAlert(test_key.get(), row_key.get()).put()
    self.assertIsNotNone(
        stoppage_alert.GetStoppageAlert('Master/b/suite/foo', 100))
    self.assertIsNone(
        stoppage_alert.GetStoppageAlert('Master/b/suite/bar', 100))

    self.testapp.post('/migrate_test_names', {
        'old_pattern': 'Master/b/suite/foo',
        'new_pattern': 'Master/b/suite/bar',
    })
    self.ExecuteTaskQueueTasks(
        '/migrate_test_names', migrate_test_names._TASK_QUEUE_NAME)

    self.assertIsNotNone(
        stoppage_alert.GetStoppageAlert('Master/b/suite/bar', 100))
    self.assertIsNone(
        stoppage_alert.GetStoppageAlert('Master/b/suite/foo', 100))
Example #9
0
    def testAddRowsToCache(self):
        self._AddMockData()
        rows = []

        stored_object.Set(
            'externally_visible__num_revisions_ChromiumPerf/win7/dromaeo/dom',
            [[10, 2, 3], [15, 4, 5], [100, 6, 7]])

        test_key = utils.TestKey('ChromiumPerf/win7/dromaeo/dom')
        test_container_key = utils.GetTestContainerKey(test_key)
        ts1 = datetime.datetime(2013, 1, 1)
        row1 = graph_data.Row(parent=test_container_key,
                              id=1,
                              value=9,
                              timestamp=ts1)
        rows.append(row1)
        ts2 = datetime.datetime(2013, 1, 2)
        row2 = graph_data.Row(parent=test_container_key,
                              id=12,
                              value=90,
                              timestamp=ts2)
        rows.append(row2)
        ts3 = datetime.datetime(2013, 1, 3)
        row3 = graph_data.Row(parent=test_container_key,
                              id=102,
                              value=99,
                              timestamp=ts3)
        rows.append(row3)
        graph_revisions.AddRowsToCache(rows)

        self.assertEqual(
            [[1, 9, utils.TimestampMilliseconds(ts1)], [10, 2, 3],
             [12, 90, utils.TimestampMilliseconds(ts2)], [15, 4, 5],
             [100, 6, 7], [102, 99, utils.TimestampMilliseconds(ts3)]],
            stored_object.Get('externally_visible__num_revisions_'
                              'ChromiumPerf/win7/dromaeo/dom'))
Example #10
0
 def row(self):
     test_container = utils.GetTestContainerKey(self.test)
     return ndb.Key('Row', self.revision, parent=test_container)
Example #11
0
    def _AddDataToDatastore(self):
        """Puts a set of entities; some internal-only, some not."""
        # Need to be privileged to add TestMetadata and Row objects to the datastore
        # because there is a get() for the parent_test in the pre_put_hook. This
        # should work correctly in production because Rows and TestMetadata should
        # only be added by /add_point, which is privileged.
        self.SetCurrentUser('*****@*****.**')
        testing_common.AddTests(
            ['ChromiumPerf'], ['Win7External', 'FooInternal'], {
                'TestInternal': {
                    'SubTestInternal': {}
                },
                'TestExternal': {
                    'SubTestExternal': {}
                },
            })
        internal_key = ['Master', 'ChromiumPerf', 'Bot', 'FooInternal']
        internal_bot = ndb.Key(*internal_key).get()
        internal_bot.internal_only = True
        internal_bot.put()
        internal_test = ndb.Key(
            'TestMetadata', 'ChromiumPerf/Win7External/TestInternal').get()
        internal_test.internal_only = True
        internal_test.put()
        internal_test = ndb.Key('TestMetadata',
                                'ChromiumPerf/FooInternal/TestInternal').get()
        internal_test.internal_only = True
        internal_test.put()
        internal_sub_test = ndb.Key(
            'TestMetadata',
            'ChromiumPerf/Win7External/TestInternal/SubTestInternal').get()
        internal_sub_test.internal_only = True
        internal_sub_test.put()
        internal_sub_test = ndb.Key(
            'TestMetadata',
            'ChromiumPerf/FooInternal/TestInternal/SubTestInternal').get()
        internal_sub_test.internal_only = True
        internal_sub_test.put()

        internal_key = internal_sub_test.key
        external_key = ndb.Key(
            'TestMetadata',
            'ChromiumPerf/Win7External/TestExternal/SubTestExternal')

        internal_test_container_key = utils.GetTestContainerKey(internal_key)
        external_test_container_key = utils.GetTestContainerKey(external_key)
        for i in range(0, 100, 10):
            graph_data.Row(parent=internal_test_container_key,
                           id=i,
                           value=float(i * 2),
                           internal_only=True).put()
            graph_data.Row(parent=external_test_container_key,
                           id=i,
                           value=float(i * 2)).put()
        self.UnsetCurrentUser()
        sheriff.Sheriff(id='external',
                        email='*****@*****.**',
                        internal_only=False).put()
        sheriff.Sheriff(id='internal',
                        email='*****@*****.**',
                        internal_only=True).put()