def main(paths, pipelines, pipelines_skip, pipeline_tags, infra_provider,
live_log, all_tests, cluster_debug, junit_xml, test):
if bool(all_tests) == bool(test):
raise click.BadOptionUsage(
'Should specify either --test NAME or --all-tests')
if bool(pipelines) and bool(pipelines_skip):
raise click.BadOptionUsage(
'Can not use both --pipelines and --pipelines-skip')
if cluster_debug and (infra_provider == 'aws'):
# FIXME in AC-5210
raise click.BadOptionUsage(
'AWS does not have an automatic cleaner thus debug is forbidden.'
)
with closing(multilogger.init_handler(logger, live_log)) as multilog:
discovered = discover_integration_tests(
paths or [INTEGRATION_TESTS_PATH])
print_msg(u'Discovered tests in:\n{}\n'.format('\n'.join(discovered)))
filtered = _filter_by_infra_provider(registered_pipelines,
infra_provider)
if not pipelines:
# Take effect only if pipelines to run are not set explicitly.
filtered = _filter_by_pipeline_tags(filtered, pipeline_tags)
filtered = _filter_by_include_exclude(filtered, pipelines,
pipelines_skip)
filtered = _filter_by_test_name(filtered, test)
if os.environ.get('BUILD_CLUSTER') != '1' and len(filtered) > 1:
sys.exit('Can not run multiple pipelines without BUILD_CLUSTER')
slots = infra_provider_slots[infra_provider]
print_msg(u'Requested pipelines: {}'.format(len(filtered)))
print_msg(u'Infra provider "{}" slots: {}'.format(infra_provider,
slots))
q_len = int(math.ceil(len(filtered) / float(slots)))
if q_len > 1:
print_msg(u'Pipelines will be queued into slots.')
print_msg(u'Estimated longest queue: {} pipelines'.format(q_len))
with ThreadPoolExecutor(max_workers=slots) as executor:
for pipe, tests in filtered.items():
full_name = u'{}_{}'.format(*pipe)
executor.submit(run_tests_in_a_pipeline,
full_name, tests, cluster_debug)
_print_logs(multilog, live_log)
if junit_xml:
write_junit_xml(junit_xml, test_results)
if test_results.has_any_failures():
sys.exit(1)
run_integration_tests.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录