Testing

To test our log streamer, build a test file in $Visor_HOME/test.

In this file, import the former fake_access_stream and fake_error_stream class, instantiate them and put them into listening.

Then write a fake client to build the connection to the streamer.

def fake_client():
    print('+++ Fake client starts running!')
    fake_client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    host = socket.gethostname()
    port = 5555
    time.sleep(5)
    fake_client.connect((host, port))
    print('+++ Fake Client connected to tested server!')

    for i in range(5):
        fake_client.recv(1024).decode()

    print('+++ Fake client ends receiving!')
    fake_client.close()

To run the streamer and fake client in the same process, use multi-threading:

client_thread = threading.Thread(target=fake_client)
client_thread.start()
time.sleep(1)
server = fake_access_stream()
server.run()
client_thread.join()

To Do

Close the connection in a more gentle way.

results matching ""

    No results matching ""