def test_MakeListOfPoints_MinimalCase(self): """A very simple test of a call to MakeListOfPoints.""" # The master name is gotten when making the list of points, # so it must be stubbed out here. self.mox.StubOutWithMock(slave_utils, 'GetActiveMaster') slave_utils.GetActiveMaster().AndReturn('MyMaster') self.mox.ReplayAll() actual_points = results_dashboard.MakeListOfPoints( {'bar': { 'traces': { 'baz': ["100.0", "5.0"] }, 'rev': '12345', }}, 'my-bot', 'foo_test', 'my.master', 'Builder', 10, {}) expected_points = [{ 'master': 'MyMaster', 'bot': 'my-bot', 'test': 'foo_test/bar/baz', 'revision': 12345, 'value': '100.0', 'error': '5.0', 'masterid': 'my.master', 'buildername': 'Builder', 'buildnumber': 10, 'supplemental_columns': {}, }] self.assertEqual(expected_points, actual_points)
def test_BlinkUsesTimestamp(self): """Tests that timestamp is used for "revision" for ChromiumWebkit master.""" self.mox.StubOutWithMock(datetime, 'datetime') datetime.datetime.utcnow().AndReturn(FakeDateTime()) self.mox.StubOutWithMock(slave_utils, 'GetActiveMaster') slave_utils.GetActiveMaster().AndReturn('ChromiumWebkit') self.mox.ReplayAll() actual_points = results_dashboard.MakeListOfPoints( { 'bar': { 'traces': { 'baz': ["100.0", "5.0"] }, 'rev': '123456', 'webkit_rev': '23456', } }, 'my-bot', 'foo_test', 'chromium.webkit', 'Builder', 10, {}) expected_points = [{ 'master': 'ChromiumWebkit', 'bot': 'my-bot', 'test': 'foo_test/bar/baz', 'revision': 1375315200, 'value': '100.0', 'error': '5.0', 'masterid': 'chromium.webkit', 'buildername': 'Builder', 'buildnumber': 10, 'supplemental_columns': { 'r_chromium_svn': 123456, 'r_webkit_rev': '23456', }, }] self.assertEqual(expected_points, actual_points)
def test_MakeListOfPoints_TimestampUsedWhenRevisionIsNaN(self): """Tests sending data with a git hash as "revision".""" self.mox.StubOutWithMock(datetime, 'datetime') datetime.datetime.utcnow().AndReturn(FakeDateTime()) self.mox.StubOutWithMock(slave_utils, 'GetActiveMaster') slave_utils.GetActiveMaster().AndReturn('ChromiumPerf') self.mox.ReplayAll() actual_points = results_dashboard.MakeListOfPoints( { 'bar': { 'traces': { 'baz': ["100.0", "5.0"] }, 'rev': '2eca27b067e3e57c70e40b8b95d0030c5d7c1a7f', } }, 'my-bot', 'foo_test', 'chromium.perf', 'Builder', 10, {}) expected_points = [{ 'master': 'ChromiumPerf', 'bot': 'my-bot', 'test': 'foo_test/bar/baz', # Corresponding timestamp for the fake datetime is used. 'revision': 1375315200, 'value': '100.0', 'error': '5.0', 'masterid': 'chromium.perf', 'buildername': 'Builder', 'buildnumber': 10, 'supplemental_columns': { 'r_chromium': '2eca27b067e3e57c70e40b8b95d0030c5d7c1a7f', }, }] self.assertEqual(expected_points, actual_points)
def test_MakeListOfPoints_MinimalCase(self): """A very simple test of a call to MakeListOfPoints.""" # The master name is gotten when making the list of points, # so it must be stubbed out here. self.mox.StubOutWithMock(slave_utils, 'GetActiveMaster') slave_utils.GetActiveMaster().AndReturn('MyMaster') self.mox.ReplayAll() actual_points = results_dashboard.MakeListOfPoints( { 'bar': { 'traces': {'baz': ["100.0", "5.0"]}, 'rev': '307226', } }, 'my-bot', 'foo_test', 'Builder', 10, {}) expected_points = [ { 'master': 'MyMaster', 'bot': 'my-bot', 'test': 'foo_test/bar/baz', 'revision': 307226, 'value': '100.0', 'error': '5.0', 'supplemental_columns': { 'r_commit_pos': 307226, 'a_stdio_uri': ('[Buildbot stdio](http://build.chromium.org/p' '/my.master/builders/Builder/builds/10/steps/' 'foo_test/logs/stdio)') }, } ] self.assertEqual(expected_points, actual_points)
def main(args): # Parse options parser = optparse.OptionParser() parser.add_option('--name') parser.add_option('--results-file') parser.add_option('--output-json-file') parser.add_option('--got-revision-cp') parser.add_option('--build-dir') parser.add_option('--perf-id') parser.add_option('--results-url') parser.add_option('--buildername') parser.add_option('--buildnumber') parser.add_option('--got-webrtc-revision') parser.add_option('--got-v8-revision') parser.add_option('--version') parser.add_option('--git-revision') options, extra_args = parser.parse_args(args) # Validate options. if extra_args: parser.error('Unexpected command line arguments') if not options.perf_id or not options.results_url: parser.error('--perf-id and --results-url are required') main_revision = _GetMainRevision(options.got_revision_cp, options.build_dir) blink_revision = slave_utils.GetBlinkRevision(options.build_dir) revisions = slave_utils.GetPerfDashboardRevisionsWithProperties( options.got_webrtc_revision, options.got_v8_revision, options.version, options.git_revision, main_revision, blink_revision) reference_build = 'reference' in options.name stripped_test_name = options.name.replace('.reference', '') results = {} with open(options.results_file) as f: results = json.load(f) dashboard_json = {} if not 'charts' in results: # These are legacy results. dashboard_json = results_dashboard.MakeListOfPoints( results, options.perf_id, stripped_test_name, options.buildername, options.buildnumber, {}, revisions_dict=revisions) else: dashboard_json = results_dashboard.MakeDashboardJsonV1( results, revisions, stripped_test_name, options.perf_id, options.buildername, options.buildnumber, {}, reference_build) if dashboard_json: if options.output_json_file: with open (options.output_json_file, 'w') as output_file: json.dump(dashboard_json, output_file) if not results_dashboard.SendResults( dashboard_json, options.results_url, options.build_dir): return 1 else: print 'Error: No perf dashboard JSON was produced.' print '@@@STEP_FAILURE@@@' return 1 return 0
def test_MakeListOfPoints_GeneralCase(self): """A test of making a list of points, including all optional data.""" # The master name is gotten when making the list of points, # so it must be stubbed out here. self.mox.StubOutWithMock(slave_utils, 'GetActiveMaster') slave_utils.GetActiveMaster().AndReturn('MyMaster') self.mox.ReplayAll() actual_points = results_dashboard.MakeListOfPoints( { 'bar': { 'traces': { 'bar': ['100.0', '5.0'], 'bar_ref': ['98.5', '5.0'], }, 'rev': '12345', 'git_revision': '46790669f8a2ecd7249ab92418260316b1c60dbf', 'webkit_rev': '6789', 'v8_rev': 'undefined', 'units': 'KB', }, 'x': { 'traces': { 'y': [10.0, 0], }, 'important': ['y'], 'rev': '23456', 'git_revision': '46790669f8a2ecd7249ab92418260316b1c60dbf', 'v8_rev': '2345', 'units': 'count', }, }, 'my-bot', 'foo_test', 'my.master', 'Builder', 10, { 'r_bar': '89abcdef', 'a_stdio_uri': 'http://mylogs.com/Builder/10', # The supplemental columns here are included in all points. }) expected_points = [ { 'master': 'MyMaster', 'bot': 'my-bot', 'test': 'foo_test/bar', # Note that trace name is omitted. 'revision': 12345, 'value': '100.0', 'error': '5.0', 'units': 'KB', 'masterid': 'my.master', 'buildername': 'Builder', 'buildnumber': 10, 'supplemental_columns': { 'r_webkit_rev': '6789', 'r_bar': '89abcdef', 'r_chromium': '46790669f8a2ecd7249ab92418260316b1c60dbf', 'a_stdio_uri': 'http://mylogs.com/Builder/10', # Note that v8 rev is not included since it was 'undefined'. }, }, { 'master': 'MyMaster', 'bot': 'my-bot', 'test': 'foo_test/bar/ref', # Note the change in trace name. 'revision': 12345, 'value': '98.5', 'error': '5.0', 'units': 'KB', 'masterid': 'my.master', 'buildername': 'Builder', 'buildnumber': 10, 'supplemental_columns': { 'r_webkit_rev': '6789', 'r_bar': '89abcdef', 'r_chromium': '46790669f8a2ecd7249ab92418260316b1c60dbf', 'a_stdio_uri': 'http://mylogs.com/Builder/10', }, }, { 'master': 'MyMaster', 'bot': 'my-bot', 'test': 'foo_test/x/y', 'revision': 23456, 'value': 10.0, 'error': 0, 'units': 'count', 'important': True, 'masterid': 'my.master', 'buildername': 'Builder', 'buildnumber': 10, 'supplemental_columns': { 'r_v8_rev': '2345', 'r_bar': '89abcdef', 'r_chromium': '46790669f8a2ecd7249ab92418260316b1c60dbf', 'a_stdio_uri': 'http://mylogs.com/Builder/10', }, }, ] self.assertEqual(expected_points, actual_points)