def __init__(self): self.command_ref = {} discover.import_modules_from_package("cloudpulse.scenario.plugins") for scenario_group in discover.itersubclasses(base.Scenario): for method in dir(scenario_group): scenario = scenario_group() callback = getattr(scenario, method) self.command_ref[method] = callback
def get_rpc_resource_detail(resource, resource_ident): resource = getattr(objects, resource) test = resource.get_by_uuid(pecan.request.context, resource_ident) discover.import_modules_from_package("cloudpulse.scenario.plugins") for scenario_group in discover.itersubclasses(base.Scenario): for method in dir(scenario_group): if test['name'] == method: scenario = scenario_group() callback = getattr(scenario, 'verbose') return callback()
def __init__(self): self.command_ref = {} self.conductor_id = '1' discover.import_modules_from_package("cloudpulse.scenario.plugins") for scenario_group in discover.itersubclasses(base.Scenario): for method in dir(scenario_group): LOG.debug( ('Adding test %s from %s') % (method, scenario_group)) scenario = scenario_group() callback = getattr(scenario, method) self.command_ref[method] = callback
def __init__(self): self.command_ref = {} self.conductor_id = '1' discover.import_modules_from_package("cloudpulse.scenario.plugins") for scenario_group in discover.itersubclasses(base.Scenario): for method in dir(scenario_group): LOG.debug(('Adding test %s from %s') % (method, scenario_group)) scenario = scenario_group() callback = getattr(scenario, method) self.command_ref[method] = callback
def list_all_scenarios(scenario_cls): """Lists all the existing methods in the operator scenario classes. Returns the method names in format <Class name>.<Method name>, which is used in the test config. :returns: List of strings """ scenario_classes = (list(discover.itersubclasses(scenario_cls)) + [scenario_cls]) scenarios_list = [[ "%s.%s" % (scenario.__name__, func) for func in dir(scenario) if Scenario.is_scenario(scenario, func) ] for scenario in scenario_classes] scenarios_list_flat = list( itertools.chain.from_iterable(scenarios_list)) return scenarios_list_flat
def list_all_scenarios(scenario_cls): """Lists all the existing methods in the operator scenario classes. Returns the method names in format <Class name>.<Method name>, which is used in the test config. :returns: List of strings """ scenario_classes = (list(discover.itersubclasses(scenario_cls)) + [scenario_cls]) scenarios_list = [ ["%s.%s" % (scenario.__name__, func) for func in dir(scenario) if Scenario.is_scenario(scenario, func)] for scenario in scenario_classes ] scenarios_list_flat = list( itertools.chain.from_iterable(scenarios_list)) return scenarios_list_flat
def create_test(self, values): # ensure that the test name is valid discover.import_modules_from_package("cloudpulse.scenario.plugins") plugins = discover.itersubclasses(base.Scenario) if not any(values['name'] in dir(scenario) for scenario in plugins): raise exception.TestInvalid(test=values['name']) # ensure defaults are present for new tests if not values.get('uuid'): values['uuid'] = utils.generate_uuid() cpulse = models.cpulse() cpulse.update(values) # TODO(VINOD) try: cpulse.save() except db_exc.DBDuplicateEntry: raise exception.TestAlreadyExists(uuid=values['uuid']) return cpulse
def all_tests(self): enabled_scenarios = cfg.CONF.scenario.enabled_scenarios all_cases = [] result = 200 resultmsg = '' discover.import_modules_from_package("cloudpulse.scenario.plugins") for scenario_group in discover.itersubclasses(base.Scenario): if scenario_group.__name__ in enabled_scenarios: all_cases += [getattr(scenario_group(), method) for method in dir(scenario_group) if method.startswith("all")] for func in all_cases: try: funres = func() except Exception as e: funres = [404, str(e)] if funres[0] != 200: resultmsg += ("%s\n\n" % (funres[1])) result = 404 if not resultmsg: resultmsg = "All Tests passed" return (result, resultmsg)
def all_tests(self): enabled_scenarios = cfg.CONF.scenario.enabled_scenarios all_cases = [] result = 200 resultmsg = '' discover.import_modules_from_package("cloudpulse.scenario.plugins") for scenario_group in discover.itersubclasses(base.Scenario): if scenario_group.__name__ in enabled_scenarios: all_cases += [ getattr(scenario_group(), method) for method in dir(scenario_group) if method.startswith("all") ] for func in all_cases: try: funres = func() except Exception as e: funres = [404, str(e)] if funres[0] != 200: resultmsg += ("%s\n\n" % (funres[1])) result = 404 if not resultmsg: resultmsg = "All Tests passed" return (result, resultmsg)
def get_by_name(name): """Returns Scenario class by name.""" for scenario in discover.itersubclasses(Scenario): if name == scenario.__name__: return scenario raise exception.NoSuchScenario(name=name)