Skip to content

Latest commit

 

History

History
210 lines (142 loc) · 5.92 KB

podman.md

File metadata and controls

210 lines (142 loc) · 5.92 KB

How to start the test databases using Podman

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

PostgreSQL

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 docker.io/postgres:16.2

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

MariaDB

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 docker.io/mariadb:11.3.2

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

MySQL

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 docker.io/mysql:8.3.0

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

CockroachDB

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 \
    docker.io/cockroachdb/cockroach:v23.1.17 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 

Db2

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/icr.io/db2_community/db2:11.5.9.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"

Microsoft SQL Server

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!~'

Oracle Database

Use the following command to start an Oracle Database 23c Free—Developer Release 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-free:23-slim-faststart