Esempio n. 1
0
    def test_task_name_with_build_variant_should_strip_bv_and_sub_task_index(self):
        bv = "enterprise-rhel-80-64-bit-dynamic-required"
        task_name = f"auth_23_{bv}"

        base_task_name = under_test.determine_task_base_name(task_name, bv)

        self.assertEqual("auth", base_task_name)
Esempio n. 2
0
    def test_task_name_without_build_variant_or_subtask_index_should_self(self):
        bv = "enterprise-rhel-80-64-bit-dynamic-required"
        task_name = "auth"

        base_task_name = under_test.determine_task_base_name(task_name, bv)

        self.assertEqual("auth", base_task_name)
def main():
    """Determine the timeout value a task should use in evergreen."""
    parser = argparse.ArgumentParser(description=main.__doc__)

    parser.add_argument("--install-dir",
                        dest="install_dir",
                        required=True,
                        help="Path to bin directory of testable installation")
    parser.add_argument("--task-name",
                        dest="task",
                        required=True,
                        help="Task being executed.")
    parser.add_argument("--suite-name",
                        dest="suite_name",
                        required=True,
                        help="Resmoke suite being run against.")
    parser.add_argument("--build-variant",
                        dest="variant",
                        required=True,
                        help="Build variant task is being executed on.")
    parser.add_argument("--evg-alias",
                        dest="evg_alias",
                        required=True,
                        help="Evergreen alias used to trigger build.")
    parser.add_argument("--timeout",
                        dest="timeout",
                        type=int,
                        help="Timeout to use (in sec).")
    parser.add_argument("--exec-timeout",
                        dest="exec_timeout",
                        type=int,
                        help="Exec timeout to use (in sec).")
    parser.add_argument("--exec-timeout-factor",
                        dest="exec_timeout_factor",
                        type=float,
                        help="Exec timeout factor to use (in sec).")
    parser.add_argument("--out-file",
                        dest="outfile",
                        help="File to write configuration to.")
    parser.add_argument("--timeout-overrides",
                        dest="timeout_overrides_file",
                        default=DEFAULT_TIMEOUT_OVERRIDES,
                        help="File containing timeout overrides to use.")
    parser.add_argument("--evg-api-config",
                        dest="evg_api_config",
                        default=DEFAULT_EVERGREEN_AUTH_CONFIG,
                        help="Evergreen API config file.")
    parser.add_argument("--evg-project-config",
                        dest="evg_project_config",
                        default=DEFAULT_EVERGREEN_CONFIG,
                        help="Evergreen project config file.")

    options = parser.parse_args()

    end_date = datetime.now()
    start_date = end_date - HISTORY_LOOKBACK

    timeout_override = timedelta(
        seconds=options.timeout) if options.timeout else None
    exec_timeout_override = timedelta(
        seconds=options.exec_timeout) if options.exec_timeout else None

    task_name = determine_task_base_name(options.task, options.variant)
    timeout_overrides = TimeoutOverrides.from_yaml_file(
        os.path.expanduser(options.timeout_overrides_file))

    enable_logging(verbose=False)

    def dependencies(binder: inject.Binder) -> None:
        binder.bind(
            EvergreenApi,
            RetryingEvergreenApi.get_api(
                config_file=os.path.expanduser(options.evg_api_config)))
        binder.bind(TimeoutSettings,
                    TimeoutSettings(start_date=start_date, end_date=end_date))
        binder.bind(TimeoutOverrides, timeout_overrides)
        binder.bind(
            EvergreenProjectConfig,
            parse_evergreen_file(os.path.expanduser(
                options.evg_project_config)))
        binder.bind(
            ResmokeProxyService,
            ResmokeProxyService(
                run_options=f"--installDir={shlex.quote(options.install_dir)}")
        )

    inject.configure(dependencies)

    task_timeout_orchestrator = inject.instance(TaskTimeoutOrchestrator)
    task_timeout_orchestrator.determine_timeouts(
        timeout_override, exec_timeout_override, options.outfile, task_name,
        options.variant, options.evg_alias, options.suite_name,
        options.exec_timeout_factor)