Example #1
0
def test_get_configs_calls_verify_scenario_name(
        mocker, config_instance, patched_verify_configs,
        patched_base_filter_configs_for_scenario, patched_scenario_name):
    patched_base_filter_configs_for_scenario.return_value = [config_instance]
    base.get_configs({}, {'scenario_name': 'default'})

    patched_scenario_name.assert_called_once_with(
        patched_base_filter_configs_for_scenario.return_value, 'default')
Example #2
0
def test_get_configs_filter_configs_for_scenario(
    mocker,
    patched_verify_configs,
    patched_base_filter_configs_for_scenario,
    patched_verify_scenario_name,
):
    base.get_configs({}, {'scenario_name': 'default'})

    patched_base_filter_configs_for_scenario.assert_called_once_with(
        'default', [])
Example #3
0
def test(ctx, scenario_name, driver_name, __all, destroy):  # pragma: no cover
    """ Test (destroy, create, converge, lint, verify, destroy). """
    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:
        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
Example #4
0
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
Example #5
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()
Example #6
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)
Example #7
0
def test_get_configs(config_instance):
    molecule_file = config_instance.molecule_file
    data = config_instance.config
    util.write_file(molecule_file, util.safe_dump(data))

    result = base.get_configs({}, {})
    assert 1 == len(result)
    assert isinstance(result, list)
    assert isinstance(result[0], config.Config)
Example #8
0
def test_get_configs(config_instance):
    molecule_file = config_instance.molecule_file
    data = config_instance.config
    util.write_file(molecule_file, util.safe_dump(data))

    result = base.get_configs({}, {})
    assert 1 == len(result)
    assert isinstance(result, list)
    assert isinstance(result[0], config.Config)
Example #9
0
def lint(ctx, scenario_name):  # pragma: no cover
    """ Lint the role. """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
        'scenario_name': scenario_name,
    }

    for c in base.get_configs(args, command_args):
        Lint(c).execute()
Example #10
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__,
        'scenario_name': scenario_name,
    }

    for c in base.get_configs(args, command_args):
        Syntax(c).execute()
Example #11
0
def destruct(ctx, scenario_name):  # pragma: no cover
    """ Use a provisioner to destruct instances. """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
        'scenario_name': scenario_name,
    }

    for c in base.get_configs(args, command_args):
        Destruct(c).execute()
Example #12
0
def dependency(ctx, scenario_name):  # pragma: no cover
    """ Mange the role's dependencies. """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
        'scenario_name': scenario_name,
    }

    for c in base.get_configs(args, command_args):
        Dependency(c).execute()
Example #13
0
def verify(ctx, scenario_name):  # pragma: no cover
    """ Run automated tests against instances. """
    args = ctx.obj.get('args')

    command_args = {
        'subcommand': __name__,
        'scenario_name': scenario_name,
    }

    for c in base.get_configs(args, command_args):
        Verify(c).execute()
Example #14
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,
        'scenario_name': scenario_name,
    }

    for c in base.get_configs(args, command_args):
        Login(c).execute()
Example #15
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()
Example #16
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()
Example #17
0
def create(ctx, scenario_name, driver_name):  # pragma: no cover
    """ Start instances. """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
        'scenario_name': scenario_name,
        'driver_name': driver_name,
    }

    for c in base.get_configs(args, command_args):
        Create(c).execute()
Example #18
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__,
        'scenario_name': scenario_name,
    }

    for c in base.get_configs(args, command_args):
        Idempotence(c).execute()
Example #19
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__,
        'scenario_name': scenario_name,
    }

    for c in base.get_configs(args, command_args):
        for task in c.scenario.converge_sequence:
            command_module = getattr(molecule.command, task)
            command = getattr(command_module, task.capitalize())
            command(c).execute()
Example #20
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)
Example #21
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)
Example #22
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)
Example #23
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)
Example #24
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)
Example #25
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)
Example #26
0
def test(ctx, scenario_name, driver_name):  # pragma: no cover
    """ Test (destroy, create, converge, lint, verify, destroy). """
    args = ctx.obj.get('args')
    command_args = {
        'subcommand': __name__,
        'scenario_name': scenario_name,
        'driver_name': driver_name,
    }

    for c in base.get_configs(args, command_args):
        for task in c.scenario.test_sequence:
            command_module = getattr(molecule.command, task)
            command = getattr(command_module, task.capitalize())
            command(c).execute()
Example #27
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)
Example #28
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)
Example #29
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)
Example #30
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)
Example #31
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)
Example #32
0
def check(ctx, scenario_name):  # pragma: no cover
    """ Use a provisioner to perform a Dry-Run (create, converge, create). """
    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.check_sequence:
            command_module = getattr(molecule.command, task)
            command = getattr(command_module, task.capitalize())
            command(c).execute()
Example #33
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)
Example #34
0
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()
Example #35
0
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)
Example #36
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)
Example #37
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)
Example #38
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)
Example #39
0
def list(ctx, scenario_name, format):  # pragma: no cover
    """ Lists status of instances. """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
        'format': format,
    }

    statuses = []
    s = scenarios.Scenarios(
        base.get_configs(args, command_args), scenario_name)
    for scenario in s:
        statuses.extend(base.execute_subcommand(scenario.config, subcommand))

    headers = [util.title(name) for name in status.get_status()._fields]
    if format == 'simple' or format == 'plain':
        table_format = 'simple'
        if format == 'plain':
            headers = []
            table_format = format
        _print_tabulate_data(headers, statuses, table_format)
    else:
        _print_yaml_data(headers, statuses)
Example #40
0
def test_get_configs_calls_verify_configs(patched_verify_configs):
    base.get_configs({}, {})

    patched_verify_configs.assert_called_once_with([])