Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(505)

Side by Side Diff: infra/services/builder_alerts/__main__.py

Issue 2150983004: Count flakiness pipeline issue tracker requests (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse 6 import argparse
7 import contextlib 7 import contextlib
8 import cStringIO 8 import cStringIO
9 import datetime 9 import datetime
10 import gzip 10 import gzip
11 import json 11 import json
12 import logging 12 import logging
13 import multiprocessing 13 import multiprocessing
14 import os 14 import os
15 import sys 15 import sys
16 import traceback 16 import traceback
17 17
18 import requests 18 import requests
19 import requests_cache 19 import requests_cache
20 20
21 from infra_libs import logs 21 from infra_libs import logs
22 from infra_libs import ts_mon
22 from infra.libs.service_utils import outer_loop 23 from infra.libs.service_utils import outer_loop
23 24
24 from infra.services.builder_alerts import alert_builder 25 from infra.services.builder_alerts import alert_builder
25 from infra.services.builder_alerts import analysis 26 from infra.services.builder_alerts import analysis
26 from infra.services.builder_alerts import buildbot 27 from infra.services.builder_alerts import buildbot
27 from infra.services.builder_alerts import crbug_issues 28 from infra.services.builder_alerts import crbug_issues
28 from infra.services.builder_alerts import gatekeeper_extras 29 from infra.services.builder_alerts import gatekeeper_extras
29 from infra.services.builder_alerts import string_helpers 30 from infra.services.builder_alerts import string_helpers
30 31
31 32
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 parser.add_argument('data_url', action='store', nargs='*') # Deprecated 352 parser.add_argument('data_url', action='store', nargs='*') # Deprecated
352 parser.add_argument('--use-cache', action='store_true') 353 parser.add_argument('--use-cache', action='store_true')
353 parser.add_argument('--master-filter', action='store') 354 parser.add_argument('--master-filter', action='store')
354 parser.add_argument('--builder-filter', action='store') 355 parser.add_argument('--builder-filter', action='store')
355 parser.add_argument('--processes', default=PARALLEL_TASKS, action='store', 356 parser.add_argument('--processes', default=PARALLEL_TASKS, action='store',
356 type=int) 357 type=int)
357 parser.add_argument('--jobs', default=CONCURRENT_TASKS, action='store', 358 parser.add_argument('--jobs', default=CONCURRENT_TASKS, action='store',
358 type=int) 359 type=int)
359 logs.add_argparse_options(parser) 360 logs.add_argparse_options(parser)
360 outer_loop.add_argparse_options(parser) 361 outer_loop.add_argparse_options(parser)
362 ts_mon.add_argparse_options(parser)
361 363
362 gatekeeper_json = os.path.join(build_scripts_dir, 'slave', 'gatekeeper.json') 364 gatekeeper_json = os.path.join(build_scripts_dir, 'slave', 'gatekeeper.json')
363 parser.add_argument('--gatekeeper', action='store', default=gatekeeper_json) 365 parser.add_argument('--gatekeeper', action='store', default=gatekeeper_json)
364 gatekeeper_trees_json = os.path.join(build_scripts_dir, 'slave', 366 gatekeeper_trees_json = os.path.join(build_scripts_dir, 'slave',
365 'gatekeeper_trees.json') 367 'gatekeeper_trees.json')
366 parser.add_argument('--gatekeeper-trees', action='store', 368 parser.add_argument('--gatekeeper-trees', action='store',
367 default=gatekeeper_trees_json) 369 default=gatekeeper_trees_json)
368 370
369 parser.add_argument('--findit-api-url', 371 parser.add_argument('--findit-api-url',
370 help='Query findit results from this url.') 372 help='Query findit results from this url.')
371 parser.add_argument('--crbug-service-account', 373 parser.add_argument('--crbug-service-account',
372 help='Path to a service account JSON file to be used to ' 374 help='Path to a service account JSON file to be used to '
373 'search for relevant issues on crbug.com.') 375 'search for relevant issues on crbug.com.')
374 parser.add_argument('--api-endpoint-prefix', 376 parser.add_argument('--api-endpoint-prefix',
375 help='Endpoint prefix for posting alerts. Old API ' 377 help='Endpoint prefix for posting alerts. Old API '
376 'endpoint will be formed by adding value specified ' 378 'endpoint will be formed by adding value specified '
377 'in --old-api-path to the prefix, new API endpoints ' 379 'in --old-api-path to the prefix, new API endpoints '
378 'will be formed by adding ' 380 'will be formed by adding '
379 '/api/v1/alerts/<tree_name>.') 381 '/api/v1/alerts/<tree_name>.')
380 parser.add_argument('--old-api-path', 382 parser.add_argument('--old-api-path',
381 help='Path to be appended to --api-endpoint-prefix to ' 383 help='Path to be appended to --api-endpoint-prefix to '
382 'form old API endpoint.') 384 'form old API endpoint.')
383 385
384 args = parser.parse_args(args) 386 args = parser.parse_args(args)
385 logs.process_argparse_options(args) 387 logs.process_argparse_options(args)
386 loop_args = outer_loop.process_argparse_options(args) 388 loop_args = outer_loop.process_argparse_options(args)
389 ts_mon.process_argparse_options(args)
387 390
388 # TODO(sergiyb): Remove support for data_url when builder_alerts recipes are 391 # TODO(sergiyb): Remove support for data_url when builder_alerts recipes are
389 # updated and using new syntax to call this script. 392 # updated and using new syntax to call this script.
390 if args.data_url: 393 if args.data_url:
391 if (len(args.data_url) == 1 and args.data_url[0].endswith('alerts') and 394 if (len(args.data_url) == 1 and args.data_url[0].endswith('alerts') and
392 not args.api_endpoint_prefix and not args.old_api_path): 395 not args.api_endpoint_prefix and not args.old_api_path):
393 logging.warn( 396 logging.warn(
394 'You are using positional argument to specify URL to post updates ' 397 'You are using positional argument to specify URL to post updates '
395 'to. Please use --api-endpoint-prefix and --old-api-path instead.') 398 'to. Please use --api-endpoint-prefix and --old-api-path instead.')
396 slash_index = args.data_url[0].rindex('/') 399 slash_index = args.data_url[0].rindex('/')
(...skipping 20 matching lines...) Expand all
417 _ConnectionpoolFilter()) 420 _ConnectionpoolFilter())
418 421
419 def outer_loop_iteration(): 422 def outer_loop_iteration():
420 return inner_loop(args) 423 return inner_loop(args)
421 424
422 loop_results = outer_loop.loop( 425 loop_results = outer_loop.loop(
423 task=outer_loop_iteration, 426 task=outer_loop_iteration,
424 sleep_timeout=lambda: 5, 427 sleep_timeout=lambda: 5,
425 **loop_args) 428 **loop_args)
426 429
430 ts_mon.flush()
427 return 0 if loop_results.success else 1 431 return 0 if loop_results.success else 1
428 432
429 433
430 if __name__ == '__main__': 434 if __name__ == '__main__':
431 sys.exit(main(sys.argv[1:])) 435 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « appengine/chromium_try_flakes/issue_tracker/issue_tracker_api.py ('k') | infra/services/builder_alerts/crbug_issues.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698