From 0f7f21a7dbb08b9842fc5de09592cb3695775418 Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Tue, 19 Apr 2022 15:49:37 +0200 Subject: [PATCH] fix clean/create in pgdump/restore (#1457) --- tests/README.md | 5 +++++ tests/lib/db/instance-postgres | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/README.md b/tests/README.md index 031e00a57..49d55d31a 100644 --- a/tests/README.md +++ b/tests/README.md @@ -329,6 +329,9 @@ You can however easily test with a different engine. Run Postgres somewhere, version 10 or above - easy to do in a docker container. +You also need to install a postgresql-client package or equivalent, to provide +recent pg_dump and pg_restore executables (not older than the PG version in the docker container). + ``` $ sudo docker run --detach --name=postgres -p 5432:5432 --env="POSTGRES_PASSWORD=postgres" postgres:latest ``` @@ -373,6 +376,8 @@ or for MariaDB $ sudo docker run --cap-add=sys_nice --detach --name=mariadb -p 3306:3306 --env="MYSQL_ROOT_PASSWORD=password" mariadb ``` +A mysql-client package is required as well. + ## gotchas - Testing with Postgres or MySQL/MariaDB leads to (unpredictably) failing diff --git a/tests/lib/db/instance-postgres b/tests/lib/db/instance-postgres index 7cd5d8260..ab0d239a8 100755 --- a/tests/lib/db/instance-postgres +++ b/tests/lib/db/instance-postgres @@ -50,7 +50,7 @@ setup() { dump() { backup_file="${1?Missing file to backup database to}" - pg_dump -Ft --dbname crowdsec_test --file "$backup_file" + pg_dump -Ft --dbname crowdsec_test --clean --create --file "$backup_file" } restore() {