def main(): parser = argparse.ArgumentParser() parser.add_argument('--json-file', help='Path of json file.') parser.add_argument('--cs-base-url', help='Base url for code search.', default='http://cs.chromium.org') parser.add_argument('--bucket', help='Google storage bucket.', required=True) parser.add_argument('--builder-name', help='Builder name.') parser.add_argument('--build-number', help='Build number.') parser.add_argument('--test-name', help='The name of the test.', required=True) parser.add_argument( '-o', '--output-json', help='(Swarming Merge Script API) ' 'Output JSON file to create.') parser.add_argument( '--build-properties', help='(Swarming Merge Script API) ' 'Build property JSON file provided by recipes.') parser.add_argument( '--summary-json', help='(Swarming Merge Script API) ' 'Summary of shard state running on swarming. ' '(Output of the swarming.py collect ' '--task-summary-json=XXX command.)') parser.add_argument( '--task-output-dir', help='(Swarming Merge Script API) ' 'Directory containing all swarming task results.') parser.add_argument( 'positional', nargs='*', help='output.json from shards.') args = parser.parse_args() if ((args.build_properties is None) == (args.build_number is None or args.builder_name is None)): raise parser.error('Exactly one of build_perperties or ' '(build_number or builder_name) should be given.') if (args.build_number is None) != (args.builder_name is None): raise parser.error('args.build_number and args.builder_name ' 'has to be be given together' 'or not given at all.') if len(args.positional) == 0 and args.json_file is None: if args.output_json: with open(args.output_json, 'w') as f: json.dump({}, f) return if len(args.positional) != 0 and args.json_file: raise parser.error('Exactly one of args.positional and ' 'args.json_file should be given.') if args.build_properties: build_properties = json.loads(args.build_properties) if ((not 'buildnumber' in build_properties) or (not 'buildername' in build_properties)): raise parser.error('Build number/builder name not specified.') build_number = build_properties['buildnumber'] builder_name = build_properties['buildername'] elif args.build_number and args.builder_name: build_number = args.build_number builder_name = args.builder_name if args.positional: if len(args.positional) == 1: json_file = args.positional[0] else: if args.output_json and args.summary_json: standard_gtest_merge.standard_gtest_merge( args.output_json, args.summary_json, args.positional) json_file = args.output_json elif not args.output_json: raise Exception('output_json required by merge API is missing.') else: raise Exception('summary_json required by merge API is missing.') elif args.json_file: json_file = args.json_file if not os.path.exists(json_file): raise IOError('--json-file %s not found.' % json_file) # Link to result details presentation page is a part of the page. result_html_string, dest, result_details_link = result_details( json_file, args.test_name, args.cs_base_url, args.bucket, builder_name, build_number) result_details_link_2 = upload_to_google_bucket( result_html_string.encode('UTF-8'), args.bucket, dest) assert result_details_link == result_details_link_2, ( 'Result details link do not match. The link returned by get_url_link' ' should be the same as that returned by upload.') ui_screenshot_set_link = upload_screenshot_set(json_file, args.test_name, args.bucket, builder_name, build_number) if ui_screenshot_set_link: ui_catalog_url = 'https://chrome-ui-catalog.appspot.com/' ui_catalog_query = urlencode({'screenshot_source': ui_screenshot_set_link}) ui_screenshot_link = '%s?%s' % (ui_catalog_url, ui_catalog_query) if args.output_json: with open(json_file) as original_json_file: json_object = json.load(original_json_file) json_object['links'] = { 'result_details (logcats, flakiness links)': result_details_link } if ui_screenshot_set_link: json_object['links']['ui screenshots'] = ui_screenshot_link with open(args.output_json, 'w') as f: json.dump(json_object, f) else: print('Result Details: %s' % result_details_link) if ui_screenshot_set_link: print('UI Screenshots %s' % ui_screenshot_link)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--json-file', help='Path of json file.') parser.add_argument('--cs-base-url', help='Base url for code search.', default='http://cs.chromium.org') parser.add_argument('--bucket', help='Google storage bucket.', required=True) parser.add_argument('--builder-name', help='Builder name.') parser.add_argument('--build-number', help='Build number.') parser.add_argument('--test-name', help='The name of the test.', required=True) parser.add_argument( '-o', '--output-json', help='(Swarming Merge Script API) ' 'Output JSON file to create.') parser.add_argument( '--build-properties', help='(Swarming Merge Script API) ' 'Build property JSON file provided by recipes.') parser.add_argument( '--summary-json', help='(Swarming Merge Script API) ' 'Summary of shard state running on swarming. ' '(Output of the swarming.py collect ' '--task-summary-json=XXX command.)') parser.add_argument( '--task-output-dir', help='(Swarming Merge Script API) ' 'Directory containing all swarming task results.') parser.add_argument( 'positional', nargs='*', help='output.json from shards.') args = parser.parse_args() if ((args.build_properties is None) == (args.build_number is None or args.builder_name is None)): raise parser.error('Exactly one of build_perperties or ' '(build_number or builder_name) should be given.') if (args.build_number is None) != (args.builder_name is None): raise parser.error('args.build_number and args.builder_name ' 'has to be be given together' 'or not given at all.') if len(args.positional) == 0 and args.json_file is None: if args.output_json: with open(args.output_json, 'w') as f: json.dump({}, f) return elif len(args.positional) != 0 and args.json_file: raise parser.error('Exactly one of args.positional and ' 'args.json_file should be given.') if args.build_properties: build_properties = json.loads(args.build_properties) if ((not 'buildnumber' in build_properties) or (not 'buildername' in build_properties)): raise parser.error('Build number/builder name not specified.') build_number = build_properties['buildnumber'] builder_name = build_properties['buildername'] elif args.build_number and args.builder_name: build_number = args.build_number builder_name = args.builder_name if args.positional: if len(args.positional) == 1: json_file = args.positional[0] else: if args.output_json and args.summary_json: standard_gtest_merge.standard_gtest_merge( args.output_json, args.summary_json, args.positional) json_file = args.output_json elif not args.output_json: raise Exception('output_json required by merge API is missing.') else: raise Exception('summary_json required by merge API is missing.') elif args.json_file: json_file = args.json_file if not os.path.exists(json_file): raise IOError('--json-file %s not found.' % json_file) # Link to result details presentation page is a part of the page. result_html_string, dest, result_details_link = result_details( json_file, args.test_name, args.cs_base_url, args.bucket, builder_name, build_number) result_details_link_2 = upload_to_google_bucket( result_html_string.encode('UTF-8'), args.bucket, dest) assert result_details_link == result_details_link_2, ( 'Result details link do not match. The link returned by get_url_link' ' should be the same as that returned by upload.') ui_screenshot_set_link = upload_screenshot_set(json_file, args.test_name, args.bucket, builder_name, build_number) if ui_screenshot_set_link: ui_catalog_url = 'https://chrome-ui-catalog.appspot.com/' ui_catalog_query = urllib.urlencode( {'screenshot_source': ui_screenshot_set_link}) ui_screenshot_link = '%s?%s' % (ui_catalog_url, ui_catalog_query) if args.output_json: with open(json_file) as original_json_file: json_object = json.load(original_json_file) json_object['links'] = { 'result_details (logcats, flakiness links)': result_details_link } if ui_screenshot_set_link: json_object['links']['ui screenshots'] = ui_screenshot_link with open(args.output_json, 'w') as f: json.dump(json_object, f) else: print 'Result Details: %s' % result_details_link if ui_screenshot_set_link: print 'UI Screenshots %s' % ui_screenshot_link