Exemplo n.º 1
0
 def __init__(self, task):
     self._action = task.get('action')
     self._model = task['model']
     self._environment = environment.Environment()
     self._environment.token = task['token']
     self._environment.tenant_id = task['tenant_id']
     self._environment.system_attributes = self._model.get('SystemData', {})
     self._environment.clients = client_manager.ClientManager()
Exemplo n.º 2
0
def run_tests(args):
    provided_pkg_name = args.package
    load_packages_from = args.load_packages_from
    tests_to_run = args.tests

    if not provided_pkg_name:
        msg = _('Package name is required parameter.')
        sys.stderr.write("ERROR: {msg}".format(msg=msg))
        sys.exit(1)

    ks_opts = _validate_keystone_opts(args)

    client = ks_client.Client(**ks_opts)
    test_env = environment.Environment()
    test_env.token = client.auth_token
    test_env.tenant_id = client.auth_tenant_id
    test_env.clients = client_manager.ClientManager(test_env)

    murano_client_factory = lambda: \
        test_env.clients.get_murano_client(test_env)

    # Replace location of loading packages with provided from command line.
    if load_packages_from:
        cfg.CONF.engine.load_packages_from = load_packages_from
    with package_loader.CombinedPackageLoader(murano_client_factory,
                                              client.tenant_id) as pkg_loader:
        engine.get_plugin_loader().register_in_loader(pkg_loader)
        exc = executor.MuranoDslExecutor(pkg_loader, engine.ContextManager(),
                                         test_env)

        package = _load_package(pkg_loader, provided_pkg_name)
        class_to_methods, class_to_obj = _get_all_test_methods(exc, package)

        run_set = _get_methods_to_run(package, tests_to_run, class_to_methods)
        if run_set:
            LOG.debug('Starting test execution.')
        else:
            msg = _('No tests found for execution.')
            LOG.error(msg)
            sys.stderr.write("ERROR: {msg}".format(msg=msg))
            sys.exit(1)

        for pkg_class, methods in run_set.iteritems():
            obj = class_to_obj[pkg_class]
            for m in methods:
                _call_service_method('setUp', exc, obj)
                obj.type.methods[m].usage = 'Action'

                test_env.start()
                try:
                    obj.type.invoke(m, exc, obj, (), {})
                    LOG.debug('\n.....{0}.{1}.....OK'.format(obj.type.name, m))
                    _call_service_method('tearDown', exc, obj)
                except Exception:
                    LOG.exception('\n.....{0}.{1}.....FAILURE\n'
                                  ''.format(obj.type.name, m))
                finally:
                    test_env.finish()
Exemplo n.º 3
0
    def setUp(self):
        super(TestAgentListener, self).setUp()

        # Register Agent class
        self.class_loader.import_class(agent_listener.AgentListener)
        model = om.Object('AgentListenerTests')
        self.runner = self.new_runner(model)
        self.context = yaql.context.Context()
        self.context.set_data(environment.Environment(), '?environment')
Exemplo n.º 4
0
    def __init__(self, model, class_loader):
        if isinstance(model, types.StringTypes):
            model = object_model.Object(model)
        model = object_model.build_model(model)
        if 'Objects' not in model:
            model = {'Objects': model}

        self.executor = executor.MuranoDslExecutor(
            class_loader, environment.Environment())
        self._root = self.executor.load(model)
Exemplo n.º 5
0
    def __init__(self, model, package_loader, functions):
        if isinstance(model, types.StringTypes):
            model = object_model.Object(model)
        model = object_model.build_model(model)
        if 'Objects' not in model:
            model = {'Objects': model}

        self.executor = executor.MuranoDslExecutor(
            package_loader, TestContextManager(functions),
            environment.Environment())
        self._root = self.executor.load(model).object
Exemplo n.º 6
0
    def setUp(self):
        super(TestAgentListener, self).setUp()

        # Register Agent class
        self.package_loader.load_package('io.murano', None).register_class(
            agent_listener.AgentListener)
        model = om.Object(
            'AgentListenerTests')
        self.runner = self.new_runner(model)
        self.context = yaql_integration.create_empty_context()
        self.context[constants.CTX_ENVIRONMENT] = environment.Environment()
Exemplo n.º 7
0
    def __init__(self, task, reporter=None):
        if reporter is None:
            reporter = status_reporter.StatusReporter(task['id'])
        self._action = task.get('action')
        self._model = task['model']
        self._environment = environment.Environment()
        self._environment.token = task['token']
        self._environment.tenant_id = task['tenant_id']
        self._environment.system_attributes = self._model.get('SystemData', {})
        self._reporter = reporter

        self._model_policy_enforcer = enforcer.ModelPolicyEnforcer(
            self._environment)
Exemplo n.º 8
0
 def __init__(self, task):
     self._action = task.get('action')
     self._model = task['model']
     self._environment = environment.Environment()
     self._environment.token = task['token']
     self._environment.tenant_id = task['tenant_id']