Example #1
0
    def build_fuzzer_sub_task(task_index: int, params: FuzzerGenTaskParams) -> Task:
        """
        Build a shrub task to run the fuzzer.

        :param task_index: Index of sub task being generated.
        :param params: Parameters describing how tasks should be generated.
        :return: Shrub task to run the fuzzer.
        """
        sub_task_name = taskname.name_generated_task(params.task_name, task_index, params.num_tasks,
                                                     params.variant)

        run_tests_vars = {
            "continue_on_failure": params.continue_on_failure,
            "resmoke_args": params.get_resmoke_args(),
            "resmoke_jobs_max": params.resmoke_jobs_max,
            "should_shuffle": params.should_shuffle,
            "require_multiversion_setup": params.require_multiversion_setup,
            "timeout_secs": params.timeout_secs,
            "task": params.task_name,
            "gen_task_config_location": params.config_location,
            "suite": params.suite,
        }  # yapf: disable

        timeout_info = TimeoutInfo.overridden(timeout=params.timeout_secs)

        commands = [
            timeout_info.cmd,
            FunctionCall("do setup"),
            FunctionCall(CONFIGURE_EVG_CREDENTIALS),
            FunctionCall("setup jstestfuzz"),
            FunctionCall("run jstestfuzz", params.jstestfuzz_params()),
            FunctionCall(RUN_GENERATED_TESTS, run_tests_vars)
        ]

        return Task(sub_task_name, commands, {TaskDependency(ARCHIVE_DIST_TEST_DEBUG_TASK)})
Example #2
0
    def _generate_task(self, sub_task_name: str, sub_suite_name: str, mixed_version_config: str,
                       params: MultiversionGenTaskParams, build_variant: str) -> Task:
        """
        Generate a sub task to be run with the provided suite and  mixed version config.

        :param sub_task_name: Name of task being generated.
        :param sub_suite_name: Name of suite to run.
        :param mixed_version_config: Versions task is being generated for.
        :param params: Parameters for how tasks should be generated.
        :return: Shrub configuration for task specified.
        """
        suite_file = self.gen_task_options.suite_location(f"{sub_suite_name}_{build_variant}.yml")

        run_tests_vars = {
            "resmoke_args": self._build_resmoke_args(suite_file, mixed_version_config, params),
            "task": params.parent_task_name,
            "gen_task_config_location": params.config_location,
        }

        commands = [
            FunctionCall("do setup"),
            # Fetch and download the proper mongod binaries before running multiversion tests.
            FunctionCall("configure evergreen api credentials"),
            FunctionCall("do multiversion setup"),
            FunctionCall("run generated tests", run_tests_vars),
        ]

        return Task(sub_task_name, commands, {TaskDependency("archive_dist_test_debug")})
Example #3
0
def resmoke_commands(
        run_tests_fn_name: str,
        run_tests_vars: Dict[str, Any],
        timeout_info: TimeoutInfo,
        require_multiversion: Optional[bool] = None) -> List[ShrubCommand]:
    """
    Create a list of commands to run a resmoke task.

    :param run_tests_fn_name: Name of function to run resmoke tests.
    :param run_tests_vars: Dictionary of variables to pass to run_tests function.
    :param timeout_info: Timeout info for task.
    :param require_multiversion: Requires downloading Multiversion binaries.
    :return: List of commands to run a resmoke task.
    """
    commands = [
        timeout_info.cmd,
        FunctionCall("do setup"),
        FunctionCall("configure evergreen api credentials")
        if require_multiversion else None,
        FunctionCall("do multiversion setup")
        if require_multiversion else None,
        FunctionCall(run_tests_fn_name, run_tests_vars),
    ]

    return [cmd for cmd in commands if cmd]
    def gen_lint_config():
        targets = ["src", "test"]
        max_hosts = 5
        task_group_name = "lint group"
        variant_name = "lint variant"

        def define_task(target):
            name = f"make-lint-{target}"
            return Task(name, [FunctionCall("run-make", {"target": name})])

        task_group = TaskGroup(
            task_group_name,
            [define_task(target) for target in targets],
            max_hosts=max_hosts,
            setup_group=[
                git_get_project("src").set_type(CommandType.SYSTEM),
                FunctionCall("set-up-credentials"),
            ],
            teardown_group=[
                FunctionCall("attach-test-results"),
                FunctionCall("remove-test-results"),
            ],
        )

        variant = BuildVariant(variant_name).add_task_group(task_group)
        project = ShrubProject({variant})
        return project
def main(expansions_file: str = "expansions.yml",
         output_file: str = "powercycle_tasks.json") -> None:
    """Generate multiple powercycle tasks to run in evergreen."""

    config = make_config(expansions_file)
    build_variant = BuildVariant(config.build_variant)
    for task_name in config.task_names:
        if "skip_compile" in task_name:
            commands, task_dependency = get_skip_compile_setup_commands()
        else:
            commands, task_dependency = get_setup_commands()

        commands.extend([
            FunctionCall("set up remote credentials", config.remote_credentials_vars),
            BuiltInCommand("timeout.update", config.timeout_params),
            FunctionCall("set up EC2 instance", config.set_up_ec2_instance_vars),
            FunctionCall("run powercycle test", config.run_powercycle_vars),
        ])

        build_variant.display_task(
            task_name, {
                Task(
                    name_generated_task(task_name, index, config.num_tasks, config.build_variant),
                    commands, task_dependency)
                for index in range(config.num_tasks)
            }, distros=[config.distro])

    shrub_project = ShrubProject.empty()
    shrub_project.add_build_variant(build_variant)

    write_file(output_file, shrub_project.json())
Example #6
0
 def define_task(index):
     name = f"aggregation_multiversion_fuzzer_{index:03d}"
     return Task(
         name,
         [
             FunctionCall("do setup"),
             FunctionCall("do multiversion setup"),
             FunctionCall(
                 "run jstestfuzz",
                 {
                     "jstestfuzz_var": "--numGeneratedFiles 5",
                     "npm_command": "agg-fuzzer"
                 },
             ),
             FunctionCall(
                 "run tests",
                 {
                     "continue_on_failure": "false",
                     "resmoke_args": "--suites=generational_fuzzer",
                     "should_shuffle": "false",
                     "task_path_suffix": "false",
                     "timeout_secs": "1800",
                 },
             ),
         ],
     ).dependency("compile")
Example #7
0
    def _generate_task(self, sub_suite_file, sub_task_name: str,
                       sub_suite_roots: List[str],
                       timeout_est: TimeoutEstimate,
                       params: ResmokeGenTaskParams, suite: GeneratedSuite,
                       excludes: List[str]) -> ResmokeTask:
        """
        Generate a shrub evergreen config for a resmoke task.

        :param sub_suite_file: Name of the suite file to run in the generated task.
        :param sub_task_name: Name of task to generate.
        :param sub_suite_roots: List of files to run.
        :param timeout_est: Estimated runtime to use for calculating timeouts.
        :param params: Parameters describing how tasks should be generated.
        :param suite: Parent suite being created.
        :param excludes: List of tests to exclude.
        :return: ResmokeTask object describing the task.
        """
        # pylint: disable=too-many-arguments
        LOGGER.debug("Generating task running suite",
                     sub_task_name=sub_task_name,
                     sub_suite_file=sub_suite_file)

        sub_suite_file_path = self.gen_task_options.suite_location(
            sub_suite_file)

        run_tests_vars = self._get_run_tests_vars(
            sub_suite_file_path=sub_suite_file_path,
            suite_file=suite.suite_name,
            task_name=suite.task_name,
            params=params)

        if timeout_est.is_specified():
            build_variant = self.evg_project_config.get_variant(
                suite.build_variant)
            timeout_info = timeout_est.generate_timeout_cmd(
                self.gen_task_options.is_patch, params.repeat_suites,
                build_variant.idle_timeout_factor,
                build_variant.exec_timeout_factor,
                self.gen_task_options.use_default_timeouts)
        else:
            timeout_info = self.gen_task_options.build_defualt_timeout()

        commands = [
            timeout_info.cmd,
            FunctionCall("do setup"),
            FunctionCall(CONFIGURE_EVG_CREDENTIALS),
            FunctionCall(RUN_GENERATED_TESTS, run_tests_vars),
        ]

        shrub_task = Task(sub_task_name, [cmd for cmd in commands if cmd],
                          self._get_dependencies(params))
        return ResmokeTask(shrub_task=shrub_task,
                           resmoke_suite_name=suite.suite_name,
                           execution_task_suite_yaml_path=sub_suite_file_path,
                           execution_task_suite_yaml_name=sub_suite_file,
                           test_list=sub_suite_roots,
                           excludes=excludes)
def get_skip_compile_setup_commands() -> Tuple[List[FunctionCall], set]:
    """Return skip compile setup commands."""
    return [
        FunctionCall("set up venv"),
        FunctionCall("upload pip requirements"),
        FunctionCall("f_expansions_write"),
        FunctionCall("configure evergreen api credentials"),
        FunctionCall("get compiled binaries"),
    ], set()
    def _add_multiversion_commands(
        commands: List[Union[FunctionCall, ShrubCommand]]
    ) -> List[Union[FunctionCall, ShrubCommand]]:
        res = [
            FunctionCall("git get project no modules"),
            FunctionCall("add git tag"),
        ]
        for command in commands:
            res.append(command)

            if hasattr(command,
                       "name") and command.name == CONFIGURE_EVG_CREDENTIALS:
                # Run multiversion setup after getting EVG credentials.
                res.append(FunctionCall(DO_MULTIVERSION_SETUP))
        return res
    def _generate_sub_task(self,
                           mixed_version_config: str,
                           task: str,
                           task_index: int,
                           suite: str,
                           num_suites: int,
                           is_sharded: bool,
                           burn_in_test: Optional[str] = None) -> Task:
        # pylint: disable=too-many-arguments
        """
        Generate a sub task to be run with the provided suite and  mixed version config.

        :param mixed_version_config: mixed version configuration.
        :param task: Name of task.
        :param task_index: Index of task to generate.
        :param suite: Name of suite being generated.
        :param num_suites: Number os suites being generated.
        :param is_sharded: If this is being generated for a sharded configuration.
        :param burn_in_test: If generation is for burn_in, burn_in options to use.
        :return: Shrub configuration for task specified.
        """
        # Create a sub task name appended with the task_index and build variant name.
        task_name = f"{task}_{mixed_version_config}"
        sub_task_name = taskname.name_generated_task(task_name, task_index,
                                                     num_suites,
                                                     self.options.variant)
        gen_task_name = BURN_IN_TASK if burn_in_test is not None else self.task

        run_tests_vars = {
            "resmoke_args":
            _generate_resmoke_args(suite, mixed_version_config, is_sharded,
                                   self.options, burn_in_test),
            "task":
            gen_task_name,
        }

        commands = [
            FunctionCall("do setup"),
            # Fetch and download the proper mongod binaries before running multiversion tests.
            FunctionCall("configure evergreen api credentials"),
            FunctionCall("do multiversion setup"),
            FunctionCall("run generated tests", run_tests_vars),
        ]

        return Task(sub_task_name, commands,
                    {TaskDependency("archive_dist_test_debug")})
Example #11
0
def resmoke_commands(
        run_tests_fn_name: str,
        run_tests_vars: Dict[str, Any],
        timeout_info: TimeoutInfo,
        require_multiversion_setup: Optional[bool] = False
) -> List[ShrubCommand]:
    """
    Create a list of commands to run a resmoke task.

    Used by burn_in* only. Other tasks use a standalone multiversion decorator.

    :param run_tests_fn_name: Name of function to run resmoke tests.
    :param run_tests_vars: Dictionary of variables to pass to run_tests function.
    :param timeout_info: Timeout info for task.
    :param require_multiversion_setup: Requires downloading Multiversion binaries.
    :return: List of commands to run a resmoke task.
    """

    commands = [
        timeout_info.cmd,
        FunctionCall("git get project no modules")
        if require_multiversion_setup else None,
        FunctionCall("add git tag") if require_multiversion_setup else None,
        FunctionCall("do setup"),
        FunctionCall(CONFIGURE_EVG_CREDENTIALS),
        FunctionCall(DO_MULTIVERSION_SETUP)
        if require_multiversion_setup else None,
        FunctionCall(run_tests_fn_name, run_tests_vars),
        FunctionCall("validate resmoke tests runtime"),
    ]

    return [cmd for cmd in commands if cmd]
Example #12
0
 def _update_suite_name(self, commands: List[Union[FunctionCall,
                                                   ShrubCommand]],
                        suite_name: str):
     index, run_test_func = self._find_command(RUN_GENERATED_TESTS,
                                               commands)
     if run_test_func is not None:
         run_test_vars = copy.deepcopy(run_test_func.parameters)
         run_test_vars["suite"] = suite_name
         commands[index] = FunctionCall(RUN_GENERATED_TESTS, run_test_vars)
Example #13
0
def build_fuzzer_sub_task(task_name: str, task_index: int,
                          options: ConfigOptions) -> Task:
    """
    Build a shrub task to run the fuzzer.

    :param task_name: Parent name of task.
    :param task_index: Index of sub task being generated.
    :param options: Options to use for task.
    :return: Shrub task to run the fuzzer.
    """
    sub_task_name = taskname.name_generated_task(task_name, task_index,
                                                 options.num_tasks,
                                                 options.variant)

    run_jstestfuzz_vars = {
        "jstestfuzz_vars":
        "--numGeneratedFiles {0} {1}".format(options.num_files,
                                             options.jstestfuzz_vars),
        "npm_command":
        options.npm_command,
    }
    suite_arg = f"--suites={options.suite}"
    run_tests_vars = {
        "continue_on_failure": options.continue_on_failure,
        "resmoke_args": f"{suite_arg} {options.resmoke_args}",
        "resmoke_jobs_max": options.resmoke_jobs_max,
        "should_shuffle": options.should_shuffle,
        "task_path_suffix": options.use_multiversion,
        "timeout_secs": options.timeout_secs,
        "task": options.name
    }  # yapf: disable

    commands = [
        FunctionCall("do setup"),
        FunctionCall("do multiversion setup")
        if options.use_multiversion else None,
        FunctionCall("setup jstestfuzz"),
        FunctionCall("run jstestfuzz", run_jstestfuzz_vars),
        FunctionCall("run generated tests", run_tests_vars)
    ]
    commands = [command for command in commands if command is not None]

    return Task(sub_task_name, commands, {TaskDependency("compile")})
def get_skip_compile_setup_commands() -> Tuple[List[FunctionCall], set]:
    """Return skip compile setup commands."""
    return [
        BuiltInCommand("manifest.load", {}),
        FunctionCall("git get project"),
        FunctionCall("f_expansions_write"),
        FunctionCall("kill processes"),
        FunctionCall("cleanup environment"),
        FunctionCall("set up venv"),
        FunctionCall("upload pip requirements"),
        FunctionCall("configure evergreen api credentials"),
        FunctionCall("get compiled binaries"),
    ], set()
Example #15
0
def resmoke_commands(
        run_tests_fn_name: str,
        run_tests_vars: Dict[str, Any],
        timeout_info: TimeoutInfo,
        use_multiversion: Optional[str] = None) -> List[ShrubCommand]:
    """
    Create a list of commands to run a resmoke task.

    :param run_tests_fn_name: Name of function to run resmoke tests.
    :param run_tests_vars: Dictionary of variables to pass to run_tests function.
    :param timeout_info: Timeout info for task.
    :param use_multiversion: If True include multiversion setup.
    :return: List of commands to run a resmoke task.
    """
    commands = [
        timeout_info.cmd,
        FunctionCall("do setup"),
        FunctionCall("do multiversion setup") if use_multiversion else None,
        FunctionCall(run_tests_fn_name, run_tests_vars),
    ]

    return [cmd for cmd in commands if cmd]
 def _update_execution_task_suite_info(self,
                                       commands: List[Union[FunctionCall,
                                                            ShrubCommand]],
                                       multiversion_suite_path: str,
                                       old_bin_version: str):
     index, run_test_func = self._find_command(RUN_GENERATED_TESTS,
                                               commands)
     if run_test_func is not None:
         run_test_vars = copy.deepcopy(run_test_func.parameters)
         run_test_vars["suite"] = multiversion_suite_path
         run_test_vars[
             "multiversion_exclude_tags_version"] = old_bin_version
         commands[index] = FunctionCall(RUN_GENERATED_TESTS, run_test_vars)
         return run_test_vars["suite"]
     return None
Example #17
0
    def build_fuzzer_sub_task(task_index: int, params: FuzzerGenTaskParams) -> Task:
        """
        Build a shrub task to run the fuzzer.

        :param task_index: Index of sub task being generated.
        :param params: Parameters describing how tasks should be generated.
        :return: Shrub task to run the fuzzer.
        """
        sub_task_name = taskname.name_generated_task(params.task_name, task_index, params.num_tasks,
                                                     params.variant)

        run_tests_vars = {
            "continue_on_failure": params.continue_on_failure,
            "resmoke_args": params.get_resmoke_args(),
            "resmoke_jobs_max": params.resmoke_jobs_max,
            "should_shuffle": params.should_shuffle,
            "require_multiversion_setup": params.require_multiversion_setup,
            "timeout_secs": params.timeout_secs,
            "task": params.task_name,
            "gen_task_config_location": params.config_location,
            "suite": params.suite,
        }  # yapf: disable

        timeout_info = TimeoutInfo.overridden(timeout=params.timeout_secs)

        commands = []

        if params.require_multiversion_setup:
            commands += [FunctionCall("git get project no modules")]
            commands += [FunctionCall("add git tag")]

        commands += [
            timeout_info.cmd,
            FunctionCall("do setup"),
            FunctionCall("configure evergreen api credentials")
            if params.require_multiversion_setup else None,
            FunctionCall("do multiversion setup") if params.require_multiversion_setup else None,
            FunctionCall("setup jstestfuzz"),
            FunctionCall("run jstestfuzz", params.jstestfuzz_params()),
            FunctionCall("run generated tests", run_tests_vars)
        ]
        commands = [command for command in commands if command is not None]

        return Task(sub_task_name, commands, {TaskDependency(ARCHIVE_DIST_TEST_DEBUG_TASK)})
Example #18
0
    def build_fuzzer_sub_task(task_index: int, params: FuzzerGenTaskParams,
                              version: str) -> Task:
        """
        Build a shrub task to run the fuzzer.

        :param task_index: Index of sub task being generated.
        :param params: Parameters describing how tasks should be generated.
        :param version: Multiversion version to generate against.
        :return: Shrub task to run the fuzzer.
        """
        sub_task_name = taskname.name_generated_task(
            params.get_task_name(version), task_index, params.num_tasks,
            params.variant)

        suite_arg = f"--suites={params.suite}"
        run_tests_vars = {
            "continue_on_failure": params.continue_on_failure,
            "resmoke_args": f"{suite_arg} {params.get_resmoke_args()}",
            "resmoke_jobs_max": params.resmoke_jobs_max,
            "should_shuffle": params.should_shuffle,
            "require_multiversion": params.require_multiversion,
            "timeout_secs": params.timeout_secs,
            "task": params.get_task_name(version),
            "gen_task_config_location": params.config_location,
        }  # yapf: disable

        commands = []

        if params.require_multiversion:
            commands += [FunctionCall("git get project no modules")]

        commands += [
            FunctionCall("do setup"),
            FunctionCall("configure evergreen api credentials")
            if params.require_multiversion else None,
            FunctionCall("do multiversion setup")
            if params.require_multiversion else None,
            FunctionCall("setup jstestfuzz"),
            FunctionCall("run jstestfuzz", params.jstestfuzz_params()),
            FunctionCall("run generated tests", run_tests_vars)
        ]
        commands = [command for command in commands if command is not None]

        return Task(sub_task_name, commands,
                    {TaskDependency("archive_dist_test_debug")})
Example #19
0
    def build_fuzzer_sub_task(task_index: int,
                              params: FuzzerGenTaskParams) -> Task:
        """
        Build a shrub task to run the fuzzer.

        :param task_index: Index of sub task being generated.
        :param params: Parameters describing how tasks should be generated.
        :return: Shrub task to run the fuzzer.
        """
        sub_task_name = taskname.name_generated_task(params.task_name,
                                                     task_index,
                                                     params.num_tasks,
                                                     params.variant)

        run_tests_vars = {
            "continue_on_failure": params.continue_on_failure,
            "resmoke_args": params.get_resmoke_args(),
            "resmoke_jobs_max": params.resmoke_jobs_max,
            "should_shuffle": params.should_shuffle,
            "require_multiversion_setup": params.require_multiversion_setup,
            "timeout_secs": params.timeout_secs,
            "task": params.task_name,
            # This expansion's name was shortened to reduce the overall size of
            # the generated configuration file
            # gtcl = gen_task_config_location
            "gtcl": params.config_location,
            "suite": params.suite,
        }  # yapf: disable

        timeout_info = TimeoutInfo.overridden(timeout=params.timeout_secs)

        commands = [
            timeout_info.cmd,
            FunctionCall("do setup"),
            FunctionCall(CONFIGURE_EVG_CREDENTIALS),
            FunctionCall("setup jstestfuzz"),
            FunctionCall("run jstestfuzz", params.jstestfuzz_params()),
            FunctionCall(RUN_GENERATED_TESTS, run_tests_vars),
            FunctionCall("minimize jstestfuzz")
        ]

        dependencies = {
            TaskDependency(dependency)
            for dependency in params.dependencies
        }

        return Task(sub_task_name, commands, dependencies)
 def define_task(target):
     name = f"make-lint-{target}"
     return Task(name, [FunctionCall("run-make", {"target": name})])
def get_setup_commands() -> Tuple[List[FunctionCall], Set[TaskDependency]]:
    """Return setup commands."""
    return [
        FunctionCall("do setup"),
    ], {TaskDependency("archive_dist_test_debug")}