def testIterTestOutputIsolates(self): job = { 'quests': ['Build', 'Test', 'Get results'], 'state': [ { 'change': Change('src@1234'), 'attempts': [ { 'executions': [ Execution(), # Build Execution(isolate='results1'), # Test Execution() # Get results ] }, { 'executions': [ Execution(), # Build Execution(), # Test (completed but failed) ] }, { 'executions': [ Execution(), # Build Execution(isolate='results3'), # Test Execution(completed=False) # Get results ] } ] }, { 'change': Change('src@1234', patch='crrev.com/c/123'), 'attempts': [ { 'executions': [ Execution(), # Build Execution(isolate='results4'), # Test Execution() # Get results ] }, { 'executions': [ Execution(), # Build Execution(completed=False) # Test ] }, { 'executions': [ Execution(completed=False) # Build ] } ] } ] } self.assertSequenceEqual(list(job_results.IterTestOutputIsolates(job)), [('src@1234', 'results1'), ('src@1234', 'results3'), ('src@1234+crrev.com/c/123', 'results4')])
def DownloadJobResultsAsCsv(job_ids, only_differences, output_file): """Download the perf results of a job as a csv file.""" with open(output_file, 'wb') as f: writer = csv.writer(f) writer.writerow(('job_id', 'change', 'isolate') + histograms_df.COLUMNS) num_rows = 0 for job_id in job_ids: job = pinpoint_service.Job(job_id, with_state=True) os_path = _OsPathFromJob(job) results_file = os_path.join(job['arguments']['benchmark'], 'perf_results.json') print('Fetching results for %s job %s:' % (job['status'].lower(), job_id)) for change_id, isolate_hash in job_results.IterTestOutputIsolates( job, only_differences): print('- isolate: %s ...' % isolate_hash) try: histograms = isolate_service.RetrieveFile( isolate_hash, results_file) except KeyError: logging.warning( 'Skipping over isolate, results not found.') continue for row in histograms_df.IterRows(json.loads(histograms)): writer.writerow((job_id, change_id, isolate_hash) + row) num_rows += 1 print('Wrote data from %d histograms in %s.' % (num_rows, output_file))