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.
Example:
podman run --rm --name HibernateTestingPGSQL postgres:14.0
becomes for Docker:
sudo docker run --rm --name HibernateTestingPGSQL postgres:14.0
Use the following command to start a PostgreSQL database with the required credentials and schema to run the tests:
podman run --rm --name HibernateTestingPGSQL \
-e POSTGRES_USER=hreact -e POSTGRES_PASSWORD=hreact -e POSTGRES_DB=hreact \
-p 5432:5432 postgres:15.0
When the database has started, you can run the tests on PostgreSQL with:
./gradlew test
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
Use the following command to start a MariaDB database with the required credentials and schema to run the tests:
podman run --rm --name HibernateTestingMariaDB \
-e MYSQL_ROOT_PASSWORD=hreact -e MYSQL_DATABASE=hreact -e MYSQL_USER=hreact -e MYSQL_PASSWORD=hreact \
-p 3306:3306 mariadb:10.9.3
When the database has started, you can run the tests on MariaDB with:
./gradlew test -Pdb=mariadb
Optionally, you can connect to the database with the MySQL Command-Line Client(mysql
) using:
podman exec -it HibernateTestingMariaDB mysql -U hreact -phreact
Use the following command to start a MySQL database with the required credentials and schema to run the tests:
podman run --rm --name HibernateTestingMySQL \
-e MYSQL_ROOT_PASSWORD=hreact -e MYSQL_DATABASE=hreact -e MYSQL_USER=hreact -e MYSQL_PASSWORD=hreact \
-p 3306:3306 mysql:8.0.31
When the database has started, you can run the tests on MySQL with:
./gradlew test -Pdb=mysql
Optionally, you can connect to the database with the MySQL Command-Line Client(mysql
) using:
podman exec -it HibernateTestingMySQL mysql -U hreact -phreact
Use the following commands to start a CockroachDB database with the configured to run the tests:
podman run --rm --name=HibernateTestingCockroachDB \
--hostname=roachrr1 -p 26257:26257 -p 8080:8080 \
cockroachdb/cockroach:v22.1.9 start-single-node --insecure
Some of tests needs temporary tables and because this is an experimental feature in CockroachDB, it needs to be enabled after the database has started:
podman exec -it HibernateTestingCockroachDB ./cockroach sql --insecure \
-e "SET CLUSTER SETTING sql.defaults.experimental_temporary_tables.enabled = 'true';"
When the database has started, you can run the tests on CockroachDB with:
./gradlew test -Pdb=CockroachDB
Optionally, you can connect to the database with the Cockroach commands(cockroach
)
using:
podman exec -it HibernateTestingCockroachDB ./cockroach sql --insecure
Use the following command to start a Db2 database with the required credentials and schema to run the tests:
podman run --rm -e LICENSE=accept --privileged=true --group-add keep-groups \
--name HibernateTestingDB2 -e DBNAME=hreact -e DB2INSTANCE=hreact \
-e DB2INST1_PASSWORD=hreact -e PERSISTENT_HOME=false -e ARCHIVE_LOGS=false \
-e AUTOCONFIG=false -p 50000:50000 docker.io/ibmcom/db2:11.5.8.0
When the database has started, you can run the tests on Db2 with:
./gradlew test -Pdb=db2
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"
Use the following command to start a Microsoft SQL Server database with the required credentials and schema to run the tests:
podman run --rm -it --name HibernateTestingMSSQL -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=~!HReact!~' -p 1433:1433 mcr.microsoft.com/mssql/server:2022-latest
When the database has started, you can run the tests on MS SQL Server with:
./gradlew test -Pdb=SqlServer
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!~'
Use the following command to start a Oracle XE database with the required credentials and schema to run the tests:
podman run --rm --name HibernateTestingOracle -e ORACLE_PASSWORD=hreact -e APP_USER=hreact -e APP_USER_PASSWORD=hreact -e ORACLE_DATABASE=hreact -p 1521:1521 docker.io/gvenzl/oracle-xe:21-slim-faststart