This document explains how to set up and run CockroachDB tests with OJP.
- Docker - Required to run CockroachDB locally
Use the official CockroachDB Docker image:
docker run --name ojp-cockroachdb -p 26257:26257 -p 8080:8080 -d --rm cockroachdb/cockroach:v24.3.4 start-single-node --insecureWait for the database to fully start (usually takes less than a minute).
Check the health endpoint:
curl http://localhost:8080/health?ready=1Or access the admin UI at: http://localhost:8080
In a separate terminal:
cd ojp
mvn verify -pl ojp-server -Prun-ojp-serverWait for the server to start (look for "Server started" in logs).
In another terminal:
cd ojp
mvn test -pl ojp-jdbc-driver -Dgpg.skip=trueThe CockroachDB integration tests will run automatically along with H2, PostgreSQL, MySQL, and MariaDB tests.
To run only CockroachDB integration tests, disable the other databases:
mvn test -pl ojp-jdbc-driver -DenableCockroachDBTests=true -Dgpg.skip=truecockroachdb_connection.csv- CockroachDB-only connection configurationh2_cockroachdb_connections.csv- Combined H2 and CockroachDB configuration for mixed testingh2_postgres_mysql_mariadb_oracle_sqlserver_connections.csv- Comprehensive configuration including CockroachDB
- URL:
jdbc:ojp[localhost:1059]_postgresql://localhost:26257/defaultdb?sslmode=disable - User:
root - Password: (empty/none - insecure mode)
- Database:
defaultdb - Port:
26257(SQL port),8080(HTTP/Admin UI port)
Note: CockroachDB uses the PostgreSQL wire protocol, so the JDBC URL uses postgresql:// but connects to CockroachDB on port 26257.
To skip CockroachDB tests, use the -DenableCockroachDBTests=false flag (or simply omit it as tests are disabled by default):
mvn test -pl ojp-jdbc-driver -DenableCockroachDBTests=falseFor production environments, you should:
- Enable security: Use
--certs-dirinstead of--insecure - Set up TLS certificates: Generate certificates using
cockroach cert - Create users with passwords: Use
CREATE USERSQL statements - Configure connection string: Update JDBC URL to include proper authentication
Example secure connection string:
jdbc:postgresql://localhost:26257/defaultdb?sslmode=require&user=myuser&password=mypassword
If port 26257 or 8080 is already in use:
# Find and stop the process using the port
docker ps | grep cockroach
docker stop ojp-cockroachdb
# Or use different ports:
docker run --name ojp-cockroachdb -p 26258:26257 -p 8081:8080 -d --rm cockroachdb/cockroach:v24.3.4 start-single-node --insecureEnsure CockroachDB is fully started and listening:
# Check CockroachDB logs
docker logs ojp-cockroachdb
# Test connection with psql (if installed)
psql -h localhost -p 26257 -U root -d defaultdbCockroachDB automatically creates the defaultdb database. If it doesn't exist:
# Connect with SQL client
docker exec -it ojp-cockroachdb ./cockroach sql --insecure
# Create database
CREATE DATABASE defaultdb;