From 313b3d63b398f1ccf550ee41262b61ef562fc9ff Mon Sep 17 00:00:00 2001 From: Sachin Singla Date: Thu, 10 Oct 2024 23:38:42 +0530 Subject: [PATCH] fix issue #1464: Added VSL Backup/Restore Tests --- tests/e2e/backup_restore_suite_test.go | 22 ++++++++++++++++++++++ tests/e2e/e2e_suite_test.go | 1 + tests/e2e/lib/dpa_helpers.go | 22 ++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/tests/e2e/backup_restore_suite_test.go b/tests/e2e/backup_restore_suite_test.go index a262eeb164..92b6035cd4 100644 --- a/tests/e2e/backup_restore_suite_test.go +++ b/tests/e2e/backup_restore_suite_test.go @@ -409,5 +409,27 @@ var _ = ginkgo.Describe("Backup and restore tests", func() { BackupTimeout: 20 * time.Minute, }, }, nil), + ginkgo.Entry("MySQL application VSL", ginkgo.FlakeAttempts(flakeAttempts), ApplicationBackupRestoreCase{ + ApplicationTemplate: "./sample-applications/mysql-persistent/mysql-persistent.yaml", + BackupRestoreCase: BackupRestoreCase{ + Namespace: "mysql-persistent", + Name: "mysql-vsl-e2e", + BackupRestoreType: lib.VSL, + PreBackupVerify: todoListReady(true, false, "mysql"), + PostRestoreVerify: todoListReady(false, false, "mysql"), + BackupTimeout: 20 * time.Minute, + }, + }, nil), + ginkgo.Entry("Mongo application VSL", ginkgo.FlakeAttempts(flakeAttempts), ApplicationBackupRestoreCase{ + ApplicationTemplate: "./sample-applications/mongo-persistent/mongo-persistent.yaml", + BackupRestoreCase: BackupRestoreCase{ + Namespace: "mongo-persistent", + Name: "mongo-vsl-e2e", + BackupRestoreType: lib.VSL, + PreBackupVerify: todoListReady(true, false, "mongo"), + PostRestoreVerify: todoListReady(false, false, "mongo"), + BackupTimeout: 20 * time.Minute, + }, + }, nil), ) }) diff --git a/tests/e2e/e2e_suite_test.go b/tests/e2e/e2e_suite_test.go index fa94230c52..0fdf0907ac 100644 --- a/tests/e2e/e2e_suite_test.go +++ b/tests/e2e/e2e_suite_test.go @@ -162,6 +162,7 @@ func TestOADPE2E(t *testing.T) { Name: "ts-" + instanceName, Namespace: namespace, Client: runTimeClientForSuiteRun, + VSLSecretName: vslSecretName, BSLSecretName: bslSecretName, BSLConfig: dpa.DeepCopy().Spec.BackupLocations[0].Velero.Config, BSLProvider: dpa.DeepCopy().Spec.BackupLocations[0].Velero.Provider, diff --git a/tests/e2e/lib/dpa_helpers.go b/tests/e2e/lib/dpa_helpers.go index eddb89b376..bc629cc971 100644 --- a/tests/e2e/lib/dpa_helpers.go +++ b/tests/e2e/lib/dpa_helpers.go @@ -28,12 +28,14 @@ const ( CSIDataMover BackupRestoreType = "csi-datamover" RESTIC BackupRestoreType = "restic" KOPIA BackupRestoreType = "kopia" + VSL BackupRestoreType = "vsl" ) type DpaCustomResource struct { Name string Namespace string Client client.Client + VSLSecretName string BSLSecretName string BSLConfig map[string]string BSLProvider string @@ -112,6 +114,26 @@ func (v *DpaCustomResource) Build(backupRestoreType BackupRestoreType) *oadpv1al dpaSpec.Configuration.Velero.DefaultPlugins = append(dpaSpec.Configuration.Velero.DefaultPlugins, oadpv1alpha1.DefaultPluginCSI) dpaSpec.Configuration.Velero.FeatureFlags = append(dpaSpec.Configuration.Velero.FeatureFlags, velero.CSIFeatureFlag) dpaSpec.SnapshotLocations = nil + case VSL: + dpaSpec.SnapshotLocations = []oadpv1alpha1.SnapshotLocation{ + { + Velero: &velero.VolumeSnapshotLocationSpec{ + Provider: v.BSLProvider, + Credential: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: v.VSLSecretName, + }, + Key: "cloud", + }, + }, + }, + } + if v.BSLProvider == "aws" { + dpaSpec.SnapshotLocations[0].Velero.Config = map[string]string{ + "region": "us-east-1", + "profile": "default", + } + } } return &dpaSpec