示例#1
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
示例#2
0
文件: lint.py 项目: bonomali/molecule
def lint(ctx, scenario_name):  # pragma: no cover
    """Lint the role (dependency, lint)."""
    args = ctx.obj.get("args")
    subcommand = base._get_subcommand(__name__)
    command_args = {"subcommand": subcommand}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#3
0
文件: lint.py 项目: t2d/molecule
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}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#4
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}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#5
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}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#6
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}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#7
0
文件: reset.py 项目: fauust/molecule
def reset(ctx, scenario_name):  # pragma: no cover
    """Reset molecule temporary folders."""
    args = ctx.obj.get('args')
    subcommand = base._get_subcommand(__name__)
    command_args = {'subcommand': subcommand}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#8
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}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#9
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
示例#10
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}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#11
0
def converge(ctx, scenario_name, ansible_args):  # pragma: no cover
    """Use the provisioner to configure instances (dependency, create, prepare converge)."""
    args = ctx.obj.get("args")
    subcommand = base._get_subcommand(__name__)
    command_args = {"subcommand": subcommand}

    base.execute_cmdline_scenarios(scenario_name, args, command_args,
                                   ansible_args)
示例#12
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}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#13
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}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#14
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)
示例#15
0
def reset(ctx, scenario_name):  # pragma: no cover
    """Reset molecule temporary folders."""
    args = ctx.obj.get("args")
    subcommand = base._get_subcommand(__name__)
    command_args = {"subcommand": subcommand}

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
    for driver in drivers():
        driver.reset()
示例#16
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,
    }

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#17
0
def check(ctx, scenario_name, parallel):  # 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 = {'parallel': parallel, 'subcommand': subcommand}

    if parallel:
        util.validate_parallel_cmd_args(command_args)

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#18
0
文件: check.py 项目: corserp/greet
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,
    }

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#19
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

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#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)
示例#21
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)
示例#22
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)
示例#23
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)
示例#24
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)
示例#25
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)
示例#26
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)
示例#27
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)
示例#28
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)
示例#29
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)
示例#30
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)
示例#31
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)
示例#32
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)
示例#33
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)
示例#34
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)
示例#35
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)
示例#36
0
def destroy(ctx, scenario_name, driver_name, __all,
            parallel):  # pragma: no cover
    """Use the provisioner to destroy the instances."""
    args = ctx.obj.get("args")
    subcommand = base._get_subcommand(__name__)
    command_args = {
        "parallel": parallel,
        "subcommand": subcommand,
        "driver_name": driver_name,
    }

    if __all:
        scenario_name = None

    if parallel:
        util.validate_parallel_cmd_args(command_args)

    base.execute_cmdline_scenarios(scenario_name, args, command_args)
示例#37
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)
示例#38
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)
示例#39
0
def test_get_subcommand():
    assert 'test_base' == base._get_subcommand(__name__)