Skip to content

Commit

Permalink
fix issue #1464: Added VSL Backup/Restore Tests (#1552)
Browse files Browse the repository at this point in the history
  • Loading branch information
stillalearner authored Oct 18, 2024
1 parent d1063c7 commit 1d6ed3c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
24 changes: 24 additions & 0 deletions tests/e2e/backup_restore_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ func prepareBackupAndRestore(brCase BackupRestoreCase, updateLastInstallTime fun
gomega.Eventually(lib.AreNodeAgentPodsRunning(kubernetesClientForSuiteRun, namespace), time.Minute*3, time.Second*5).Should(gomega.BeTrue())
}

// Velero does not change status of VSL objects. Users can only confirm if VSLs are correct configured when running a native snapshot backup/restore

log.Print("Checking if BSL is available")
gomega.Eventually(dpaCR.BSLsAreAvailable(), time.Minute*3, time.Second*5).Should(gomega.BeTrue())

Expand Down Expand Up @@ -409,5 +411,27 @@ var _ = ginkgo.Describe("Backup and restore tests", func() {
BackupTimeout: 20 * time.Minute,
},
}, nil),
ginkgo.Entry("MySQL application Native-Snapshots", ginkgo.FlakeAttempts(flakeAttempts), ginkgo.Label("aws", "azure", "gcp"), ApplicationBackupRestoreCase{
ApplicationTemplate: "./sample-applications/mysql-persistent/mysql-persistent.yaml",
BackupRestoreCase: BackupRestoreCase{
Namespace: "mysql-persistent",
Name: "mysql-native-snapshots-e2e",
BackupRestoreType: lib.NativeSnapshots,
PreBackupVerify: todoListReady(true, false, "mysql"),
PostRestoreVerify: todoListReady(false, false, "mysql"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
ginkgo.Entry("Mongo application Native-Snapshots", ginkgo.FlakeAttempts(flakeAttempts), ginkgo.Label("aws", "azure", "gcp"), ApplicationBackupRestoreCase{
ApplicationTemplate: "./sample-applications/mongo-persistent/mongo-persistent.yaml",
BackupRestoreCase: BackupRestoreCase{
Namespace: "mongo-persistent",
Name: "mongo-native-snapshots-e2e",
BackupRestoreType: lib.NativeSnapshots,
PreBackupVerify: todoListReady(true, false, "mongo"),
PostRestoreVerify: todoListReady(false, false, "mongo"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
)
})
2 changes: 1 addition & 1 deletion tests/e2e/dpa_deployment_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ var _ = ginkgo.Describe("Configuration testing for DPA Custom Resource", func()
}

if len(installCase.DpaSpec.SnapshotLocations) > 0 {
// TODO Check if VSLs are available creating new backup/restore test with VSL
// Velero does not change status of VSL objects. Users can only confirm if VSLs are correct configured when running a native snapshot backup/restore
for _, vsl := range installCase.DpaSpec.SnapshotLocations {
log.Printf("Checking for VSL spec")
gomega.Expect(dpaCR.DoesVSLSpecMatchesDpa(namespace, *vsl.Velero)).To(gomega.BeTrue())
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 13 additions & 4 deletions tests/e2e/lib/dpa_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ import (
type BackupRestoreType string

const (
CSI BackupRestoreType = "csi"
CSIDataMover BackupRestoreType = "csi-datamover"
RESTIC BackupRestoreType = "restic"
KOPIA BackupRestoreType = "kopia"
CSI BackupRestoreType = "csi"
CSIDataMover BackupRestoreType = "csi-datamover"
RESTIC BackupRestoreType = "restic"
KOPIA BackupRestoreType = "kopia"
NativeSnapshots BackupRestoreType = "native-snapshots"
)

type DpaCustomResource struct {
Name string
Namespace string
Client client.Client
VSLSecretName string
BSLSecretName string
BSLConfig map[string]string
BSLProvider string
Expand Down Expand Up @@ -112,6 +114,13 @@ 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 NativeSnapshots:
dpaSpec.SnapshotLocations[0].Velero.Credential = &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: v.VSLSecretName,
},
Key: "cloud",
}
}

return &dpaSpec
Expand Down

0 comments on commit 1d6ed3c

Please sign in to comment.