Skip to content

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

FIX (mysql): Fix MySQL tests

Rostislav Dugine1f466c9651d
diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml
index 035ce748..5d0271c2 100644
--- a/.github/workflows/ci-release.yml
+++ b/.github/workflows/ci-release.yml
@@ -229,12 +229,53 @@ jobs:
mkdir -p postgresus-data/backups
mkdir -p postgresus-data/temp
+ - name: Cache PostgreSQL client tools
+ id: cache-postgres
+ uses: actions/cache@v4
+ with:
+ path: /usr/lib/postgresql
+ key: postgres-clients-12-18-v1
+
+ - name: Cache MySQL client tools
+ id: cache-mysql
+ uses: actions/cache@v4
+ with:
+ path: backend/tools/mysql
+ key: mysql-clients-57-80-84-v1
+
+ - name: Install MySQL dependencies
+ run: |
+ sudo apt-get update -qq
+ sudo apt-get install -y -qq libncurses6
+ sudo ln -sf /usr/lib/x86_64-linux-gnu/libncurses.so.6 /usr/lib/x86_64-linux-gnu/libncurses.so.5
+ sudo ln -sf /usr/lib/x86_64-linux-gnu/libtinfo.so.6 /usr/lib/x86_64-linux-gnu/libtinfo.so.5
+
- name: Install PostgreSQL and MySQL client tools
+ if: steps.cache-postgres.outputs.cache-hit != 'true' || steps.cache-mysql.outputs.cache-hit != 'true'
run: |
chmod +x backend/tools/download_linux.sh
cd backend/tools
./download_linux.sh
+ - name: Setup PostgreSQL symlinks (when using cache)
+ if: steps.cache-postgres.outputs.cache-hit == 'true'
+ run: |
+ cd backend/tools
+ mkdir -p postgresql
+ for version in 12 13 14 15 16 17 18; do
+ version_dir="postgresql/postgresql-$version"
+ mkdir -p "$version_dir/bin"
+ pg_bin_dir="/usr/lib/postgresql/$version/bin"
+ if [ -d "$pg_bin_dir" ]; then
+ ln -sf "$pg_bin_dir/pg_dump" "$version_dir/bin/pg_dump"
+ ln -sf "$pg_bin_dir/pg_dumpall" "$version_dir/bin/pg_dumpall"
+ ln -sf "$pg_bin_dir/psql" "$version_dir/bin/psql"
+ ln -sf "$pg_bin_dir/pg_restore" "$version_dir/bin/pg_restore"
+ ln -sf "$pg_bin_dir/createdb" "$version_dir/bin/createdb"
+ ln -sf "$pg_bin_dir/dropdb" "$version_dir/bin/dropdb"
+ fi
+ done
+
- name: Run database migrations
run: |
cd backend
diff --git a/backend/internal/features/databases/databases/mysql/readonly_user_test.go b/backend/internal/features/databases/databases/mysql/readonly_user_test.go
index 8ec4539c..811ca818 100644
--- a/backend/internal/features/databases/databases/mysql/readonly_user_test.go
+++ b/backend/internal/features/databases/databases/mysql/readonly_user_test.go
@@ -43,7 +43,7 @@ func Test_IsUserReadOnly_AdminUser_ReturnsFalse(t *testing.T) {
isReadOnly, err := mysqlModel.IsUserReadOnly(ctx, logger, nil, uuid.New())
assert.NoError(t, err)
- assert.False(t, isReadOnly, "Admin user should not be read-only")
+ assert.False(t, isReadOnly, "Root user should not be read-only")
})
}
}
@@ -327,9 +327,9 @@ func connectToMysqlContainer(
}
dbName := "testdb"
- password := "testpassword"
- username := "testuser"
- host := "localhost"
+ host := "127.0.0.1"
+ username := "root"
+ password := "rootpassword"
portInt, err := strconv.Atoi(port)
assert.NoError(t, err)
diff --git a/backend/internal/features/tests/mysql_backup_restore_test.go b/backend/internal/features/tests/mysql_backup_restore_test.go
index 7aee2234..dd66d165 100644
--- a/backend/internal/features/tests/mysql_backup_restore_test.go
+++ b/backend/internal/features/tests/mysql_backup_restore_test.go
@@ -529,7 +529,11 @@ func waitForMysqlRestoreCompletion(
return restore
}
if restore.Status == restores_enums.RestoreStatusFailed {
- t.Fatalf("MySQL restore failed: %v", restore.FailMessage)
+ failMsg := "unknown error"
+ if restore.FailMessage != nil {
+ failMsg = *restore.FailMessage
+ }
+ t.Fatalf("MySQL restore failed: %s", failMsg)
}
}
@@ -570,9 +574,9 @@ func connectToMysqlContainer(version tools.MysqlVersion, port string) (*MysqlCon
}
dbName := "testdb"
- password := "testpassword"
- username := "testuser"
- host := "localhost"
+ password := "rootpassword"
+ username := "root"
+ host := "127.0.0.1"
portInt, err := strconv.Atoi(port)
if err != nil {
diff --git a/backend/internal/features/tests/postgresql_backup_restore_test.go b/backend/internal/features/tests/postgresql_backup_restore_test.go
index b5aca0d8..35feb84e 100644
--- a/backend/internal/features/tests/postgresql_backup_restore_test.go
+++ b/backend/internal/features/tests/postgresql_backup_restore_test.go
@@ -1183,7 +1183,11 @@ func waitForBackupCompletion(
return backup
}
if backup.Status == backups.BackupStatusFailed {
- t.Fatalf("Backup failed: %v", backup.FailMessage)
+ failMsg := "unknown error"
+ if backup.FailMessage != nil {
+ failMsg = *backup.FailMessage
+ }
+ t.Fatalf("Backup failed: %s", failMsg)
}
}
@@ -1221,7 +1225,11 @@ func waitForRestoreCompletion(
return restore
}
if restore.Status == restores_enums.RestoreStatusFailed {
- t.Fatalf("Restore failed: %v", restore.FailMessage)
+ failMsg := "unknown error"
+ if restore.FailMessage != nil {
+ failMsg = *restore.FailMessage
+ }
+ t.Fatalf("Restore failed: %s", failMsg)
}
}
diff --git a/backend/tools/download_linux.sh b/backend/tools/download_linux.sh
index a6dd55de..a26de08e 100644
--- a/backend/tools/download_linux.sh
+++ b/backend/tools/download_linux.sh
@@ -98,22 +98,6 @@ echo "========================================"
echo "Installing MySQL client tools (versions 5.7, 8.0, 8.4)..."
echo "========================================"
-# Add MySQL APT repository
-echo "Adding MySQL official APT repository..."
-wget -q https://dev.mysql.com/get/mysql-apt-config_0.8.29-1_all.deb -O /tmp/mysql-apt-config.deb
-$SUDO DEBIAN_FRONTEND=noninteractive dpkg -i /tmp/mysql-apt-config.deb || true
-rm /tmp/mysql-apt-config.deb
-
-# Update package list
-$SUDO apt-get update -qq -y
-
-# MySQL versions and their package names
-declare -A mysql_packages=(
- ["5.7"]="mysql-community-client"
- ["8.0"]="mysql-community-client"
- ["8.4"]="mysql-community-client"
-)
-
# Download and extract MySQL client tools
mysql_versions="5.7 8.0 8.4"