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])
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])
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 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()
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 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()
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()
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()
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()
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()
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()
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()
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 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): # 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()
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 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()
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()
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 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 []
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 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()
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 _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])
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)