Esempio n. 1
0
def test_start_remote_server(srv_port, pub_port):
    host, ssh_port = os.getenv(SSH_HOST_VAR), os.getenv(SSH_PORT_VAR, 22)
    user, pwd = os.getenv(SSH_USER_VAR), os.getenv(SSH_PWD_VAR)
    key = os.getenv(SSH_KEY_VAR)

    if not all([host, ssh_port, user, key or pwd]):
        pytest.skip(
            "To run this test specify "
            f"{SSH_HOST_VAR}, {SSH_USER_VAR} {SSH_PWD_VAR} or {SSH_KEY_VAR} and optionaly {SSH_PORT_VAR}"
        )

    conn_conf = TCPConnConf(socket.gethostbyname(host),
                            srv_port,
                            pub_port,
                            timeout=20)
    cred = SSHCred(user=user, password=pwd, key_path=key)
    launcher = RemoteSSHServerLauncher(conn_conf, cred=cred)
    client = Client(IFlightControl(), conn_conf)
    try:
        launcher.start()

        assert launcher.is_server_running()

        assert client.ping() == b"pong"
    finally:
        launcher.stop()

    assert not launcher.is_server_running()
Esempio n. 2
0
def test_start_local_server(srv_port, pub_port):
    conn_conf = TCPConnConf("127.0.0.1", srv_port, pub_port, timeout=20)
    launcher = LocalServerLauncher(conn_conf)
    launcher.start()

    assert launcher.is_server_running()

    client = Client(IFlightControl(), conn_conf)

    assert client.ping() == b"pong"

    launcher.stop()

    launcher.is_server_running()
Esempio n. 3
0
    def listen(self, provider_cls: INeuralNetworkAPI = TikTorchServer):
        api_provider = provider_cls()

        conf = TCPConnConf(self._addr, self._port, self._notify_port)
        srv = Server(api_provider, conf)
        client = Client(IFlightControl(), conf)

        watchdog = Watchdog(client, self._kill_timeout)
        watchdog.start()

        srv.listen()
Esempio n. 4
0
def client(conn_conf):
    cl = Client(INeuralNetworkAPI(), conn_conf)
    yield cl
Esempio n. 5
0
def client_control(conn_conf):
    cl_fl = Client(IFlightControl(), conn_conf)

    yield cl_fl