Example #1
0
    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)
        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()))
 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])
   path_list = list_tests.GetTestsForTestPathDict(
       {p: [] for p in test_paths}, False)['tests']
   response = graph_json.GetGraphJson(path_list, is_selected=False)
   self.assertEqual(
       {'data': {}, 'annotations': {}, 'error_bars': {}},
       json.loads(response))