Exemplo n.º 1
0
    def __init__(self, app):
        """Load or copy config file."""
        self._config_file = fs.join(app.user_dir, self.FILE_NAME)

        if not os.path.exists(self._config_file):
            copy2(resource_path('regions.yml'), self._config_file)

        self._config = yaml_load(self._config_file)
Exemplo n.º 2
0
    def __init__(self, filename, app):
        """Load content."""
        self._app = app
        self._filename = filename
        self._original_content = yaml_load(filename)

        self._content = copy.deepcopy(self._original_content)
        TestCaseValidator(self._content, filename).validate()
        self._content = self._prepare_content()
Exemplo n.º 3
0
    def __init__(self, app):
        self._app = app

        self.config_file = fs.join(app.user_dir, 'bindings.yml')
        # TODO atomically
        if not os.path.exists(self.config_file):
            # setting up the default config
            copy2(resource_path('bindings.yml'), self.config_file)

        # TODO validate
        self._config = yaml_load(self.config_file)
Exemplo n.º 4
0
    def __init__(self, app, run_id: str):
        self._app = app
        self.run_id = run_id

        # install terraform and terraform-inventory
        TerraformInstaller(storage_path=app.installation_dir).install()
        TerraformInventoryInstaller(
            storage_path=app.installation_dir).install()

        self._testcase = TestCase(fs.join(self._dir, 'testcase.yml'), app)
        self._meta = yaml_load(fs.join(self._dir, 'meta.yml'))
Exemplo n.º 5
0
    def __init__(self, filename):
        self.filename = filename

        self._content = yaml_load(filename)
        try:
            jsonschema.validate(self._content, self.__class__._TESTCASE_SCHEMA)
        except jsonschema.ValidationError as e:
            raise TankTestCaseError(
                'Failed to validate testcase {}'.format(filename), e)

        for name, cfg in self._content['instances'].items():
            if name.lower() == 'monitoring':
                raise TankTestCaseError(
                    '\'monitoring\' instance name is reserved')
            if isinstance(cfg, int):
                self._content['instances'][name] = {
                    'count': cfg,
                    'type': 'small'
                }
Exemplo n.º 6
0
    def dependency(self):
        """
        Install Ansible roles from Galaxy or SCM.
        """
        with self._lock:
            ansible_deps = yaml_load(
                resource_path('ansible', 'ansible-requirements.yml'))

            ansible_deps.extend(
                AnsibleBinding(self._app,
                               self._testcase.binding).get_dependencies())

            requirements_file = fs.join(self._dir, 'ansible-requirements.yml')
            yaml_dump(requirements_file, ansible_deps)

            sh.Command("ansible-galaxy")("install",
                                         "-f",
                                         "-r",
                                         requirements_file,
                                         _env=self._make_env(),
                                         _out=sys.stdout,
                                         _err=sys.stderr)
Exemplo n.º 7
0
 def _validate_schema(self):
     """Validate via JSON schema."""
     try:
         Draft4Validator(yaml_load(self.SCHEMA_FILE)).validate(self._content)
     except ValidationError as e:
         raise TankTestCaseError('Failed to validate testcase {}'.format(self._filename), e)
Exemplo n.º 8
0
    def __init__(self, app, run_id: str):
        self._app = app
        self.run_id = run_id

        self._testcase = TestCase(fs.join(self._dir, 'testcase.yml'))
        self._meta = yaml_load(fs.join(self._dir, 'meta.yml'))