Skip to content

Commit

Permalink
doc(java-binding): add docs for running java-binding unit test (#10304)
Browse files Browse the repository at this point in the history
  • Loading branch information
yufansong authored Jun 25, 2023
1 parent a418ed0 commit f885259
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions java/connector-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,12 @@ This will create a `.tar.gz` file with the Connector Node and all its dependenci

```
# unpack the tar file, the file name might vary depending on the version
cd assembly/target && tar xvf risingwave-connector-1.0.0.tar.gz
cd java/connector-node/assembly/target && tar xvf risingwave-connector-1.0.0.tar.gz
# launch connector node service
java -classpath "./libs/*" com.risingwave.connector.ConnectorService
```

Sometimes, you need to specify the shared library path. For example, when program want to run class related to java-binding, they need to call shared library file. If not, it will throw exception when running. You need:

```
RISINGWAVE_ROOT=$(git rev-parse --show-toplevel)
CONNECTOR_ROOT=$JAVA_ROOT/connector-node
cd ${CONNECTOR_ROOT}/assembly/target && java -classpath "./libs/*" com.risingwave.connector.ConnectorService
```
Currently, during the Maven build process, all the required shared libraries are built and added to the JAR file. These shared libraries can then be loaded directly from the Java code.

## Docker image
Alternatively, to build and run the Docker image, run the following command from the project's root directory:
Expand Down Expand Up @@ -75,6 +69,30 @@ Or you can use conda and install the necessary package `grpcio grpcio-tools psyc

The connector service is the server and Python integration test is a client, which will send gRPC request and get response from the connector server. So when running integration_tests, remember to launch the connector service in advance. You can get the gRPC response and check messages or errors in client part. And check the detailed exception information on server side.

### JDBC test

We have integration tests that involve the use of several sinks, including file sink, jdbc sink, iceberg sink, and deltalake sink. If you wish to run these tests locally, you will need to configure both MinIO and PostgreSQL.
Downloading and launching MinIO is a straightforward process. For PostgreSQL, I recommend launching it using Docker. When setting up PostgreSQL, please ensure that the values for `POSTGRES_PASSWORD`, `POSTGRES_DB`, and `POSTGRES_USER` match the corresponding settings in the `integration_tests.py` file.

```shell
# create postgresql in docker
docker run --name my-postgres -e POSTGRES_PASSWORD=connector -e POSTGRES_DB=test -e POSTGRES_USER=test -d -p 5432:5432 postgres
# connect postgresql
psql -h localhost -p 5432 -U test -d postgres
```
Also remember to create the database and tables in postgresql

```sql
# create table
CREATE TABLE test (id serial PRIMARY KEY, name VARCHAR (50) NOT NULL);
```

If you want to create a Sink to this pg instance, please check details at [here](https://www.risingwave.dev/docs/current/sink-to-postgres/). About how to launch rw in kubernetes, please check [here](https://github.com/risingwavelabs/risingwave-operator/blob/main/README.md).

By maintaining consistency between these configurations, you can ensure a smooth execution of the integration tests. Please check more details in `connector-node-integration.yml`.

Also, if you change the file in `src/java_binding`, remember to use `cargo fmt` and `cargo sort` to format the `Cargo.toml` file to pass the github ci check.

## Connect with RisingWave

Connector node is optional to running a RisingWave cluster. It is only on creating external sources and sinks that the connector node service will be automatically called.
Expand Down

0 comments on commit f885259

Please sign in to comment.