numaproj / numaflow-java

Numaflow Java SDK
Apache License 2.0
22 stars 10 forks source link

feat: Test Kit for Servers #111

Closed yhl25 closed 6 months ago

yhl25 commented 6 months ago

Unit Testings

Just test functions without starting neither server or the client

Component Testing - Client code

In this mode, server will be already running.

  1. start client
  2. using client call the server
  3. close the client
       // Create a client that can send requests to the server
        MapperTestKit.Client client = new MapperTestKit.Client();
        MapperTestKit.TestDatum datum = MapperTestKit.TestDatum
                .builder()
                .value("2".getBytes())
                .build();
        MessageList result = client.sendRequest(new String[]{}, datum);
        client.close();

Server code for just testing the UDFs locally

  1. start server
  2. open client
  3. using client invoke the RPCs functions on server
  4. close client
  5. showdown server
        // Start the server locally. This will initiate the server on localhost and port 50051
        Server server = new Server(new EvenOddFunction());
        // Start the server
        server.start();
        // Wait for the server to shutdown
        server.awaitTermination();

fixes https://github.com/numaproj/numaflow/issues/1625