def _one_cluster_linear_tests(run_attrs, repo_root, continue_on_error): fail_fast = not continue_on_error if run_attrs.cluster_url and run_attrs.cluster_token: clustinfo.add_running_cluster(run_attrs.cluster_url, run_attrs.cluster_token) else: start_config = launch_ccm_cluster.StartConfig(private_agents=6) clustinfo.start_cluster(start_config) cluster = clustinfo._clusters[0] all_ok = True for framework in fwinfo.get_frameworks(): func = run_test args = framework, cluster, repo_root, fail_fast try: _action_wrapper("Run %s tests" % framework.name, framework, func, *args) except Exception as e: all_ok = False if fail_fast: logger.info( "Some tests failed; aborting early") # TODO paramaterize raise else: logger.info("Tests for % tests failed.", framework.name) return all_ok
def report_failed_actions(): "Do useful things with the recorded successful and failed actions" # These are our data sources cluster_launch_attempts = clustinfo.get_launch_attempts() _ = cluster_launch_attempts for framework in fwinfo.get_frameworks(): actions = framework.actions _ = actions # We actually have no functionality to report them right now. pass
def _one_cluster_linear_tests(run_attrs, repo_root): start_config = launch_ccm_cluster.StartConfig(private_agents=6) clustinfo.start_cluster(start_config) cluster = clustinfo._clusters[0] for framework in fwinfo.get_frameworks(): func = run_test args = framework, cluster, repo_root _action_wrapper("Run %s tests" % framework.name, framework, func, *args)
def build_and_upload(run_attrs=parse_args([])): """ Build a list of framework scheduler and put them at URLs so a cluster can use it. build() and upload()should be two different functions, but that's a project for another day. run_attrs takes defaults from the argument parser with no arguments """ for framework in fwinfo.get_frameworks(): func = build_and_upload_single args = framework, run_attrs _action_wrapper("build %s" % framework.name, framework, func, *args)
def _recover_stub_urls(run_attrs, repo_root): """If run with test_only, acquire the stub_universe urls from the filesystem. Will fail with exception if they're not present. """ for framework in fwinfo.get_frameworks(): url_textfile_path = _make_url_path(framework) try: with open(url_textfile_path) as url_file: stub_url = url_file.read().strip() framework.stub_universe_url = stub_url except: logger.error("Failed to open universe url_file=%s for framework=%s", url_textfile_path, framework.name) raise
def _one_cluster_linear_tests(run_attrs, repo_root): if run_attrs.cluster_url and run_attrs.cluster_token: clustinfo.add_running_cluster(run_attrs.cluster_url, run_attrs.cluster_token) else: start_config = launch_ccm_cluster.StartConfig(private_agents=6) clustinfo.start_cluster(start_config) cluster = clustinfo._clusters[0] for framework in fwinfo.get_frameworks(): func = run_test args = framework, cluster, repo_root _action_wrapper("Run %s tests" % framework.name, framework, func, *args) # we don't handle exceptions here, so any failures will stop us from # getting this far. all_passed = True return all_passed
def _handle_test_completions(): all_tests_ok = True for framework in fwinfo.get_frameworks(): if not framework.running: # never started continue pollval = framework.popen.poll() if pollval == None: # probably still running; try again later continue action_name = "Test %s completed" % framework.name framework.start_action(action_name) logger.info("%s test exit code: %s", framework.name, pollval) if pollval == 0: # test exited with success logger.info("%s tests completed successfully. PASS", framework.name) else: logger.info("%s tests failed. FAILED", framework.name) all_tests_ok = False framework.running = False logger.info("%s unclaiming cluster id %s", framework.name, framework.cluster.cluster_id) framework.cluster.unclaim(framework) framework.cluster = None logger.info("%s test output follows ------------>>>>>>", framework.name) framework.output_file.seek(0) for line in framework.output_file: sys.stdout.buffer.write(line) sys.stdout.flush() framework.output_file.close() logger.info("<<<<<<------------ end %s test output", framework.name) if pollval == 0: framework.finish_action_ok(action_name) else: framework.finish_action_fail(action_name) return all_tests_ok
def emit_junit_xml(): launch_fake_testcases = [] for launch_attempt in clustinfo.get_launch_attempts(): attempt_duration = launch_attempt.end_time - launch_attempt.start_time fake_test = junit_xml.TestCase(launch_attempt.name, elapsed_sec=attempt_duration) if launch_attempt.launch_succeeded: fake_test.stdout = "Launch worked" else: fake_test.add_failure_info("Launch failed") launch_fake_testcases.append(fake_test) launch_suite = junit_xml.TestSuite("Cluster launches", launch_fake_testcases) fake_suites = [] fake_suites.append(launch_suite) for framework in fwinfo.get_frameworks(): framework_testcases = [] for action_name, action in framework.actions.items(): action_duration = action['finish'] - action['start'] fake_test = junit_xml.TestCase(action_name, elapsed_sec=action_duration, stdout=action['stdout'], stderr=action['stderr']) if not action['ok']: message = action['error_message'] if not message: message = "%s failed" % action_name fake_test.add_failure_info(message, action['error_output']) framework_testcases.append(fake_test) framework_suite = junit_xml.TestSuite("%s actions" % framework.name, framework_testcases) fake_suites.append(framework_suite) with open("junit_testpy.xml", "w") as f: junit_xml.TestSuite.to_file(f, fake_suites)
def report_failed_actions(): """Do useful things with the recorded successful and failed actions""" # These are our data sources cluster_launch_attempts = clustinfo.get_launch_attempts() frameworks = fwinfo.get_frameworks() junit_write.emit_junit_xml(cluster_launch_attempts, frameworks)