Skip to content

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

FIX (tests): Allow to skip external network tests in CI CD

Rostislav Dugind9c176d19a69
diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml
index 77664f01..00f494fc 100644
--- a/.github/workflows/ci-release.yml
+++ b/.github/workflows/ci-release.yml
@@ -150,6 +150,7 @@ jobs:
GOOSE_MIGRATION_DIR=./migrations
# testing
TEST_LOCALHOST=172.17.0.1
+ IS_SKIP_EXTERNAL_RESOURCES_TESTS=true
# to get Google Drive env variables: add storage in UI and copy data from added storage here
TEST_GOOGLE_DRIVE_CLIENT_ID=${{ secrets.TEST_GOOGLE_DRIVE_CLIENT_ID }}
TEST_GOOGLE_DRIVE_CLIENT_SECRET=${{ secrets.TEST_GOOGLE_DRIVE_CLIENT_SECRET }}
diff --git a/backend/.env.development.example b/backend/.env.development.example
index d3b818ca..801378eb 100644
--- a/backend/.env.development.example
+++ b/backend/.env.development.example
@@ -8,6 +8,7 @@ ENV_MODE=development
SHOW_DB_INSTALLATION_VERIFICATION_LOGS=true
# tests
TEST_LOCALHOST=localhost
+IS_SKIP_EXTERNAL_RESOURCES_TESTS=false
# db
DATABASE_DSN=host=dev-db user=postgres password=Q1234567 dbname=databasus port=5437 sslmode=disable
DATABASE_URL=postgres://postgres:Q1234567@dev-db:5437/databasus?sslmode=disable
diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go
index d05f6909..c7105704 100644
--- a/backend/internal/config/config.go
+++ b/backend/internal/config/config.go
@@ -32,6 +32,7 @@ type EnvVariables struct {
TestLocalhost string `env:"TEST_LOCALHOST"`
ShowDbInstallationVerificationLogs bool `env:"SHOW_DB_INSTALLATION_VERIFICATION_LOGS"`
+ IsSkipExternalResourcesTests bool `env:"IS_SKIP_EXTERNAL_RESOURCES_TESTS"`
IsManyNodesMode bool `env:"IS_MANY_NODES_MODE"`
IsPrimaryNode bool `env:"IS_PRIMARY_NODE"`
@@ -176,6 +177,11 @@ func loadEnvVariables() {
env.ShowDbInstallationVerificationLogs = true
}
+ // Set default value for IsSkipExternalTests if not defined
+ if os.Getenv("IS_SKIP_EXTERNAL_RESOURCES_TESTS") == "" {
+ env.IsSkipExternalResourcesTests = false
+ }
+
for _, arg := range os.Args {
if strings.Contains(arg, "test") {
env.IsTesting = true
diff --git a/backend/internal/features/databases/databases/postgresql/model_test.go b/backend/internal/features/databases/databases/postgresql/model_test.go
index e3d277c5..9e7f01d5 100644
--- a/backend/internal/features/databases/databases/postgresql/model_test.go
+++ b/backend/internal/features/databases/databases/postgresql/model_test.go
@@ -599,6 +599,10 @@ func Test_CreateReadOnlyUser_DatabaseNameWithDash_Success(t *testing.T) {
}
func Test_CreateReadOnlyUser_Supabase_UserCanReadButNotWrite(t *testing.T) {
+ if config.GetEnv().IsSkipExternalResourcesTests {
+ t.Skip("Skipping Supabase test: IS_SKIP_EXTERNAL_RESOURCES_TESTS is true")
+ }
+
env := config.GetEnv()
if env.TestSupabaseHost == "" {
diff --git a/backend/internal/features/storages/controller_test.go b/backend/internal/features/storages/controller_test.go
index 22088417..f772bd05 100644
--- a/backend/internal/features/storages/controller_test.go
+++ b/backend/internal/features/storages/controller_test.go
@@ -6,6 +6,7 @@ import (
"strings"
"testing"
+ "databasus-backend/internal/config"
audit_logs "databasus-backend/internal/features/audit_logs"
azure_blob_storage "databasus-backend/internal/features/storages/models/azure_blob"
ftp_storage "databasus-backend/internal/features/storages/models/ftp"
@@ -902,6 +903,12 @@ func Test_StorageSensitiveDataLifecycle_AllTypes(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
+ // Skip Google Drive tests if external resources tests are disabled
+ if tc.storageType == StorageTypeGoogleDrive &&
+ config.GetEnv().IsSkipExternalResourcesTests {
+ t.Skip("Skipping Google Drive storage test: IS_SKIP_EXTERNAL_RESOURCES_TESTS=true")
+ }
+
owner := users_testing.CreateTestUser(users_enums.UserRoleMember)
router := createRouter()
workspace := workspaces_testing.CreateTestWorkspace("Test Workspace", owner, router)
diff --git a/backend/internal/features/storages/model_test.go b/backend/internal/features/storages/model_test.go
index ac835007..bf8edfa8 100644
--- a/backend/internal/features/storages/model_test.go
+++ b/backend/internal/features/storages/model_test.go
@@ -185,7 +185,9 @@ acl = private`, s3Container.accessKey, s3Container.secretKey, s3Container.endpoi
// Add Google Drive storage test only if environment variables are available
env := config.GetEnv()
- if env.TestGoogleDriveClientID != "" && env.TestGoogleDriveClientSecret != "" &&
+ if env.IsSkipExternalResourcesTests {
+ t.Log("Skipping Google Drive storage test: IS_SKIP_EXTERNAL_RESOURCES_TESTS=true")
+ } else if env.TestGoogleDriveClientID != "" && env.TestGoogleDriveClientSecret != "" &&
env.TestGoogleDriveTokenJSON != "" {
testCases = append(testCases, struct {
name string
diff --git a/backend/internal/features/tests/postgresql_backup_restore_test.go b/backend/internal/features/tests/postgresql_backup_restore_test.go
index aefe4dcc..47522c8d 100644
--- a/backend/internal/features/tests/postgresql_backup_restore_test.go
+++ b/backend/internal/features/tests/postgresql_backup_restore_test.go
@@ -124,6 +124,10 @@ func Test_BackupAndRestorePostgresqlWithEncryption_RestoreIsSuccessful(t *testin
}
func Test_BackupAndRestoreSupabase_PublicSchemaOnly_RestoreIsSuccessful(t *testing.T) {
+ if config.GetEnv().IsSkipExternalResourcesTests {
+ t.Skip("Skipping Supabase test: IS_SKIP_EXTERNAL_RESOURCES_TESTS is true")
+ }
+
env := config.GetEnv()
if env.TestSupabaseHost == "" {