コード例 #1
0
 def testPinpointParams_BisectMode_Invalid_RaisesError(self):
   params = {
       'test_path': 'ChromiumPerf/mac/blink_perf/foo/label/bar.html',
       'start_commit': 'abcd1234',
       'end_commit': 'efgh5678',
       'start_repository': 'chromium',
       'end_repository': 'chromium',
       'bug_id': 1,
       'bisect_mode': 'foo',
       'story_filter': '',
   }
   graph_data.TestMetadata(id=params['test_path'],).put()
   with self.assertRaises(pinpoint_request.InvalidParamsError):
     pinpoint_request.PinpointParamsFromBisectParams(params)
コード例 #2
0
 def testSuccess(self):
     self.SetCurrentUserOAuth(testing_common.INTERNAL_USER)
     path = 'm/b/s/m/c'
     test = graph_data.TestMetadata(has_rows=True,
                                    id=path,
                                    improvement_direction=anomaly.DOWN,
                                    units='units')
     test.put()
     key = anomaly.Anomaly(test=test.key, start_revision=1,
                           end_revision=1).put()
     graph_data.Row(id=1, parent=test.key, value=1).put()
     response = self._Post(key=key.urlsafe(), bug=12345)
     self.assertEqual({}, response)
     self.assertEqual(12345, key.get().bug_id)
コード例 #3
0
  def testBotAliases(self):
    test = graph_data.TestMetadata(
        has_rows=True,
        id='master/a/suite/measure',
        improvement_direction=anomaly.DOWN,
        units='units')
    test.UpdateSheriff()
    test.put()
    graph_data.Row(id=10, parent=test.key, value=100).put()

    test = graph_data.TestMetadata(
        has_rows=True,
        id='master/b/suite/measure',
        improvement_direction=anomaly.DOWN,
        units='units')
    test.UpdateSheriff()
    test.put()
    graph_data.Row(id=20, parent=test.key, value=200).put()

    template = {
        'rows': [
            {
                'testSuites': ['suite'],
                'bots': ['master:b'],
                'measurement': 'measure',
                'testCases': [],
            },
        ],
        'statistics': ['avg'],
    }
    report = report_query.ReportQuery(template, [10, 20]).FetchSync()
    stats = histogram_module.RunningStatistics.FromDict(
        report['rows'][0]['data'][10]['statistics'])
    self.assertEqual(100, stats.mean)
    stats = histogram_module.RunningStatistics.FromDict(
        report['rows'][0]['data'][20]['statistics'])
    self.assertEqual(200, stats.mean)
コード例 #4
0
    def testPinpointParams_BisectMode_Functional(self):
        params = {
            'test_path': 'ChromiumPerf/mac/blink_perf/foo/label/bar.html',
            'start_commit': 'abcd1234',
            'end_commit': 'efgh5678',
            'bug_id': 1,
            'bisect_mode': 'functional',
            'story_filter': '',
        }
        graph_data.TestMetadata(id=params['test_path'], ).put()
        results = pinpoint_request.PinpointParamsFromBisectParams(params)

        self.assertEqual('', results['tir_label'])
        self.assertEqual('', results['chart'])
        self.assertEqual('', results['trace'])
コード例 #5
0
  def testGet_WithMaxTestsParam(self):
    master = graph_data.Master(id='XMaster').put()
    graph_data.Bot(id='x-bot', parent=master).put()
    for i in range(20):
      test = graph_data.TestMetadata(id='XMaster/x-bot/xtest-%d' % i).put()
      test_container_key = utils.GetTestContainerKey(test)
      graph_data.Row(parent=test_container_key, id=1, value=1).put()

    response = self.testapp.get(
        '/new_points', {'pattern': '*/*/*', 'max_tests': '12'})

    self.assertIn('matched 20 tests', response.body)
    self.assertIn('first 12 tests', response.body)
    # 12 points across 12 tests, plus one row for the header.
    self.assertEqual(13, len(re.findall(r'<tr>', response.body)))
コード例 #6
0
  def testIgnoreWrongUnits(self):
    test = graph_data.TestMetadata(
        has_rows=True,
        id='master/bot/suite/measure/a',
        improvement_direction=anomaly.DOWN,
        units='units')
    test.UpdateSheriff()
    test.put()
    graph_data.Row(id=10, parent=test.key, value=100).put()

    test = graph_data.TestMetadata(
        has_rows=True,
        id='master/bot/suite/measure/b',
        improvement_direction=anomaly.DOWN,
        units='wrong')
    test.UpdateSheriff()
    test.put()
    graph_data.Row(id=10, parent=test.key, value=100).put()

    template = {
        'rows': [
            {
                'testSuites': ['suite'],
                'bots': ['master:bot'],
                'measurement': 'measure',
                'testCases': ['a', 'b'],
            },
        ],
        'statistics': ['avg'],
    }
    report = report_query.ReportQuery(template, [10]).FetchSync()

    self.assertEqual('units', report['rows'][0]['units'])
    self.assertEqual(1, len(report['rows'][0]['data'][10]['descriptors']))
    self.assertEqual(
        'a', report['rows'][0]['data'][10]['descriptors'][0]['testCase'])
コード例 #7
0
    def _AddLongTestColumns(self, start_rev=15000, end_rev=16500, step=3):
        """Adds test data with long nested sub test to the mock datastore.

    Args:
      start_rev: Starting revision number.
      end_rev: Ending revision number.
      step: Difference between adjacent revisions.
    """
        master = graph_data.Master(id='master')
        master.put()
        bot = graph_data.Bot(id='bot', parent=master.key)
        bot.put()
        test = graph_data.TestMetadata(id='master/bot/suite')
        test.UpdateSheriff()
        test.put()

        rows = []
        path = 'master/bot/suite'
        for sub_name in ['sub1', 'sub2', 'sub3', 'sub4', 'sub5']:
            path = '%s/%s' % (path, sub_name)
            test = graph_data.TestMetadata(id=path,
                                           improvement_direction=anomaly.UP,
                                           has_rows=True)
            test.UpdateSheriff()
            test.put()
            test_container_key = utils.GetTestContainerKey(test.key)
            for i in range(start_rev, end_rev, step):
                row = graph_data.Row(parent=test_container_key,
                                     id=i,
                                     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)
                rows.append(row)
        ndb.put_multi(rows)
コード例 #8
0
    def testPinpointParams_Metric_TIRLabelChartAndTrace(self):
        params = {
            'test_path': 'ChromiumPerf/mac/blink_perf/foo/label/bar.html',
            'start_commit': 'abcd1234',
            'end_commit': 'efgh5678',
            'start_repository': 'chromium',
            'end_repository': 'chromium',
            'bug_id': 1
        }
        graph_data.TestMetadata(id=params['test_path'], ).put()
        results = pinpoint_request.PinpointParamsFromBisectParams(params)

        self.assertEqual('label', results['tir_label'])
        self.assertEqual('foo', results['chart'])
        self.assertEqual('bar.html', results['trace'])
コード例 #9
0
    def testPost_InternalOnly(self):
        self.SetCurrentUser('*****@*****.**')
        self._AddSampleData()
        master_key = ndb.Key('Master', 'Chromium')
        graph_data.Bot(id='internal_mac',
                       parent=master_key,
                       internal_only=True).put()
        t = graph_data.TestMetadata(id='Chromium/internal_mac/internal_test',
                                    internal_only=True)
        t.UpdateSheriff()
        t.put()

        self.testapp.post('/update_test_suites?internal_only=true')

        self.assertEqual(
            {
                'dromaeo': {
                    'mas': {
                        'Chromium': {
                            'mac': False,
                            'win7': False
                        }
                    },
                },
                'internal_test': {
                    'mas': {
                        'Chromium': {
                            'internal_mac': False
                        }
                    },
                },
                'scrolling': {
                    'mas': {
                        'Chromium': {
                            'mac': False,
                            'win7': False
                        }
                    },
                },
                'really': {
                    'mas': {
                        'Chromium': {
                            'mac': False,
                            'win7': False
                        }
                    },
                },
            }, update_test_suites.FetchCachedTestSuites())
コード例 #10
0
    def testPinpointParams_Metric_ChartAndTrace(self):
        params = {
            'test_path': 'ChromiumPerf/mac/blink_perf/foo/http___bar.html',
            'start_commit': 'abcd1234',
            'end_commit': 'efgh5678',
            'bug_id': 1,
            'bisect_mode': 'performance',
            'story_filter': '',
        }
        graph_data.TestMetadata(id=params['test_path'],
                                unescaped_story_name='http://bar.html').put()
        results = pinpoint_request.PinpointParamsFromBisectParams(params)

        self.assertEqual('', results['tir_label'])
        self.assertEqual('foo', results['chart'])
        self.assertEqual('http://bar.html', results['trace'])
コード例 #11
0
ファイル: graph_json_test.py プロジェクト: rexchun/catapult
  def testGetGraphJson_UnSelectedTrace(self):
    self._AddTestColumns(start_rev=15000, end_rev=15050)
    test_key = ndb.Key('TestMetadata', 'ChromiumGPU/win7/dromaeo/jslib')
    rows = graph_data.Row.query(graph_data.Row.parent_test == test_key).fetch()
    for row in rows:
      row.error = 1 + ((row.revision - 15000) * 0.25)
    ndb.put_multi(rows)

    # Insert sub tests to jslib.
    rows = []
    start_rev = 15000
    end_rev = 15050
    for name in ['sub_test_a', 'sub_test_b']:
      sub_test = graph_data.TestMetadata(id='%s/%s' % (test_key.id(), name),
                                         improvement_direction=anomaly.UP,
                                         has_rows=True).put()
      sub_test_container_key = utils.GetTestContainerKey(sub_test)
      for i in range(start_rev, end_rev, 3):
        # Add Rows for one bot with revision numbers that aren't lined up
        # with the other bots.
        row = graph_data.Row(
            parent=sub_test_container_key, id=i, 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)

    paths = list_tests.GetTestsForTestPathDict(
        {
            'ChromiumGPU/win7/dromaeo/jslib': ['jslib'],
        }, False)['tests']
    flot_json_str = graph_json.GetGraphJson(
        paths, rev=15000, num_points=8, is_selected=False)
    flot = json.loads(flot_json_str)

    sub_test_a_index = self._GetSeriesIndex(
        flot, 'ChromiumGPU/win7/dromaeo/jslib/sub_test_a')
    sub_test_b_index = self._GetSeriesIndex(
        flot, 'ChromiumGPU/win7/dromaeo/jslib/sub_test_b')

    self.assertEqual(2, len(flot['data']))
    self.assertEqual(5, len(flot['data'][sub_test_a_index]['data']))
    self.assertEqual(2, len(flot['annotations']['series']))
    self.assertEqual(5, len(flot['annotations'].get(sub_test_a_index).keys()))
    self.assertEqual(5, len(flot['annotations'].get(sub_test_b_index).keys()))
コード例 #12
0
    def testPinpointParams_NoData(self):
        params = {
            'test_path':
            'ChromiumPerf/Android Nexus5X WebView Perf/system_health/foo',
            'start_commit': '1050',
            'end_commit': '1150',
            'bug_id': 1,
            'bisect_mode': 'performance',
            'story_filter': '',
            'pin': '',
        }
        t = graph_data.TestMetadata(id=params['test_path'])
        t.put()

        results = pinpoint_request.PinpointParamsFromBisectParams(params)

        self.assertFalse('comparison_magnitude' in results)
コード例 #13
0
def AddTests(masters, bots, tests_dict):
    """Adds data to the mock datastore.

  Args:
    masters: List of buildbot master names.
    bots: List of bot names.
    tests_dict: Nested dictionary of tests to add; keys are test names
        and values are nested dictionaries of tests to add.
  """
    for master_name in masters:
        master_key = graph_data.Master(id=master_name).put()
        for bot_name in bots:
            graph_data.Bot(id=bot_name, parent=master_key).put()
            for test_name in tests_dict:
                test_path = '%s/%s/%s' % (master_name, bot_name, test_name)
                graph_data.TestMetadata(id=test_path).put()
                _AddSubtest(test_path, tests_dict[test_name])
コード例 #14
0
    def testPinpointParams_Metric_TIRLabelChartAndTrace(self):
        params = {
            'test_path': 'ChromiumPerf/mac/blink_perf/foo/label/bar.html',
            'start_commit': 'abcd1234',
            'end_commit': 'efgh5678',
            'bug_id': 1,
            'bisect_mode': 'performance',
            'story_filter': '',
            'pin': '',
        }
        t = graph_data.TestMetadata(id=params['test_path'], )
        t.UpdateSheriff()
        t.put()
        results = pinpoint_request.PinpointParamsFromBisectParams(params)

        self.assertEqual('label', results['tir_label'])
        self.assertEqual('foo', results['chart'])
        self.assertEqual('bar.html', results['trace'])
コード例 #15
0
ファイル: utils_test.py プロジェクト: SavoBit/catapult
    def _PutEntitiesHalfInternal(self):
        """Puts entities (half internal-only) and returns the keys."""
        master = graph_data.Master(id='M').put()
        graph_data.Bot(parent=master, id='b').put()
        keys = [
            graph_data.TestMetadata(id='M/b/ax', internal_only=True),
            graph_data.TestMetadata(id='M/b/a', internal_only=False),
            graph_data.TestMetadata(id='M/b/b', internal_only=False),
            graph_data.TestMetadata(id='M/b/bx', internal_only=True),
            graph_data.TestMetadata(id='M/b/c', internal_only=False),
            graph_data.TestMetadata(id='M/b/cx', internal_only=True),
            graph_data.TestMetadata(id='M/b/d', internal_only=False),
            graph_data.TestMetadata(id='M/b/dx', internal_only=True),
        ]

        for t in keys:
            t.UpdateSheriff()

        keys = [k.put() for k in keys]

        return keys
コード例 #16
0
 def _AddAnomaly(self, **kargs):
   default = {
       'test': 'master/bot/test_suite/measurement/test_case',
       'start_revision': 0,
       'end_revision': 100,
       'is_improvement': False,
       'median_before_anomaly': 1.1,
       'median_after_anomaly': 1.3,
       'ownership': {
           'component': 'Foo>Bar',
           'emails': ['*****@*****.**', '*****@*****.**'],
       },
   }
   default.update(kargs)
   default['test'] = utils.TestKey(default['test'])
   graph_data.TestMetadata(key=default['test']).put()
   a = anomaly.Anomaly(**default)
   a.groups = alert_group.AlertGroup.GetGroupsForAnomaly(a)
   return a.put()
コード例 #17
0
 def testHasCC(self):
   self.SetCurrentUserOAuth(testing_common.INTERNAL_USER)
   path = 'm/b/s/m/c'
   test = graph_data.TestMetadata(
       has_rows=True,
       id=path,
       improvement_direction=anomaly.DOWN,
       units='units')
   test.put()
   key = anomaly.Anomaly(
       test=test.key,
       start_revision=1,
       end_revision=1).put().urlsafe()
   graph_data.Row(
       id=1,
       parent=test.key,
       value=1).put()
   response = self._Post(key=key, cc='[email protected],[email protected]')
   self.assertEqual(12345, response['bug_id'])
コード例 #18
0
 def _AddSampleTestData(self):
     """Adds some sample data used in the tests below."""
     master = graph_data.Master(id='TheMaster').put()
     graph_data.Bot(id='TheBot', parent=master).put()
     graph_data.TestMetadata(id='TheMaster/TheBot/Suite1').put()
     graph_data.TestMetadata(id='TheMaster/TheBot/Suite2').put()
     graph_data.TestMetadata(id='TheMaster/TheBot/Suite1/aaa',
                             has_rows=True).put()
     graph_data.TestMetadata(id='TheMaster/TheBot/Suite1/bbb',
                             has_rows=True).put()
     graph_data.TestMetadata(id='TheMaster/TheBot/Suite2/ccc',
                             has_rows=True).put()
     graph_data.TestMetadata(id='TheMaster/TheBot/Suite2/ddd',
                             has_rows=True).put()
コード例 #19
0
ファイル: timeseries2_test.py プロジェクト: owatch01/catapult
  def testAnnotations(self):
    test = graph_data.TestMetadata(
        has_rows=True,
        id='master/bot/suite/measure/case',
        improvement_direction=anomaly.DOWN,
        units='units')
    test.UpdateSheriff()
    test.put()
    graph_data.Row(
        parent=test.key, id=1, value=42.0,
        a_trace_uri='http://example.com').put()

    response = self._Post(
        test_suite='suite', measurement='measure', bot='master:bot',
        test_case='case', build_type='test',
        columns='revision,annotations')
    self.assertEqual(1, len(response['data']))
    self.assertEqual(1, response['data'][0][0])
    self.assertEqual('http://example.com',
                     response['data'][0][1]['a_trace_uri'])
コード例 #20
0
  def testPinpointParams_Metric_ChartAndTrace(self):
    testing_common.AddTests(
        ['ChromiumPerf'], ['mac'],
        {'blink_perf': {'foo': {'http___bar.html': {}}}})
    params = {
        'test_path': 'ChromiumPerf/mac/blink_perf/foo/http___bar.html',
        'start_commit': 'abcd1234',
        'end_commit': 'efgh5678',
        'bug_id': 1,
        'bisect_mode': 'performance',
        'story_filter': '',
        'pin': '',
    }
    t = graph_data.TestMetadata(
        id=params['test_path'], unescaped_story_name='http://bar.html')
    t.UpdateSheriff()
    t.put()
    results = pinpoint_request.PinpointParamsFromBisectParams(params)

    self.assertEqual('foo', results['chart'])
    self.assertEqual('http://bar.html', results['trace'])
コード例 #21
0
    def testPinpointParams_OverriddenAnomalyConfig(self):
        testing_common.AddTests(['ChromiumPerf'],
                                ['Android Nexus5X WebView Perf'],
                                {'system_health': {
                                    'foo': {}
                                }})
        params = {
            'test_path':
            'ChromiumPerf/Android Nexus5X WebView Perf/system_health/foo',
            'start_commit': '1051',
            'end_commit': '1151',
            'bug_id': 1,
            'bisect_mode': 'performance',
            'story_filter': '',
            'pin': '',
        }
        a = anomaly_config.AnomalyConfig()
        a.config = {'min_segment_size': 1}
        a.patterns = ['*/*/*/*']
        a.put()

        t = graph_data.TestMetadata(id=params['test_path'])
        t.overridden_anomaly_config = a.key
        t.put()

        rows = dict(
            itertools.chain(
                zip(itertools.islice(itertools.count(1000, 2), 75),
                    itertools.repeat({'value': -100.0})), [(1050, {
                        'value': 0.1
                    })],
                zip(itertools.islice(itertools.count(1101, 2), 50),
                    itertools.repeat({'value': 0.5}))))

        testing_common.AddRows(params['test_path'], rows)
        results = pinpoint_request.PinpointParamsFromBisectParams(params)

        # We overrode the anomaly config with a window of 1, and there's only a
        # single row with value 0.1, the rest are 0.0.
        self.assertEqual(0.4, results['comparison_magnitude'])
コード例 #22
0
  def testMultipleRevisions(self):
    test = graph_data.TestMetadata(
        has_rows=True,
        id='master/bot/suite/measure',
        improvement_direction=anomaly.DOWN,
        units='units')
    test.UpdateSheriff()
    test.put()
    graph_data.Row(error=2, id=10, parent=test.key, value=20).put()
    graph_data.Row(error=3, id=20, parent=test.key, value=30).put()
    graph_data.Row(error=4, id=30, parent=test.key, value=40).put()

    template = {
        'rows': [
            {
                'testSuites': ['suite'],
                'bots': ['master:bot'],
                'measurement': 'measure',
                'testCases': [],
            },
        ],
        'statistics': ['avg', 'std'],
    }
    report = report_query.ReportQuery(template, [10, 20, 30]).FetchSync()

    stats = histogram_module.RunningStatistics.FromDict(
        report['rows'][0]['data'][10]['statistics'])
    self.assertEqual(20, stats.mean)
    self.assertEqual(2, stats.stddev)

    stats = histogram_module.RunningStatistics.FromDict(
        report['rows'][0]['data'][20]['statistics'])
    self.assertEqual(30, stats.mean)
    self.assertEqual(3, stats.stddev)

    stats = histogram_module.RunningStatistics.FromDict(
        report['rows'][0]['data'][30]['statistics'])
    self.assertEqual(40, stats.mean)
    self.assertEqual(4, stats.stddev)
コード例 #23
0
 def testPutTemplate_InternalOnly(self):
   self.SetCurrentUser(testing_common.INTERNAL_USER.email())
   test = graph_data.TestMetadata(
       has_rows=True,
       internal_only=True,
       id='master/internalbot/internalsuite/measure',
       units='units')
   test.put()
   report_template.PutTemplate(
       None, 'foo', [testing_common.INTERNAL_USER.email()], {
           'rows': [
               {
                   'testSuites': ['internalsuite'],
                   'bots': ['master:internalbot'],
                   'measurement': 'measure',
                   'testCases': [],
               },
           ],
       })
   template = report_template.ReportTemplate.query(
       report_template.ReportTemplate.name == 'foo').get()
   self.assertTrue(template.internal_only)
コード例 #24
0
 def testUpgradeOld(self):
   t = graph_data.TestMetadata(
       has_rows=True, id='master/bot/suite/measurement/case')
   t.UpdateSheriff()
   t.put()
   page_state.PageState(id='test_sid', value=json.dumps({
       'charts': [
           [
               ['master/bot/suite/measurement', ['all']],
           ],
       ]})).put()
   response = self.testapp.get('/short_uri', {'sid': 'test_sid', 'v2': 'true'})
   expected = {
       'testSuites': ['suite'],
       'measurements': ['measurement'],
       'bots': ['master:bot'],
       'testCases': ['case'],
   }
   actual = json.loads(response.body)['chartSections'][0]['parameters']
   self.assertEqual(expected, actual)
   self.assertEqual(response.body,
                    ndb.Key('PageState', 'test_sid').get().value_v2)
コード例 #25
0
  def testNewStyleUnsuffixedDataRows(self):
    test = graph_data.TestMetadata(
        has_rows=True,
        id='master/bot/suite/measure',
        improvement_direction=anomaly.DOWN,
        units='units')
    test.UpdateSheriff()
    test.put()
    graph_data.Row(
        error=10,
        id=10,
        parent=test.key,
        d_std=20,
        d_count=30,
        d_min=40,
        d_max=200,
        value=100).put()

    template = {
        'rows': [
            {
                'testSuites': ['suite'],
                'bots': ['master:bot'],
                'measurement': 'measure',
                'testCases': [],
            },
        ],
        'statistics': ['avg', 'std', 'count', 'min', 'max'],
    }
    report = report_query.ReportQuery(template, [10]).FetchSync()

    stats = histogram_module.RunningStatistics.FromDict(
        report['rows'][0]['data'][10]['statistics'])
    self.assertEqual(100, stats.mean)
    self.assertEqual(40, stats.min)
    self.assertEqual(200, stats.max)
    self.assertEqual(20, stats.stddev)
    self.assertEqual(30, stats.count)
コード例 #26
0
    def testPinpointParams_GitHashes(self, mock_commit):
        def _MockCommit(git_sha):
            if git_sha == 'abc':
                return {'number': 1050}
            else:
                return {'number': 1150}

        mock_commit.side_effect = _MockCommit
        testing_common.AddTests(['ChromiumPerf'],
                                ['Android Nexus5X WebView Perf'],
                                {'system_health': {
                                    'foo': {}
                                }})
        params = {
            'test_path':
            'ChromiumPerf/Android Nexus5X WebView Perf/system_health/foo',
            'start_commit': 'abc',
            'end_commit': 'def',
            'bug_id': 1,
            'bisect_mode': 'performance',
            'story_filter': '',
            'pin': '',
        }
        t = graph_data.TestMetadata(id=params['test_path'])
        t.put()

        rows = dict(
            itertools.chain(
                zip(itertools.islice(itertools.count(1000, 2), 50),
                    itertools.repeat({'value': 0.1})),
                zip(itertools.islice(itertools.count(1101, 2), 50),
                    itertools.repeat({'value': 0.5}))))

        testing_common.AddRows(params['test_path'], rows)
        results = pinpoint_request.PinpointParamsFromBisectParams(params)

        self.assertEqual(0.4, results['comparison_magnitude'])
コード例 #27
0
    def testPinpointParams_NoAlert(self):
        params = {
            'test_path':
            'ChromiumPerf/Android Nexus5X WebView Perf/system_health/foo',
            'start_commit': '1051',
            'end_commit': '1151',
            'bug_id': 1,
            'bisect_mode': 'performance',
            'story_filter': '',
            'pin': '',
        }
        t = graph_data.TestMetadata(id=params['test_path'])
        t.put()

        rows = {}
        for i in xrange(1000, 1100, 2):
            rows[i] = {'value': 0.1}
        for i in xrange(1101, 1200, 2):
            rows[i] = {'value': 0.5}

        testing_common.AddRows(params['test_path'], rows)
        results = pinpoint_request.PinpointParamsFromBisectParams(params)

        self.assertEqual(0.4, results['comparison_magnitude'])
コード例 #28
0
def _GetOrCreateTest(name, parent_test_path, properties):
    """Either gets an entity if it already exists, or creates one.

  If the entity already exists but the properties are different than the ones
  specified, then the properties will be updated first. This implies that a
  new point is being added for an existing TestMetadata, so if the TestMetadata
  has been previously marked as deprecated then it can be updated and marked as
  non-deprecated.

  If the entity doesn't yet exist, a new one will be created with the given
  properties.

  Args:
    name: The string ID of the Test to get or create.
    parent_test_path: The test_path of the parent entity.
    properties: A dictionary of properties that should be set.

  Returns:
    An entity (which has already been put).

  Raises:
    datastore_errors.BadRequestError: Something went wrong getting the entity.
  """
    test_path = '%s/%s' % (parent_test_path, name)
    existing = graph_data.TestMetadata.get_by_id(test_path)

    if not existing:
        # Add improvement direction if this is a new test.
        if 'units' in properties and 'improvement_direction' not in properties:
            units = properties['units']
            direction = units_to_direction.GetImprovementDirection(units)
            properties['improvement_direction'] = direction
        elif 'units' not in properties or properties['units'] is None:
            properties['improvement_direction'] = anomaly.UNKNOWN
        else:
            print properties
        new_entity = graph_data.TestMetadata(id=test_path, **properties)
        new_entity.put()
        # TODO(sullivan): Consider putting back Test entity in a scoped down
        # form so we can check if it exists here.
        return new_entity

    # Flag indicating whether we want to re-put the entity before returning.
    properties_changed = False

    if existing.deprecated:
        existing.deprecated = False
        properties_changed = True

    # Special case to update improvement direction from units for TestMetadata
    # entities when units are being updated. If an improvement direction is
    # explicitly provided in the properties, then we can skip this check since it
    # will get overwritten below. Additionally, by skipping we avoid
    # touching the entity and setting off an expensive put() operation.
    if properties.get('improvement_direction') is None:
        units = properties.get('units')
        if units:
            direction = units_to_direction.GetImprovementDirection(units)
            if direction != existing.improvement_direction:
                properties['improvement_direction'] = direction

    # Go through the list of general properties and update if necessary.
    for prop, value in properties.items():
        if (hasattr(existing, prop) and value is not None
                and getattr(existing, prop) != value):
            setattr(existing, prop, value)
            properties_changed = True

    if properties_changed:
        existing.put()
    return existing
コード例 #29
0
  def testEdit_AddPattern(self):
    """Tests changing the patterns list of an existing AnomalyConfig."""
    self.SetCurrentUser('*****@*****.**', is_admin=True)
    master = graph_data.Master(id='TheMaster').put()
    graph_data.Bot(id='TheBot', parent=master).put()
    suite1 = graph_data.TestMetadata(id='TheMaster/TheBot/Suite1')
    suite1.UpdateSheriff()
    suite1 = suite1.put()

    suite2 = graph_data.TestMetadata(id='TheMaster/TheBot/Suite2')
    suite2.UpdateSheriff()
    suite2 = suite2.put()

    test_aaa = graph_data.TestMetadata(
        id='TheMaster/TheBot/Suite1/aaa', has_rows=True)
    test_aaa.UpdateSheriff()
    test_aaa = test_aaa.put()

    test_bbb = graph_data.TestMetadata(
        id='TheMaster/TheBot/Suite1/bbb', has_rows=True)
    test_bbb.UpdateSheriff()
    test_bbb = test_bbb.put()

    test_ccc = graph_data.TestMetadata(
        id='TheMaster/TheBot/Suite1/ccc', has_rows=True)
    test_ccc.UpdateSheriff()
    test_ccc = test_ccc.put()

    test_ddd = graph_data.TestMetadata(
        id='TheMaster/TheBot/Suite2/ddd', has_rows=True)
    test_ddd.UpdateSheriff()
    test_ddd = test_ddd.put()

    anomaly_config.AnomalyConfig(id='1-Suite1-specific', config={'a': 10}).put()
    anomaly_config.AnomalyConfig(id='2-Suite1-general', config={'b': 20}).put()

    self.testapp.post('/edit_anomaly_configs', {
        'add-edit': 'edit',
        'edit-name': '1-Suite1-specific',
        'config': '{"a": 10}',
        'patterns': '*/*/Suite1/aaa',
        'xsrf_token': xsrf.GenerateToken(users.get_current_user()),
    })
    self.ExecuteTaskQueueTasks(
        '/put_entities_task', edit_config_handler._TASK_QUEUE_NAME)
    self.testapp.post('/edit_anomaly_configs', {
        'add-edit': 'edit',
        'edit-name': '2-Suite1-general',
        'config': '{"b": 20}',
        'patterns': '*/*/Suite1/*',
        'xsrf_token': xsrf.GenerateToken(users.get_current_user()),
    })
    self.ExecuteDeferredTasks('default')
    self.ExecuteTaskQueueTasks(
        '/put_entities_task', edit_config_handler._TASK_QUEUE_NAME)

    # The lists of test patterns in the AnomalyConfig entities in the datastore
    # should be set based on what was added in the two requests above.
    self.assertEqual(
        ['*/*/Suite1/*'],
        anomaly_config.AnomalyConfig.get_by_id('2-Suite1-general').patterns)
    self.assertEqual(
        ['*/*/Suite1/aaa'],
        anomaly_config.AnomalyConfig.get_by_id('1-Suite1-specific').patterns)

    # The 1-Suite1-specific config applies instead of the other config
    # because its name comes first according to sort order.
    self.assertEqual(
        '1-Suite1-specific',
        test_aaa.get().overridden_anomaly_config.string_id())
    # The 2-Suite1-specific config applies to the other tests under Suite1.
    self.assertEqual(
        '2-Suite1-general',
        test_bbb.get().overridden_anomaly_config.string_id())
    self.assertEqual(
        '2-Suite1-general',
        test_ccc.get().overridden_anomaly_config.string_id())

    # Note that Suite2/ddd has no config, and nor do the parent tests.
    self.assertIsNone(test_ddd.get().overridden_anomaly_config)
    self.assertIsNone(suite1.get().overridden_anomaly_config)
    self.assertIsNone(suite2.get().overridden_anomaly_config)
コード例 #30
0
    def testIgnoreSuffixedDataRowsMissingAvg(self):
        test = graph_data.TestMetadata(has_rows=True,
                                       id='master/bot/suite/measure_avg/a',
                                       improvement_direction=anomaly.DOWN,
                                       units='units')
        test.put()
        graph_data.Row(id=10, parent=test.key, value=10).put()

        test = graph_data.TestMetadata(has_rows=True,
                                       id='master/bot/suite/measure_std/a',
                                       improvement_direction=anomaly.DOWN,
                                       units='units')
        test.put()
        graph_data.Row(id=10, parent=test.key, value=20).put()

        test = graph_data.TestMetadata(has_rows=True,
                                       id='master/bot/suite/measure_std/b',
                                       improvement_direction=anomaly.DOWN,
                                       units='units')
        test.put()
        graph_data.Row(id=10, parent=test.key, value=20).put()

        test = graph_data.TestMetadata(has_rows=True,
                                       id='master/bot/suite/measure_count/a',
                                       improvement_direction=anomaly.DOWN,
                                       units='count')
        test.put()
        graph_data.Row(id=10, parent=test.key, value=30).put()

        test = graph_data.TestMetadata(has_rows=True,
                                       id='master/bot/suite/measure_count/b',
                                       improvement_direction=anomaly.DOWN,
                                       units='count')
        test.put()
        graph_data.Row(id=10, parent=test.key, value=30).put()

        test = graph_data.TestMetadata(has_rows=True,
                                       id='master/bot/suite/measure_min/a',
                                       improvement_direction=anomaly.DOWN,
                                       units='count')
        test.put()
        graph_data.Row(id=10, parent=test.key, value=4).put()

        test = graph_data.TestMetadata(has_rows=True,
                                       id='master/bot/suite/measure_min/b',
                                       improvement_direction=anomaly.DOWN,
                                       units='count')
        test.put()
        graph_data.Row(id=10, parent=test.key, value=4).put()

        test = graph_data.TestMetadata(has_rows=True,
                                       id='master/bot/suite/measure_max/a',
                                       improvement_direction=anomaly.DOWN,
                                       units='count')
        test.put()
        graph_data.Row(id=10, parent=test.key, value=500).put()

        test = graph_data.TestMetadata(has_rows=True,
                                       id='master/bot/suite/measure_max/b',
                                       improvement_direction=anomaly.DOWN,
                                       units='count')
        test.put()
        graph_data.Row(id=10, parent=test.key, value=500).put()

        template = {
            'rows': [
                {
                    'testSuites': ['suite'],
                    'bots': ['master:bot'],
                    'measurement': 'measure',
                    'testCases': ['a', 'b'],
                },
            ],
            'statistics': ['avg', 'std', 'count'],
        }
        report = report_query.ReportQuery(template, [10]).FetchSync()

        data = report['rows'][0]['data']
        self.assertEqual(1, len(data[10]['descriptors']))
        self.assertEqual('a', data[10]['descriptors'][0]['testCase'])

        stats = histogram_module.RunningStatistics.FromDict(
            report['rows'][0]['data'][10]['statistics'])
        self.assertEqual(10, stats.mean)
        self.assertEqual(4, stats.min)
        self.assertEqual(500, stats.max)
        self.assertEqual(20, stats.stddev)
        self.assertEqual(30, stats.count)
        self.assertEqual(300, stats.sum)