Exemple #1
0
    def setUp(self):
        super(EngineTestCase, self).setUp()

        # Get transport here to let oslo.messaging setup default config
        # before changing the rpc_backend to the fake driver; otherwise,
        # oslo.messaging will throw exception.
        messaging.get_transport(cfg.CONF)

        # Set the transport to 'fake' for Engine tests.
        cfg.CONF.set_default('rpc_backend', 'fake')

        # Drop all RPC objects (transport, clients).
        rpc.cleanup()
        transport = rpc.get_transport()

        self.engine_client = rpc.get_engine_client()
        self.executor_client = rpc.get_executor_client()

        self.engine = def_eng.DefaultEngine(self.engine_client)
        self.executor = def_exec.DefaultExecutor(self.engine_client)

        LOG.info("Starting engine and executor threads...")

        self.threads = [
            eventlet.spawn(launch_engine_server, transport, self.engine),
            eventlet.spawn(launch_executor_server, transport, self.executor),
        ]

        self.addOnException(self.print_executions)

        # Start scheduler.
        scheduler_thread_group = scheduler.setup()

        self.addCleanup(self.kill_threads)
        self.addCleanup(scheduler_thread_group.stop)
Exemple #2
0
def launch_executor(transport):
    target = messaging.Target(topic=cfg.CONF.executor.topic,
                              server=cfg.CONF.executor.host)

    executor_v2 = def_executor.DefaultExecutor(rpc.get_engine_client())

    endpoints = [rpc.ExecutorServer(executor_v2)]

    server = messaging.get_rpc_server(transport,
                                      target,
                                      endpoints,
                                      executor='eventlet',
                                      serializer=ctx.RpcContextSerializer(
                                          ctx.JsonPayloadSerializer()))

    executor_v2.register_membership()

    try:
        server.start()
        while True:
            time.sleep(604800)
    except (KeyboardInterrupt, SystemExit):
        pass
    finally:
        print("Stopping executor service...")
        server.stop()
        server.wait()
Exemple #3
0
def _run_at_target(action_ex_id,
                   action_class_str,
                   attributes,
                   action_params,
                   target=None,
                   async_=True,
                   safe_rerun=False):
    # We'll just call executor directly for testing purposes.
    executor = default_executor.DefaultExecutor()

    executor.run_action(action_ex_id, action_class_str, attributes,
                        action_params, safe_rerun)
Exemple #4
0
def launch_executor(transport):
    target = messaging.Target(topic=cfg.CONF.executor.topic,
                              server=cfg.CONF.executor.host)

    executor_v2 = def_executor.DefaultExecutor(rpc.get_engine_client())

    endpoints = [rpc.ExecutorServer(executor_v2)]

    server = messaging.get_rpc_server(transport,
                                      target,
                                      endpoints,
                                      executor='eventlet',
                                      serializer=ctx.RpcContextSerializer(
                                          ctx.JsonPayloadSerializer()))

    server.start()
    server.wait()
Exemple #5
0
def launch_executor():
    profiler.setup('mistral-executor', cfg.CONF.executor.host)

    executor_v2 = def_executor.DefaultExecutor(rpc.get_engine_client())
    executor_endpoint = rpc.ExecutorServer(executor_v2)

    executor_server = rpc.get_rpc_server_driver()(
        rpc_utils.get_rpc_info_from_oslo(CONF.executor))
    executor_server.register_endpoint(executor_endpoint)

    executor_v2.register_membership()

    try:
        executor_server.run(executor='threading')
    except (KeyboardInterrupt, SystemExit):
        pass
    finally:
        print("Stopping executor service...")
          task_name: task2
        publish:
          slogan: >
            <% task(task1).result.final_result %> is a cool <% env().var4 %>!
"""


def _run_at_target(action_ex_id,
                   action_class_str,
                   attributes,
                   action_params,
                   target=None,
                   async=True,
                   safe_rerun=False):
    # We'll just call executor directly for testing purposes.
    executor = default_executor.DefaultExecutor(rpc.get_engine_client())

    executor.run_action(action_ex_id, action_class_str, attributes,
                        action_params, safe_rerun)


MOCK_RUN_AT_TARGET = mock.MagicMock(side_effect=_run_at_target)


class EnvironmentTest(base.EngineTestCase):
    def setUp(self):
        super(EnvironmentTest, self).setUp()

        wb_service.create_workbook_v2(WORKBOOK)

    @mock.patch.object(rpc.ExecutorClient, 'run_action', MOCK_RUN_AT_TARGET)
import mock

from mistral.db.v2 import api as db_api
from mistral.engine import default_executor
from mistral.engine.rpc_backend import rpc
from mistral.services import workflows as wf_service
from mistral.tests.unit.engine import base
from mistral.workflow import data_flow
from mistral.workflow import states


def _run_at_target(action_ex_id, action_class_str, attributes,
                   action_params, target=None, async=True, safe_rerun=False):
    # We'll just call executor directly for testing purposes.
    executor = default_executor.DefaultExecutor()

    executor.run_action(
        action_ex_id,
        action_class_str,
        attributes,
        action_params,
        safe_rerun,
        redelivered=True
    )


MOCK_RUN_AT_TARGET = mock.MagicMock(side_effect=_run_at_target)


class TestSafeRerun(base.EngineTestCase):
Exemple #8
0
def get_oslo_service(setup_profiler=True):
    return ExecutorServer(default_executor.DefaultExecutor(),
                          setup_profiler=setup_profiler)