示例#1
0
def test_mutable_pod(runtime):
    args = set_pod_parser().parse_args(['--runtime', runtime, '--parallel', '2'])

    with MutablePod(BasePod(args).peas_args):
        pass

    MutablePod(BasePod(args).peas_args).start().close()
示例#2
0
def test_pod_context(runtime):
    args = set_pod_parser().parse_args(['--runtime', runtime,
                                        '--parallel', '2',
                                        '--max-idle-time', '5',
                                        '--shutdown-idle'])
    with BasePod(args) as bp:
        bp.join()

    BasePod(args).start().close()
示例#3
0
def test_ssh_mutable_pod():
    p = set_pod_parser().parse_args(
        ['--host', '[email protected]', '--timeout', '5000'])
    p = BasePod(p)
    with SSHRuntime(p, kind='pod') as pp:
        assert pp.status.envelope.status.code == jina_pb2.StatusProto.READY

    assert pp.status is None
示例#4
0
def test_pod_naming_with_parallel(runtime):
    args = set_pod_parser().parse_args(
        ['--name', 'pod', '--parallel', '2', '--runtime-backend', runtime])
    with BasePod(args) as bp:
        assert bp.peas[0].name == 'pod/head'
        assert bp.peas[1].name == 'pod/tail'
        assert bp.peas[2].name == 'pod/1'
        assert bp.peas[3].name == 'pod/2'
        assert bp.peas[0].runtime.name == 'pod/head/ZEDRuntime'
        assert bp.peas[1].runtime.name == 'pod/tail/ZEDRuntime'
        assert bp.peas[2].runtime.name == 'pod/1/ZEDRuntime'
        assert bp.peas[3].runtime.name == 'pod/2/ZEDRuntime'
示例#5
0
def test_local_runtime_naming_with_parallel():
    args = set_pod_parser().parse_args([
        '--name', 'pod', '--parallel', '2', '--max-idle-time', '5',
        '--shutdown-idle'
    ])
    with BasePod(args) as bp:
        assert bp.runtimes[0].name == 'runtime-pod-head'
        assert bp.runtimes[1].name == 'runtime-pod-tail'
        assert bp.runtimes[2].name == 'runtime-pod-1'
        assert bp.runtimes[3].name == 'runtime-pod-2'
        assert bp.runtimes[0].pea.name == 'pod-head'
        assert bp.runtimes[1].pea.name == 'pod-tail'
        assert bp.runtimes[2].pea.name == 'pod-1'
        assert bp.runtimes[3].pea.name == 'pod-2'
示例#6
0
def test_pod_gracefully_close_idle():
    import time
    args = set_pod_parser().parse_args(['--name', 'pod',
                                        '--parallel', '2',
                                        '--max-idle-time', '4',
                                        '--shutdown-idle'])

    start_time = time.time()
    with BasePod(args) as bp:
        while not bp.is_shutdown:
            time.sleep(1.5)

    end_time = time.time()
    elapsed_time = end_time - start_time
    assert elapsed_time > 4
示例#7
0
def test_logging_pod(monkeypatch):
    from fluent import asynchandler as fluentasynchandler

    def mock_emit(obj, record):
        msg = obj.format(record)

        ct = msg['context']
        if ct not in ['JINA', 'PROFILE', 'BaseExecutor']:
            assert msg['log_id'] == 'logging_id'
        if msg['name'] == 'gateway':
            assert 'log_id' in msg

    monkeypatch.setattr(fluentasynchandler.FluentHandler, "emit", mock_emit)

    args = set_pod_parser().parse_args(['--identity', 'logging_id'])
    with BasePod(args):
        pass
示例#8
0
def test_pod_status():
    args = set_pod_parser().parse_args(['--parallel', '3'])
    with BasePod(args) as p:
        assert len(p.status) == p.num_peas
        for v in p.status:
            assert v
示例#9
0
def test_pod_context(runtime):
    args = set_pod_parser().parse_args(['--runtime', runtime, '--parallel', '2'])
    with BasePod(args):
        pass

    BasePod(args).start().close()