示例#1
0
def task_manager_for(global_config,
                     channel_name,
                     ch_config=None,
                     src_workers=None):
    if ch_config is None:
        ch_config = channel_config(channel_name)
    # If the channel name is not specified in the configuration, we
    # add a random string onto the end so that we can inspect log
    # files from tests that all use "test_channel.jsonnet"--the suffix
    # ensures that we avoid file collisions.
    channel_name = ch_config.get("channel_name",
                                 channel_name + "-" + random_suffix())
    if src_workers is None:
        _, src_workers = source_workers(channel_name, ch_config["sources"])
    keys = [worker.key for worker in src_workers.values()]
    module_workers = validated_workflow(channel_name, src_workers, ch_config)
    return TaskManager(
        channel_name,
        module_workers,
        DataSpace(global_config),
        source_products(module_workers["sources"]),
        exchange=_EXCHANGE,
        broker_url=_BROKER_URL,
        routing_keys=keys,
    )
示例#2
0
def test_taskmanager_channel_name_in_config(global_config):
    for channel in _TEST_CHANNEL_NAMES2:
        task_manager = TaskManager(channel, 1, get_channel_config(channel),
                                   global_config)
        assert task_manager.name == "name_in_config"
示例#3
0
def test_failing_publisher(global_config):
    task_manager = TaskManager("failing_publisher", 1,
                               get_channel_config("failing_publisher"),
                               global_config)
    task_manager.run()
    assert task_manager.state.has_value(State.OFFLINE)
示例#4
0
def test_taskmanager_init(global_config):
    for channel in _TEST_CHANNEL_NAMES:
        task_manager = TaskManager(channel, 1, get_channel_config(channel),
                                   global_config)
        assert task_manager.state.has_value(State.BOOT)
示例#5
0
 def __init__(self, global_config, channel):
     self._tm = TaskManager(channel, 1, get_channel_config(channel),
                            global_config)
     self._thread = threading.Thread(name=channel, target=self._tm.run)
def task_manager_for(name):
    return TaskManager(name, 1, channel_config(name), _global_config)
def test_multiple_logic_engines_not_supported(global_config):
    with pytest.raises(RuntimeError, match="Cannot support more than one logic engine per channel."):
        channel = "multiple_logic_engines"
        TaskManager(channel, get_channel_config(channel), global_config)
示例#8
0
def task_manager(global_config):
    task_manager = TaskManager(channel, get_channel_config(channel),
                               global_config)
    yield task_manager

    gc.collect()