예제 #1
0
def _instance(config_instance):
    config_instance_1 = copy.deepcopy(config_instance)

    config_instance_2 = copy.deepcopy(config_instance)
    config_instance_2.config["scenario"]["name"] = "foo"

    return scenarios.Scenarios([config_instance_1, config_instance_2])
예제 #2
0
def scenarios_instance(config_instance):
    config_instance_1 = copy.deepcopy(config_instance)

    config_instance_2 = copy.deepcopy(config_instance)
    config_instance_2.config['scenario']['name'] = 'foo'

    return scenarios.Scenarios([config_instance_1, config_instance_2])
예제 #3
0
파일: test.py 프로젝트: neilus/molecule
def test(ctx, scenario_name, driver_name, __all, destroy):  # pragma: no cover
    """
    Test (lint, destroy, dependency, syntax, create, prepare, converge,
          idempotence, side_effect, verify, destroy).
    """

    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'destroy': destroy,
        'subcommand': subcommand,
        'driver_name': driver_name,
    }

    if __all:
        scenario_name = None

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    s.print_matrix()
    for scenario in s:
        try:
            for term in scenario.sequence:
                base.execute_subcommand(scenario.config, term)
        except SystemExit:
            if destroy == 'always':
                msg = ('An error occured during the test sequence.  '
                       'Cleaning up.')
                LOG.warn(msg)
                base.execute_subcommand(scenario.config, 'destroy')
                util.sysexit()
            raise
예제 #4
0
def matrix(ctx, scenario_name, subcommand):  # pragma: no cover
    """List matrix of steps used to test instances."""
    args = ctx.obj.get("args")
    command_args = {"subcommand": subcommand}

    s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name)
    s.print_matrix()
예제 #5
0
def login(ctx, host, scenario_name):  # pragma: no cover
    """Log in to one instance."""
    args = ctx.obj.get("args")
    subcommand = base._get_subcommand(__name__)
    command_args = {"subcommand": subcommand, "host": host}

    s = scenarios.Scenarios(base.get_configs(args, command_args), scenario_name)
    for scenario in s.all:
        base.execute_subcommand(scenario.config, subcommand)
예제 #6
0
def dependency(ctx, scenario_name):  # pragma: no cover
    """ Mange the role's dependencies. """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
    }

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    for c in s.all:
        Dependency(c).execute()
예제 #7
0
def syntax(ctx, scenario_name):  # pragma: no cover
    """ Use a provisioner to syntax check the role. """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
    }

    s = scenarios.Scenarios(
        base.get_configs(args, command_args), scenario_name)
    for c in s.all:
        Syntax(c).execute()
예제 #8
0
def lint(ctx, scenario_name):  # pragma: no cover
    """ Lint the role. """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
    }

    s = scenarios.Scenarios(
        base.get_configs(args, command_args), scenario_name)
    for c in s.all:
        Lint(c).execute()
예제 #9
0
def destruct(ctx, scenario_name):  # pragma: no cover
    """ Use a provisioner to destruct instances. """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
    }

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    for c in s.all:
        Destruct(c).execute()
예제 #10
0
def verify(ctx, scenario_name):  # pragma: no cover
    """ Run automated tests against instances. """
    args = ctx.obj.get('args')

    command_args = {
        'subcommand': __name__,
    }

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    for c in s.all:
        Verify(c).execute()
예제 #11
0
파일: create.py 프로젝트: shahtab/molecule
def create(ctx, scenario_name, driver_name):  # pragma: no cover
    """ Start instances. """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
        'driver_name': driver_name,
    }

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    for c in s.all:
        Create(c).execute()
예제 #12
0
def login(ctx, host, scenario_name):  # pragma: no cover
    """ Log in to one instance. """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
        'host': host,
    }

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    for c in s.all:
        Login(c).execute()
예제 #13
0
def converge(ctx, scenario_name, ansible_args):  # pragma: no cover
    """ Use the provisioner to configure instances (create, converge). """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
    }

    s = scenarios.Scenarios(base.get_configs(args, command_args, ansible_args),
                            scenario_name)
    s.print_matrix()
    for scenario in s:
        for term in scenario.sequence:
            base.execute_subcommand(scenario.config, term)
예제 #14
0
def dependency(ctx, scenario_name):  # pragma: no cover
    """ Manage the role's dependencies. """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
    }

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    s.print_matrix()
    for scenario in s:
        for term in scenario.sequence:
            base.execute_subcommand(scenario.config, term)
예제 #15
0
def verify(ctx, scenario_name):  # pragma: no cover
    """ Run automated tests against instances. """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
    }

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    s.print_matrix()
    for scenario in s:
        for term in scenario.sequence:
            base.execute_subcommand(scenario.config, term)
예제 #16
0
def converge(ctx, scenario_name):  # pragma: no cover
    """ Use a provisioner to configure instances (create, converge). """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
    }

    s = scenarios.Scenarios(
        base.get_configs(args, command_args), scenario_name)
    for c in s.all:
        for task in c.scenario.converge_sequence:
            command_module = getattr(molecule.command, task)
            command = getattr(command_module, task.capitalize())
            command(c).execute()
예제 #17
0
def side_effect(ctx, scenario_name):  # pragma: no cover
    """ Use the provisioner to perform side-effects to the instances. """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
    }

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    s.print_matrix()
    for scenario in s:
        for term in scenario.sequence:
            base.execute_subcommand(scenario.config, term)
예제 #18
0
def syntax(ctx, scenario_name):  # pragma: no cover
    """ Use the provisioner to syntax check the role. """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
    }

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    s.print_matrix()
    for scenario in s:
        for term in scenario.sequence:
            base.execute_subcommand(scenario.config, term)
예제 #19
0
def idempotence(ctx, scenario_name):  # pragma: no cover
    """
    Use a provisioner to configure the instances and parse the output to
    determine idempotence.
    """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
    }

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    for c in s.all:
        Idempotence(c).execute()
예제 #20
0
파일: destroy.py 프로젝트: shahtab/molecule
def destroy(ctx, scenario_name, driver_name, __all):  # pragma: no cover
    """ Destroy instances. """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
        'driver_name': driver_name,
    }

    if __all:
        scenario_name = None

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    for c in s.all:
        Destroy(c).execute()
예제 #21
0
파일: lint.py 프로젝트: corserp/greet
def lint(ctx, scenario_name):  # pragma: no cover
    """ Lint the role. """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
    }

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    s.print_matrix()
    for scenario in s:
        for action in scenario.sequence:
            scenario.config.action = action
            base.execute_subcommand(scenario.config, action)
예제 #22
0
def create(ctx, scenario_name, driver_name):  # pragma: no cover
    """ Start instances. """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
        'driver_name': driver_name,
    }

    s = scenarios.Scenarios(
        base.get_configs(args, command_args), scenario_name)
    s.print_matrix()
    for scenario in s:
        for term in scenario.sequence:
            base.execute_subcommand(scenario.config, term)
예제 #23
0
def create(ctx, scenario_name, driver_name):  # pragma: no cover
    """ Use the provisioner to start the instances. """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
        'driver_name': driver_name,
    }

    s = scenarios.Scenarios(
        base.get_configs(args, command_args), scenario_name)
    s.print_matrix()
    for scenario in s:
        for action in scenario.sequence:
            scenario.config.action = action
            base.execute_subcommand(scenario.config, action)
예제 #24
0
    def sequence(self):
        """
        Select the sequence based on scenario and subcommand of the provided
        scenario object and returns a list.

        :param scenario: A scenario object.
        :param skipped: An optional bool to include skipped scenarios.
        :return: list
        """
        s = scenarios.Scenarios([self.config])
        matrix = s._get_matrix()

        try:
            return matrix[self.name][self.config.subcommand]
        except KeyError:
            # TODO(retr0h): May change this handling in the future.
            return []
예제 #25
0
def check(ctx, scenario_name):  # pragma: no cover
    """
    Use the provisioner to perform a Dry-Run (destroy, dependency, create,
    prepare, converge).
    """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
    }

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    s.print_matrix()
    for scenario in s:
        for term in scenario.sequence:
            base.execute_subcommand(scenario.config, term)
예제 #26
0
def idempotence(ctx, scenario_name):  # pragma: no cover
    """
    Use the provisioner to configure the instances and parse the output to
    determine idempotence.
    """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
    }

    s = scenarios.Scenarios(
        base.get_configs(args, command_args), scenario_name)
    s.print_matrix()
    for scenario in s:
        for term in scenario.sequence:
            base.execute_subcommand(scenario.config, term)
예제 #27
0
파일: test.py 프로젝트: shahtab/molecule
def test(ctx, scenario_name, driver_name, __all):  # pragma: no cover
    """ Test (destroy, create, converge, lint, verify, destroy). """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
        'driver_name': driver_name,
    }

    if __all:
        scenario_name = None

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    for c in s.all:
        for task in c.scenario.test_sequence:
            command_module = getattr(molecule.command, task)
            command = getattr(command_module, task.capitalize())
            command(c).execute()
예제 #28
0
def cleanup(ctx, scenario_name):  # pragma: no cover
    """
    Use the provisioner to cleanup any changes made to external systems during
    the stages of testing.
    """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
    }

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    s.print_matrix()
    for scenario in s:
        for action in scenario.sequence:
            scenario.config.action = action
            base.execute_subcommand(scenario.config, action)
예제 #29
0
def _instance(config_instance):
    config_instance_1 = copy.deepcopy(config_instance)
    config_instance_1.config['scenario']['name'] = 'two'
    config_instance_1.molecule_file = \
        config_instance_1.molecule_file.replace('default', '02_foo')

    config_instance_2 = copy.deepcopy(config_instance)
    config_instance_2.config['scenario']['name'] = 'one'
    config_instance_2.molecule_file = \
        config_instance_2.molecule_file.replace('default', '01_foo')

    config_instance_3 = copy.deepcopy(config_instance)
    config_instance_3.config['scenario']['name'] = 'three'
    config_instance_3.molecule_file = \
        config_instance_3.molecule_file.replace('default', '03_foo')

    return scenarios.Scenarios(
        [config_instance_1, config_instance_2, config_instance_3])
예제 #30
0
파일: destroy.py 프로젝트: neilus/molecule
def destroy(ctx, scenario_name, driver_name, __all):  # pragma: no cover
    """ Use the provisioner to destroy the instances. """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
        'driver_name': driver_name,
    }

    if __all:
        scenario_name = None

    s = scenarios.Scenarios(base.get_configs(args, command_args),
                            scenario_name)
    s.print_matrix()
    for scenario in s:
        for term in scenario.sequence:
            base.execute_subcommand(scenario.config, term)