Esempio n. 1
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
Esempio n. 2
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
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
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)
Esempio n. 6
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)
Esempio n. 7
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)
Esempio n. 8
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)
Esempio n. 9
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)
Esempio n. 10
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)
Esempio n. 11
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)
Esempio n. 12
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)
Esempio n. 13
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)
Esempio n. 14
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)
Esempio n. 15
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)
Esempio n. 16
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)
Esempio n. 17
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)
Esempio n. 18
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)
Esempio n. 19
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)
Esempio n. 20
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)
Esempio n. 21
0
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)
Esempio n. 22
0
def prepare(ctx, scenario_name, driver_name, force):  # pragma: no cover
    """
    Use the provisioner to prepare the instances into a particular starting
    state.
    """
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {
        'subcommand': subcommand,
        'driver_name': driver_name,
        'force': force,
    }

    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)
Esempio n. 23
0
def list(ctx, scenario_name, format):  # pragma: no cover
    """List 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._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)
Esempio n. 24
0
def list(ctx, scenario_name, format):  # pragma: no cover
    """List 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)
Esempio n. 25
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)
Esempio n. 26
0
def test_execute_subcommand(config_instance):
    # scenario's config.action is mutated in-place for every sequence action,
    # so make sure that is currently set to the executed action
    assert config_instance.action != 'list'
    assert base.execute_subcommand(config_instance, 'list')
    assert config_instance.action == 'list'
Esempio n. 27
0
def test_execute_subcommand(config_instance):
    assert base.execute_subcommand(config_instance, 'list')
Esempio n. 28
0
def test_execute_subcommand(config_instance):
    assert base.execute_subcommand(config_instance, 'list')