Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

FIX (tests): Change SSL to copying to docker compose to run SSL tests

Rostislav Dugin1f3a940f1946
diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml
index 58b88cbf..39811bc8 100644
--- a/.github/workflows/ci-release.yml
+++ b/.github/workflows/ci-release.yml
@@ -362,41 +362,15 @@ jobs:
echo "Waiting for MongoDB 8.2..."
timeout 120 bash -c 'until docker exec test-mongodb-82 mongosh --eval "db.adminCommand(\"ping\")" -u root -p rootpassword --authenticationDatabase admin 2>/dev/null; do sleep 2; done'
- # Wait for SSL/TLS test containers.
- # Exits early with logs if the container stops — silent until-loops
- # otherwise hide entrypoint failures (e.g. cert install errors) and
- # waste the full timeout chasing a dead container.
- wait_for_container() {
- local name="$1"
- local probe="$2"
- local deadline=$(( $(date +%s) + 180 ))
- while true; do
- if eval "$probe" >/dev/null 2>&1; then
- return 0
- fi
- if [ "$(docker inspect -f '{{.State.Running}}' "$name" 2>/dev/null)" != "true" ]; then
- echo "Container $name is not running. Logs:"
- docker logs "$name" 2>&1 | tail -50
- docker inspect "$name" --format 'State: {{.State.Status}} ExitCode: {{.State.ExitCode}} Error: {{.State.Error}}'
- return 1
- fi
- if [ "$(date +%s)" -ge "$deadline" ]; then
- echo "Timed out waiting for $name. Logs:"
- docker logs "$name" 2>&1 | tail -50
- return 1
- fi
- sleep 2
- done
- }
-
+ # Wait for SSL/TLS test containers
echo "Waiting for PostgreSQL SSL..."
- wait_for_container test-postgres-ssl 'docker exec test-postgres-ssl pg_isready -h /var/run/postgresql -U testuser -d testdb'
+ timeout 120 bash -c 'until docker exec test-postgres-ssl pg_isready -U testuser -d testdb 2>/dev/null; do sleep 2; done'
echo "Waiting for MariaDB SSL..."
- wait_for_container test-mariadb-ssl 'docker exec test-mariadb-ssl healthcheck.sh --connect --innodb_initialized'
+ timeout 120 bash -c 'until docker exec test-mariadb-ssl healthcheck.sh --connect --innodb_initialized 2>/dev/null; do sleep 2; done'
echo "Waiting for MySQL SSL..."
- wait_for_container test-mysql-ssl 'docker exec test-mysql-ssl mysqladmin ping -h localhost -u root -prootpassword --silent'
+ timeout 120 bash -c 'until docker exec test-mysql-ssl mysqladmin ping -h localhost -u root -prootpassword --silent 2>/dev/null; do sleep 2; done'
echo "Waiting for MongoDB SSL..."
- wait_for_container test-mongodb-ssl 'docker exec test-mongodb-ssl mongosh --tls --tlsAllowInvalidCertificates -u root -p rootpassword --authenticationDatabase admin --eval "db.adminCommand(\"ping\")"'
+ timeout 120 bash -c 'until docker exec test-mongodb-ssl mongosh --tls --tlsAllowInvalidCertificates -u root -p rootpassword --authenticationDatabase admin --eval "db.adminCommand(\"ping\")" 2>/dev/null; do sleep 2; done'
- name: Create data and temp directories
run: |
diff --git a/docker-compose.yml b/docker-compose.yml
index 813b9939..44eb13dc 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -641,20 +641,28 @@ services:
# handshake regressions without multiplying the version matrix.
# ================================================================
+ # Certs are baked in via build context (COPY) instead of bind-mounted.
+ # CI runs Docker-in-Docker where host paths don't resolve to the job
+ # container's workspace, but build contexts are uploaded to the daemon
+ # as a tarball so they always reach the container.
test-postgres-ssl:
- image: postgres:18
+ build:
+ context: ./backend/internal/features/tests/testdata/ssl
+ dockerfile_inline: |
+ FROM postgres:18
+ COPY server.key /etc/ssl-test/server.key
+ COPY server.crt /etc/ssl-test/server.crt
+ COPY pg_hba.conf /etc/ssl-test/pg_hba.conf
+ RUN chown postgres:postgres /etc/ssl-test/server.key /etc/ssl-test/server.crt /etc/ssl-test/pg_hba.conf \
+ && chmod 600 /etc/ssl-test/server.key \
+ && chmod 644 /etc/ssl-test/server.crt /etc/ssl-test/pg_hba.conf
ports:
- "${TEST_POSTGRES_SSL_PORT}:5432"
environment:
- POSTGRES_DB=testdb
- POSTGRES_USER=testuser
- POSTGRES_PASSWORD=testpassword
- volumes:
- - ./backend/internal/features/tests/testdata/ssl:/etc/ssl-test:ro
- command:
- - bash
- - -c
- - install -m 600 -o postgres -g postgres /etc/ssl-test/server.key /tmp/server.key && install -m 644 -o postgres -g postgres /etc/ssl-test/server.crt /tmp/server.crt && exec docker-entrypoint.sh postgres -c ssl=on -c ssl_cert_file=/tmp/server.crt -c ssl_key_file=/tmp/server.key -c hba_file=/etc/ssl-test/pg_hba.conf
+ command: postgres -c ssl=on -c ssl_cert_file=/etc/ssl-test/server.crt -c ssl_key_file=/etc/ssl-test/server.key -c hba_file=/etc/ssl-test/pg_hba.conf
container_name: test-postgres-ssl
shm_size: 1gb
healthcheck:
@@ -707,8 +715,17 @@ services:
timeout: 5s
retries: 10
+ # Certs baked in via build context — see test-postgres-ssl note.
test-mongodb-ssl:
- image: mongo:8.2.3-noble
+ build:
+ context: ./backend/internal/features/tests/testdata/ssl
+ dockerfile_inline: |
+ FROM mongo:8.2.3-noble
+ COPY server.pem /etc/ssl-test/server.pem
+ COPY server.crt /etc/ssl-test/server.crt
+ RUN chown mongodb:mongodb /etc/ssl-test/server.pem /etc/ssl-test/server.crt \
+ && chmod 600 /etc/ssl-test/server.pem \
+ && chmod 644 /etc/ssl-test/server.crt
container_name: test-mongodb-ssl
ports:
- "${TEST_MONGODB_SSL_PORT}:27017"
@@ -716,12 +733,7 @@ services:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: rootpassword
MONGO_INITDB_DATABASE: testdb
- volumes:
- - ./backend/internal/features/tests/testdata/ssl:/etc/ssl-test:ro
- command:
- - bash
- - -c
- - install -m 600 -o mongodb -g mongodb /etc/ssl-test/server.pem /tmp/server.pem && install -m 644 -o mongodb -g mongodb /etc/ssl-test/server.crt /tmp/server.crt && exec docker-entrypoint.sh mongod --auth --tlsMode requireTLS --tlsCertificateKeyFile /tmp/server.pem --tlsCAFile /tmp/server.crt --tlsAllowConnectionsWithoutCertificates
+ command: mongod --auth --tlsMode requireTLS --tlsCertificateKeyFile /etc/ssl-test/server.pem --tlsCAFile /etc/ssl-test/server.crt --tlsAllowConnectionsWithoutCertificates
healthcheck:
test: ["CMD", "mongosh", "--tls", "--tlsAllowInvalidCertificates",
"-u", "root", "-p", "rootpassword", "--authenticationDatabase", "admin",