예제 #1
0
def send_report_to_s3(head_report: Version2Report) -> None:
    job = os.getenv('JOB_BASE_NAME', os.environ.get('CIRCLE_JOB'))
    sha1 = os.environ.get('SHA1', os.environ.get('CIRCLE_SHA1', ''))
    branch = os.environ.get('BRANCH', os.environ.get('CIRCLE_BRANCH', ''))
    now = datetime.datetime.utcnow().isoformat()

    # SHARD_NUMBER and TEST_CONFIG are specific to GHA, as these details would be included in CIRCLE_JOB already
    shard = os.environ.get('SHARD_NUMBER', '')
    test_config = os.environ.get('TEST_CONFIG')

    job_report_dirname = f'{job}{f"-{test_config}" if test_config is not None else ""}{shard}'

    if branch not in ['master', 'nightly'
                      ] and not branch.startswith("release/"):
        pr = os.environ.get('PR_NUMBER',
                            os.environ.get('CIRCLE_PR_NUMBER', 'unknown'))
        key = f'pr_test_time/{pr}/{sha1}/{job_report_dirname}/{now}Z.json.bz2'  # Z meaning UTC
    else:
        key = f'test_time/{sha1}/{job_report_dirname}/{now}Z.json.bz2'  # Z meaning UTC
    obj = get_S3_object_from_bucket('ossci-metrics', key)
    # use bz2 because the results are smaller than gzip, and the
    # compression time penalty we pay is only about half a second for
    # input files of a few megabytes in size like these JSON files, and
    # because for some reason zlib doesn't seem to play nice with the
    # gunzip command whereas Python's bz2 does work with bzip2
    obj.put(Body=bz2.compress(json.dumps(head_report).encode()))
예제 #2
0
def assemble_flaky_test_stats(
        duplicated_tests_by_file: Dict[str, DuplicatedDict]) -> Any:
    flaky_tests = []
    workflow_id = os.environ.get("GITHUB_RUN_ID",
                                 os.environ.get("CIRCLE_WORKFLOW_ID", None))
    for file_name, suite_to_dict in duplicated_tests_by_file.items():
        for suite_name, testcase_to_runs in suite_to_dict.items():
            for testcase_name, list_of_runs in testcase_to_runs.items():
                num_green, num_red = process_intentional_test_runs(
                    list_of_runs)
                if num_green > 0:  # Otherwise, it's likely just a failing test
                    flaky_tests.append({
                        "name": testcase_name,
                        "suite": suite_name,
                        "file": file_name,
                        "num_green": num_green,
                        "num_red": num_red,
                    })
    if len(flaky_tests) > 0:
        # write to RDS
        register_rds_schema("flaky_tests", schema_from_sample(flaky_tests[0]))
        rds_write("flaky_tests", flaky_tests, only_on_master=False)

        # write to S3 to go to Rockset as well
        import uuid
        for flaky_test in flaky_tests:
            flaky_test["workflow_id"] = workflow_id
            key = f"flaky_tests/{workflow_id}/{uuid.uuid4()}.json"
            obj = get_S3_object_from_bucket("ossci-raw-job-status", key)
            obj.put(Body=json.dumps(flaky_test),
                    ContentType="application/json")
예제 #3
0
def write_flaky_test_stats_to_rockset(
        duplicated_tests_by_file: Dict[str, DuplicatedDict]) -> Any:
    flaky_tests = []
    workflow_id = os.environ.get("GITHUB_RUN_ID",
                                 os.environ.get("CIRCLE_WORKFLOW_ID", None))
    for file_name, suite_to_dict in duplicated_tests_by_file.items():
        for suite_name, testcase_to_runs in suite_to_dict.items():
            for testcase_name, list_of_runs in testcase_to_runs.items():
                num_green, num_red = process_intentional_test_runs(
                    list_of_runs)
                if (
                        num_green > 0 and num_red > 0
                ):  # Flaky tests show different results in consecutive reruns
                    flaky_tests.append({
                        "name": testcase_name,
                        "suite": suite_name,
                        "file": file_name,
                        "num_green": num_green,
                        "num_red": num_red,
                    })
    if len(flaky_tests) > 0:
        import uuid

        for flaky_test in flaky_tests:
            flaky_test["job_id"] = os.environ["GHA_WORKFLOW_JOB_ID"]
            flaky_test["workflow_id"] = workflow_id
            key = f"flaky_tests/{workflow_id}/{uuid.uuid4()}.json"
            obj = get_S3_object_from_bucket("ossci-raw-job-status", key)
            obj.put(Body=json.dumps(flaky_test),
                    ContentType="application/json")
예제 #4
0
def send_report_to_s3(head_report: Version2Report) -> None:
    job = os.environ.get('JOB_BASE_NAME')
    sha1 = os.environ.get('CIRCLE_SHA1')
    branch = os.environ.get('CIRCLE_BRANCH', '')
    now = datetime.datetime.utcnow().isoformat()
    if branch not in ['master', 'nightly'] and not branch.startswith("release/"):
        pr = os.environ.get('CIRCLE_PR_NUMBER', 'unknown')
        key = f'pr_test_time/{pr}/{sha1}/{job}/{now}Z.json.bz2'  # Z meaning UTC
    else:
        key = f'test_time/{sha1}/{job}/{now}Z.json.bz2'  # Z meaning UTC
    obj = get_S3_object_from_bucket('ossci-metrics', key)
    # use bz2 because the results are smaller than gzip, and the
    # compression time penalty we pay is only about half a second for
    # input files of a few megabytes in size like these JSON files, and
    # because for some reason zlib doesn't seem to play nice with the
    # gunzip command whereas Python's bz2 does work with bzip2
    obj.put(Body=bz2.compress(json.dumps(head_report).encode()))
예제 #5
0
def send_report_to_s3(head_report: Version2Report) -> None:
    job = os.getenv("JOB_BASE_NAME", os.environ.get("CIRCLE_JOB"))
    sha1 = os.environ.get("SHA1", os.environ.get("CIRCLE_SHA1", ""))
    now = datetime.datetime.utcnow().isoformat()

    # SHARD_NUMBER and TEST_CONFIG are specific to GHA, as these details would be included in CIRCLE_JOB already
    shard = os.environ.get("SHARD_NUMBER", "")
    test_config = os.environ.get("TEST_CONFIG")

    job_report_dirname = (
        f'{job}{f"-{test_config}" if test_config is not None else ""}{shard}')
    key = f"test_time/{sha1}/{job_report_dirname}/{now}Z.json.bz2"  # Z meaning UTC
    obj = get_S3_object_from_bucket("ossci-metrics", key)
    # use bz2 because the results are smaller than gzip, and the
    # compression time penalty we pay is only about half a second for
    # input files of a few megabytes in size like these JSON files, and
    # because for some reason zlib doesn't seem to play nice with the
    # gunzip command whereas Python's bz2 does work with bzip2
    obj.put(Body=bz2.compress(json.dumps(head_report).encode()))