From f352d6db813cfa8bd086b5d12aa5ab75dc29dea6 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sun, 10 Nov 2024 19:41:04 +0100 Subject: [PATCH] chore: improve database docker instructions - Do not require minio for mariadb docker. - Do not require elasticsearch for mysql. - Fix postgress password parameter. - Add the multistatement query for mysql (this is not optimal but adding Makefile code doesn't seem to work really well either) --- Makefile | 1 + tests/e2e/README.md | 7 +++---- tests/integration/README.md | 9 ++++----- tests/pgsql.ini.tmpl | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index a95a951792..6a8ff8d88e 100644 --- a/Makefile +++ b/Makefile @@ -660,6 +660,7 @@ generate-ini-pgsql: -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \ -e 's|{{TEST_LOGGER}}|$(or $(TEST_LOGGER),test$(COMMA)file)|g' \ -e 's|{{TEST_TYPE}}|$(or $(TEST_TYPE),integration)|g' \ + -e 's|{{TEST_STORAGE_TYPE}}|$(or $(TEST_STORAGE_TYPE),minio)|g' \ tests/pgsql.ini.tmpl > tests/pgsql.ini .PHONY: test-pgsql diff --git a/tests/e2e/README.md b/tests/e2e/README.md index 36b9a187c3..4f93cfb64a 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -126,17 +126,16 @@ You can also perform e2e tests using MariaDB/MySQL or PostgreSQL if you want. Setup a MySQL database inside docker ``` -docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:latest #(just ctrl-c to stop db and clean the container) -docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" --rm --name elasticsearch elasticsearch:7.6.0 #(in a second terminal, just ctrl-c to stop db and clean the container) +docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:latest #(Ctrl-c to stop the database) ``` Start tests based on the database container ``` -TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root TEST_MYSQL_PASSWORD='' make test-e2e-mysql +TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test?multiStatements=true TEST_MYSQL_USERNAME=root TEST_MYSQL_PASSWORD='' make test-e2e-mysql ``` Setup a pgsql database inside docker ``` -docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:latest #(just ctrl-c to stop db and clean the container) +docker run -e POSTGRES_DB=test -e POSTGRES_PASSWORD=password -p 5432:5432 --rm --name pgsql postgres:latest #(Ctrl-c to stop the database) ``` Start tests based on the database container ``` diff --git a/tests/integration/README.md b/tests/integration/README.md index f0fbf94df9..d83685388e 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -61,22 +61,21 @@ make test-sqlite ### Run MySQL integration tests Setup a MySQL database inside docker ``` -docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:latest #(just ctrl-c to stop db and clean the container) -docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" --rm --name elasticsearch elasticsearch:7.6.0 #(in a second terminal, just ctrl-c to stop db and clean the container) +docker run -e MYSQL_DATABASE=test -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -p 3306:3306 --rm --name mysql mysql:latest #(Ctrl-c to stop the database) ``` Start tests based on the database container ``` -TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root TEST_MYSQL_PASSWORD='' make test-mysql +TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test?multiStatements=true TEST_MYSQL_USERNAME=root TEST_MYSQL_PASSWORD='' make test-mysql ``` ### Run pgsql integration tests Setup a pgsql database inside docker ``` -docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:latest #(just ctrl-c to stop db and clean the container) +docker run -e "POSTGRES_DB=test" -e POSTGRES_PASSWORD=postgres -p 5432:5432 --rm --name pgsql postgres:latest #(Ctrl-c to stop the database) ``` Start tests based on the database container ``` -TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-pgsql +TEST_STORAGE_TYPE=local TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-pgsql ``` ### Running individual tests diff --git a/tests/pgsql.ini.tmpl b/tests/pgsql.ini.tmpl index b58d753b6c..01d018c5b7 100644 --- a/tests/pgsql.ini.tmpl +++ b/tests/pgsql.ini.tmpl @@ -112,7 +112,7 @@ MINIO_BASE_PATH = avatars/ MINIO_BASE_PATH = repo-avatars/ [storage] -STORAGE_TYPE = minio +STORAGE_TYPE = {{TEST_STORAGE_TYPE}} SERVE_DIRECT = false MINIO_ENDPOINT = minio:9000 MINIO_ACCESS_KEY_ID = 123456