diff --git a/testing/config.mysql.yml b/testing/config.mysql.yml index f4b7ad9..d382160 100644 --- a/testing/config.mysql.yml +++ b/testing/config.mysql.yml @@ -21,7 +21,7 @@ app: db: host: 127.0.0.1 - port: 3306 + port: 53306 user: wakapi password: wakapi name: wakapi diff --git a/testing/config.postgres.yml b/testing/config.postgres.yml index 0b5c672..fec4144 100644 --- a/testing/config.postgres.yml +++ b/testing/config.postgres.yml @@ -21,7 +21,7 @@ app: db: host: 127.0.0.1 - port: 5432 + port: 55432 user: wakapi password: wakapi name: wakapi diff --git a/testing/docker-compose.yml b/testing/docker-compose.yml index 3c72f98..77cab91 100644 --- a/testing/docker-compose.yml +++ b/testing/docker-compose.yml @@ -7,6 +7,7 @@ services: POSTGRES_USER: "wakapi" POSTGRES_PASSWORD: "wakapi" POSTGRES_DB: "wakapi" + PGPORT: 55432 network_mode: host volumes: - wakapi-postgres:/var/lib/postgresql/data @@ -14,6 +15,7 @@ services: mysql: image: mysql:8 environment: + MYSQL_TCP_PORT: 53306 MYSQL_USER: "wakapi" MYSQL_PASSWORD: "wakapi" MYSQL_DATABASE: "wakapi" @@ -25,6 +27,7 @@ services: mariadb: image: mariadb:10 environment: + MYSQL_TCP_PORT: 53306 MARIADB_USER: "wakapi" MARIADB_PASSWORD: "wakapi" MARIADB_DATABASE: "wakapi" diff --git a/testing/run_api_tests.sh b/testing/run_api_tests.sh index 902dc9a..5838051 100755 --- a/testing/run_api_tests.sh +++ b/testing/run_api_tests.sh @@ -34,14 +34,24 @@ if [[ $MIGRATION -eq 1 ]]; then echo "Running tests with release version" fi +cleanup() { + if [ -n "$pid" ] && ps -p "$pid" > /dev/null; then + kill -TERM "$pid" + fi + if [ "${docker_down-0}" -eq 1 ]; then + docker-compose -f "$script_dir/docker-compose.yml" down + fi +} +trap cleanup EXIT + # Initialise test data case $1 in postgres|mysql|mariadb) - docker compose -f "$script_dir/docker-compose.yml" down + docker-compose -f "$script_dir/docker-compose.yml" down docker volume rm "testing_wakapi-$1" docker_down=1 - docker compose -f "$script_dir/docker-compose.yml" up --wait -d "$1" + docker-compose -f "$script_dir/docker-compose.yml" up --wait -d "$1" if [ "$1" == "mariadb" ]; then config="config.mysql.yml" else @@ -50,9 +60,9 @@ case $1 in db_port=0 if [ "$1" == "postgres" ]; then - db_port=5432 + db_port=55432 else - db_port=3306 + db_port=53306 fi for _ in $(seq 0 30); do @@ -122,9 +132,5 @@ if [[ $MIGRATION -eq 1 ]]; then kill -TERM $pid fi -if [ "$docker_down" -eq 1 ]; then - docker compose -f "$script_dir/docker-compose.yml" down -fi - echo "Exiting with status $exit_code" exit $exit_code