Skip to content

Latest commit

 

History

History
174 lines (120 loc) · 4.66 KB

podman.md

File metadata and controls

174 lines (120 loc) · 4.66 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:13.0

becomes for Docker:

sudo docker run --rm --name HibernateTestingPGSQL postgres:13.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 postgres:13.1

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:

podman exec -it HibernateTestingPGSQL psql -U hreact -W -d hreact

When asked for the password, type: 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 mariadb:10.5.8

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 mysql:8.0.23

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 \
    cockroachdb/cockroach:v20.2.5 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 --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 ibmcom/db2:11.5.4.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"