From a941fbd0935026b1392fbc0f12b73be23c16fd71 Mon Sep 17 00:00:00 2001 From: Rostislav Dugin Date: Wed, 12 Nov 2025 15:39:44 +0300 Subject: [PATCH] FEATURE (postgres): Add PostgreSQL 12 tests and CI \ CD config --- .github/workflows/ci-release.yml | 2 ++ backend/.env.development.example | 1 + backend/docker-compose.yml.example | 11 +++++++++++ backend/internal/config/config.go | 5 +++++ .../features/tests/postgresql_backup_restore_test.go | 1 + frontend/src/features/backups/ui/BackupsComponent.tsx | 1 + 6 files changed, 21 insertions(+) diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index 8a36be9..7620b87 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -127,6 +127,7 @@ jobs: TEST_GOOGLE_DRIVE_CLIENT_SECRET=${{ secrets.TEST_GOOGLE_DRIVE_CLIENT_SECRET }} TEST_GOOGLE_DRIVE_TOKEN_JSON=${{ secrets.TEST_GOOGLE_DRIVE_TOKEN_JSON }} # testing DBs + TEST_POSTGRES_12_PORT=5000 TEST_POSTGRES_13_PORT=5001 TEST_POSTGRES_14_PORT=5002 TEST_POSTGRES_15_PORT=5003 @@ -154,6 +155,7 @@ jobs: timeout 60 bash -c 'until docker exec dev-db pg_isready -h localhost -p 5437 -U postgres; do sleep 2; done' # Wait for test databases + timeout 60 bash -c 'until nc -z localhost 5000; do sleep 2; done' timeout 60 bash -c 'until nc -z localhost 5001; do sleep 2; done' timeout 60 bash -c 'until nc -z localhost 5002; do sleep 2; done' timeout 60 bash -c 'until nc -z localhost 5003; do sleep 2; done' diff --git a/backend/.env.development.example b/backend/.env.development.example index 11264b1..0509869 100644 --- a/backend/.env.development.example +++ b/backend/.env.development.example @@ -17,6 +17,7 @@ TEST_GOOGLE_DRIVE_CLIENT_ID= TEST_GOOGLE_DRIVE_CLIENT_SECRET= TEST_GOOGLE_DRIVE_TOKEN_JSON="{\"access_token\":\"ya29..." # testing DBs +TEST_POSTGRES_12_PORT=5000 TEST_POSTGRES_13_PORT=5001 TEST_POSTGRES_14_PORT=5002 TEST_POSTGRES_15_PORT=5003 diff --git a/backend/docker-compose.yml.example b/backend/docker-compose.yml.example index cda7e82..2c5785d 100644 --- a/backend/docker-compose.yml.example +++ b/backend/docker-compose.yml.example @@ -32,6 +32,17 @@ services: command: server /data --console-address ":9001" # Test PostgreSQL containers + test-postgres-12: + image: postgres:12 + ports: + - "${TEST_POSTGRES_12_PORT}:5432" + environment: + - POSTGRES_DB=testdb + - POSTGRES_USER=testuser + - POSTGRES_PASSWORD=testpassword + container_name: test-postgres-12 + shm_size: 1gb + test-postgres-13: image: postgres:13 ports: diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go index 3267427..5022160 100644 --- a/backend/internal/config/config.go +++ b/backend/internal/config/config.go @@ -33,6 +33,7 @@ type EnvVariables struct { TestGoogleDriveClientSecret string `env:"TEST_GOOGLE_DRIVE_CLIENT_SECRET"` TestGoogleDriveTokenJSON string `env:"TEST_GOOGLE_DRIVE_TOKEN_JSON"` + TestPostgres12Port string `env:"TEST_POSTGRES_12_PORT"` TestPostgres13Port string `env:"TEST_POSTGRES_13_PORT"` TestPostgres14Port string `env:"TEST_POSTGRES_14_PORT"` TestPostgres15Port string `env:"TEST_POSTGRES_15_PORT"` @@ -145,6 +146,10 @@ func loadEnvVariables() { env.TempFolder = filepath.Join(filepath.Dir(backendRoot), "postgresus-data", "temp") if env.IsTesting { + if env.TestPostgres12Port == "" { + log.Error("TEST_POSTGRES_12_PORT is empty") + os.Exit(1) + } if env.TestPostgres13Port == "" { log.Error("TEST_POSTGRES_13_PORT is empty") os.Exit(1) diff --git a/backend/internal/features/tests/postgresql_backup_restore_test.go b/backend/internal/features/tests/postgresql_backup_restore_test.go index 3f203cc..37580a1 100644 --- a/backend/internal/features/tests/postgresql_backup_restore_test.go +++ b/backend/internal/features/tests/postgresql_backup_restore_test.go @@ -69,6 +69,7 @@ func Test_BackupAndRestorePostgresql_RestoreIsSuccesful(t *testing.T) { version string port string }{ + {"PostgreSQL 12", "12", env.TestPostgres12Port}, {"PostgreSQL 13", "13", env.TestPostgres13Port}, {"PostgreSQL 14", "14", env.TestPostgres14Port}, {"PostgreSQL 15", "15", env.TestPostgres15Port}, diff --git a/frontend/src/features/backups/ui/BackupsComponent.tsx b/frontend/src/features/backups/ui/BackupsComponent.tsx index 9a35721..3b9dddd 100644 --- a/frontend/src/features/backups/ui/BackupsComponent.tsx +++ b/frontend/src/features/backups/ui/BackupsComponent.tsx @@ -175,6 +175,7 @@ export const BackupsComponent = ({ database, isCanManageDBs, scrollContainerRef try { await backupsApi.makeBackup(database.id); + await new Promise((resolve) => setTimeout(resolve, 1000)); setCurrentLimit(BACKUPS_PAGE_SIZE); setHasMore(true); await loadBackups(BACKUPS_PAGE_SIZE);