The following sections will use Podman to start the database of your choice, create the schema and create the credentials required to run the tests during the build.
Podman is a daemonless container engine for developing, managing, and running OCI Containers on your Linux System. Containers can either be run as root or in rootless mode.
TIP
If you replace podman with sudo docker, they will also work with Docker.
Each database has a Dockerfile in tooling/docker/ that contains the base image,
environment variables, exposed ports, and startup commands.
You can use these Dockerfiles directly with podman build to start a database for testing
without Testcontainers.
TIP
Use the -t option with podman build to tag the image with a specific version,
e.g. -t hreact-postgresql:18.3. Without it, the image defaults to :latest.
Build and start a PostgreSQL database:
podman build -f tooling/docker/postgresql.Dockerfile -t hreact-postgresql .
podman run --rm --name HibernateTestingPGSQL -p 5432:5432 hreact-postgresql
When the database has started, you can run the tests on PostgreSQL with:
./gradlew testDbPostgreSQL -PskipTestcontainers
Optionally, you can connect to the database with the PostgreSQL interactive terminal(psql)
using this one-liner:
podman exec -e PGPASSWORD=hreact -it HibernateTestingPGSQL psql -U hreact -d hreact
Build and start a MariaDB database:
podman build -f tooling/docker/maria.Dockerfile -t hreact-maria .
podman run --rm --name HibernateTestingMariaDB -p 3306:3306 hreact-maria
When the database has started, you can run the tests on MariaDB with:
./gradlew testDbMariaDB -PskipTestcontainers
Optionally, you can connect to the database with the MySQL Command-Line Client(mysql) using:
podman exec -it HibernateTestingMariaDB mysql -U hreact -phreact
Build and start a MySQL database:
podman build -f tooling/docker/mysql.Dockerfile -t hreact-mysql .
podman run --rm --name HibernateTestingMySQL -p 3306:3306 hreact-mysql
When the database has started, you can run the tests on MySQL with:
./gradlew testDbMySQL -PskipTestcontainers
Optionally, you can connect to the database with the MySQL Command-Line Client(mysql) using:
podman exec -it HibernateTestingMySQL mysql -U hreact -phreact
Build and start a CockroachDB database:
podman build -f tooling/docker/cockroachdb.Dockerfile -t hreact-cockroachdb .
podman run --rm --name HibernateTestingCockroachDB -p 26257:26257 -p 8080:8080 hreact-cockroachdb
When the database has started, you can run the tests on CockroachDB with:
./gradlew testDbCockroachDB -PskipTestcontainers
Optionally, you can connect to the database with the Cockroach commands(cockroach)
using:
podman exec -it HibernateTestingCockroachDB ./cockroach sql --insecure
Build and start a Db2 database:
podman build -f tooling/docker/db2.Dockerfile -t hreact-db2 .
podman run --rm --privileged --name HibernateTestingDB2 -p 50000:50000 hreact-db2
NOTE: Db2 requires --privileged mode. On Fedora with rootless Podman, this may not work.
See the Db2 with rootless Podman section for workarounds.
When the database has started, you can run the tests on Db2 with:
./gradlew testDbDB2 -PskipTestcontainers
Optionally, you can connect to the database with the Db2 command line interface using:
podman exec -ti HibernateTestingDB2 bash -c "su - hreact -c db2 connect"
Db2 requires --privileged mode for shared memory management, which doesn't work with
rootless Podman. You can use rootful Podman instead:
sudo systemctl enable --now podman.socket
sudo podman build -f tooling/docker/db2.Dockerfile -t hreact-db2 .
sudo podman run --rm --privileged --name HibernateTestingDB2 -p 50000:50000 hreact-db2
Build and start a Microsoft SQL Server database:
podman build -f tooling/docker/sqlserver.Dockerfile -t hreact-sqlserver .
podman run --rm --name HibernateTestingMSSQL -p 1433:1433 hreact-sqlserver
When the database has started, you can run the tests on MS SQL Server with:
./gradlew testDbMSSQLServer -PskipTestcontainers
Optionally, you can connect to the database with the sqlcmd utility using:
podman exec -it HibernateTestingMSSQL /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '~!HReact!~'
Build and start an Oracle Database Free:
podman build -f tooling/docker/oracle.Dockerfile -t hreact-oracle .
podman run --rm --name HibernateTestingOracle -p 1521:1521 hreact-oracle
NOTE: Oracle Database takes 30-60 seconds to fully initialize after the container starts. Wait for the message "DATABASE IS READY TO USE!" in the logs before running tests:
podman logs -f HibernateTestingOracle
When the database has started, you can run the tests on Oracle with:
./gradlew testDbOracle -PskipTestcontainers