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
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
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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'
def test_execute_subcommand(config_instance): assert base.execute_subcommand(config_instance, 'list')