From 2f18808d68482f8839f628cf7df9206ea7fe8ba6 Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Fri, 25 Mar 2022 12:17:28 +0100 Subject: [PATCH] print db logs after tests (#1390) --- .github/workflows/ci_bats_mariadb.yaml | 5 +++++ .github/workflows/ci_bats_mysql.yaml | 7 ++++++- .github/workflows/ci_bats_postgres.yaml | 7 ++++++- tests/lib/db/instance-pgx | 2 +- tests/lib/db/instance-postgres | 6 ++++-- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci_bats_mariadb.yaml b/.github/workflows/ci_bats_mariadb.yaml index 026c7fe3d..13acafa4e 100644 --- a/.github/workflows/ci_bats_mariadb.yaml +++ b/.github/workflows/ci_bats_mariadb.yaml @@ -61,3 +61,8 @@ jobs: MYSQL_PORT: 3306 MYSQL_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} MYSQL_USER: root + + - name: "show mariadb logs" + run: docker logs "${{ job.services.mariadb .id }}" + if: ${{ always() }} + diff --git a/.github/workflows/ci_bats_mysql.yaml b/.github/workflows/ci_bats_mysql.yaml index 829f0a603..d735512e2 100644 --- a/.github/workflows/ci_bats_mysql.yaml +++ b/.github/workflows/ci_bats_mysql.yaml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 20 services: - mariadb: + mysql: image: mysql:latest env: MYSQL_ROOT_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} @@ -61,3 +61,8 @@ jobs: MYSQL_PORT: 3306 MYSQL_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} MYSQL_USER: root + + - name: "show mysql logs" + run: docker logs "${{ job.services.mysql.id }}" + if: ${{ always() }} + diff --git a/.github/workflows/ci_bats_postgres.yaml b/.github/workflows/ci_bats_postgres.yaml index d54b8346f..c53f8551d 100644 --- a/.github/workflows/ci_bats_postgres.yaml +++ b/.github/workflows/ci_bats_postgres.yaml @@ -21,7 +21,7 @@ jobs: ports: - 5432:5432 options: >- - --health-cmd pg_isready + --health-cmd pg_isready -u postgres --health-interval 10s --health-timeout 5s --health-retries 5 @@ -84,3 +84,8 @@ jobs: POSTGRES_PORT: 5432 POSTGRES_PASSWORD: ${{ secrets.DATABASE_PASSWORD }} POSTGRES_USER: postgres + + - name: "show postgres logs" + run: docker logs "${{ job.services.postgres.id }}" + if: ${{ always() }} + diff --git a/tests/lib/db/instance-pgx b/tests/lib/db/instance-pgx index 204ddaf38..1a3ed0813 100755 --- a/tests/lib/db/instance-pgx +++ b/tests/lib/db/instance-pgx @@ -18,7 +18,7 @@ about() { } check_postgres_client() { - if ! command -v psql >/dev/null; then + if ! command -v psql --version >/dev/null; then die "missing required program 'psql' as a postgres client (package postgres-client-13 on debian like system)" fi } diff --git a/tests/lib/db/instance-postgres b/tests/lib/db/instance-postgres index 4c7ee9c57..038c2d7f7 100755 --- a/tests/lib/db/instance-postgres +++ b/tests/lib/db/instance-postgres @@ -18,14 +18,14 @@ about() { } check_postgres_client() { - if ! command -v psql >/dev/null; then + if ! command -v psql --version >/dev/null; then die "missing required program 'psql' as a postgres client (package postgres-client-13 on debian like system)" fi } exec_sql() { cmd="${1?Missing required sql command}" - PGPASSWORD="${POSTGRES_PASSWORD}" psql -h "${POSTGRES_HOST}" --user "${POSTGRES_USER}" "--port=${POSTGRES_PORT}" <<< "$cmd" + PGPASSWORD="${POSTGRES_PASSWORD}" psql --host "${POSTGRES_HOST}" --user "${POSTGRES_USER}" "--port=${POSTGRES_PORT}" <<< "$cmd" } requirements() { @@ -38,6 +38,8 @@ setup() { exec_sql "DROP USER IF EXISTS crowdsec_test;" exec_sql "CREATE USER crowdsec_test WITH ENCRYPTED PASSWORD 'crowdsec_test';" exec_sql "GRANT ALL PRIVILEGES ON DATABASE crowdsec_test TO crowdsec_test;" + # exec_sql "SET log_statement='all';" + # exec_sql "SELECT pg_reload_conf();" } dump() {