Ejemplo n.º 1
0
    def test_existing_file_can_be_overriden(self, mock_write_file,
                                            mock_exists):
        mock_exists.return_value = True

        under_test.write_file_to_dir("dir", "file", "contents", overwrite=True)

        mock_write_file.assert_called()
Ejemplo n.º 2
0
    def write_to_dir(self, directory: str) -> None:
        """
        Write this file to the given directory.

        :param directory: Directory to write file to.
        """
        write_file_to_dir(directory, self.file_name, self.content)
Ejemplo n.º 3
0
def burn_in(task_expansions: Dict[str, Any], evg_conf: EvergreenProjectConfig,
            evergreen_api: RetryingEvergreenApi, repos: Iterable[Repo]):
    """Execute Main program."""
    shrub_project = ShrubProject.empty()
    build_variant_map = _create_evg_build_variant_map(task_expansions,
                                                      evg_conf)
    _generate_evg_tasks(evergreen_api, shrub_project, task_expansions,
                        build_variant_map, repos, evg_conf)

    write_file_to_dir(CONFIG_DIRECTORY, CONFIG_FILE, shrub_project.json())
Ejemplo n.º 4
0
    def test_existing_file_can_cause_exception(self, mock_write_file,
                                               mock_exists):
        mock_exists.return_value = True

        with self.assertRaises(FileExistsError):
            under_test.write_file_to_dir("dir",
                                         "file",
                                         "contents",
                                         overwrite=False)

        mock_write_file.assert_not_called()
Ejemplo n.º 5
0
    def run(self) -> None:
        """Generate multiversion suites that run within a specified target execution time."""
        if not generate_resmoke.should_tasks_be_generated(self.evg_api, self.options.task_id):
            LOGGER.info("Not generating configuration due to previous successful generation.")
            return

        build_variant = BuildVariant(self.options.variant)
        self.generate_evg_tasks(build_variant)

        shrub_project = ShrubProject.empty()
        shrub_project.add_build_variant(build_variant)
        write_file_to_dir(CONFIG_DIR, f"{self.task}.json", shrub_project.json())
Ejemplo n.º 6
0
def write_file_dict(directory: str, file_dict: Dict[str, str]) -> None:
    """
    Write files in the given dictionary to disk.

    The keys of the dictionary should be the filenames to write and the values should be
    the contents to write to each file.

    If the given directory does not exist, it will be created.

    :param directory: Directory to write files to.
    :param file_dict: Dictionary of files to write.
    """
    for name, contents in file_dict.items():
        write_file_to_dir(directory, name, contents)
Ejemplo n.º 7
0
def burn_in(task_expansions: Dict[str, Any], evg_conf: EvergreenProjectConfig,
            evergreen_api: RetryingEvergreenApi, repos: List[Repo]):
    """
    Execute main program.

    :param task_expansions: Dictionary of expansions for the running task.
    :param evg_conf: Evergreen configuration.
    :param evergreen_api: Evergreen.py object.
    :param repos: Git repositories.
    """
    shrub_project = ShrubProject.empty()
    build_variant_map = _create_evg_build_variant_map(task_expansions,
                                                      evg_conf)
    _generate_evg_tasks(evergreen_api, shrub_project, task_expansions,
                        build_variant_map, repos, evg_conf)

    write_file_to_dir(CONFIG_DIRECTORY, CONFIG_FILE, shrub_project.json())
Ejemplo n.º 8
0
def burn_in(task_expansions: Dict[str, Any], evg_conf: EvergreenProjectConfig,
            evergreen_api: RetryingEvergreenApi, repos: List[Repo],
            install_dir: str):
    """
    Execute main program.

    :param task_expansions: Dictionary of expansions for the running task.
    :param evg_conf: Evergreen configuration.
    :param evergreen_api: Evergreen.py object.
    :param repos: Git repositories.
    :param install_dir: path to bin directory of a testable installation
    """
    shrub_project = ShrubProject.empty()
    build_variant_map = _create_evg_build_variant_map(task_expansions)
    _generate_evg_tasks(evergreen_api, shrub_project, task_expansions,
                        build_variant_map, repos, evg_conf, install_dir)

    if not validate_task_generation_limit(shrub_project):
        sys.exit(1)
    write_file_to_dir(CONFIG_DIRECTORY, CONFIG_FILE, shrub_project.json())
Ejemplo n.º 9
0
def main():
    """Generate fuzzer tests to run in evergreen."""
    parser = argparse.ArgumentParser(description=main.__doc__)

    parser.add_argument(
        "--expansion-file",
        dest="expansion_file",
        type=str,
        help="Location of expansions file generated by evergreen.")
    parser.add_argument("--num-files",
                        dest="num_files",
                        type=int,
                        help="Number of files to generate per task.")
    parser.add_argument("--num-tasks",
                        dest="num_tasks",
                        type=int,
                        help="Number of tasks to generate.")
    parser.add_argument("--resmoke-args",
                        dest="resmoke_args",
                        help="Arguments to pass to resmoke.")
    parser.add_argument("--npm-command",
                        dest="npm_command",
                        help="npm command to run for fuzzer.")
    parser.add_argument("--jstestfuzz-vars",
                        dest="jstestfuzz_vars",
                        help="options to pass to jstestfuzz.")
    parser.add_argument("--name",
                        dest="name",
                        help="name of task to generate.")
    parser.add_argument("--variant",
                        dest="build_variant",
                        help="build variant to generate.")
    parser.add_argument(
        "--use-multiversion",
        dest="task_path_suffix",
        help="Task path suffix for multiversion generated tasks.")
    parser.add_argument("--continue-on-failure",
                        dest="continue_on_failure",
                        help="continue_on_failure value for generated tasks.")
    parser.add_argument("--resmoke-jobs-max",
                        dest="resmoke_jobs_max",
                        help="resmoke_jobs_max value for generated tasks.")
    parser.add_argument("--should-shuffle",
                        dest="should_shuffle",
                        help="should_shuffle value for generated tasks.")
    parser.add_argument("--timeout-secs",
                        dest="timeout_secs",
                        help="timeout_secs value for generated tasks.")
    parser.add_argument("--suite",
                        dest="suite",
                        help="Suite to run using resmoke.")

    options = parser.parse_args()

    config_options = _get_config_options(options, options.expansion_file)
    build_variant = BuildVariant(config_options.variant)
    create_fuzzer_task(config_options, build_variant)

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

    write_file_to_dir(CONFIG_DIRECTORY, f"{config_options.name}.json",
                      shrub_project.json())