diff --git a/e2e/fixtures/fdb_backup.go b/e2e/fixtures/fdb_backup.go index be3656926..13c79aa1c 100644 --- a/e2e/fixtures/fdb_backup.go +++ b/e2e/fixtures/fdb_backup.go @@ -23,6 +23,7 @@ package fixtures import ( "context" "encoding/json" + "fmt" "log" "time" @@ -221,6 +222,21 @@ func (fdbBackup *FdbBackup) Pause() { fdbBackup.setState(fdbv1beta2.BackupStatePaused) } +// RunDescribeCommand run the describe command on the backup pod. +func (fdbBackup *FdbBackup) RunDescribeCommand() string { + backupPod := fdbBackup.GetBackupPod() + command := fmt.Sprintf( + "fdbbackup describe -d \"%s\" --json", + fdbBackup.backup.BackupURL()) + out, _, err := fdbBackup.fdbCluster.ExecuteCmdOnPod( + *backupPod, + fdbv1beta2.MainContainerName, + command, + false) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + return out +} + // WaitForReconciliation waits until the FdbBackup resource is fully reconciled. func (fdbBackup *FdbBackup) WaitForReconciliation() { objectKey := client.ObjectKeyFromObject(fdbBackup.backup) diff --git a/e2e/test_operator_backups/operator_backup_test.go b/e2e/test_operator_backups/operator_backup_test.go index 96003f299..96281036e 100644 --- a/e2e/test_operator_backups/operator_backup_test.go +++ b/e2e/test_operator_backups/operator_backup_test.go @@ -25,6 +25,7 @@ This test suite contains tests related to backup and restore with the operator. */ import ( + "encoding/json" "log" fdbv1beta2 "github.com/FoundationDB/fdb-kubernetes-operator/v2/api/v1beta2" @@ -105,6 +106,8 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() { When("the default backup system is used", func() { var useRestorableVersion bool var backupConfiguration *fixtures.FdbBackupConfiguration + var currentRestorableVersion *uint64 + var skipRestore bool JustBeforeEach(func() { log.Println("creating backup for cluster") @@ -135,11 +138,12 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() { // Delete the data and restore it again. fdbCluster.ClearRange([]byte{prefix}, 60) - var currentRestorableVersion *uint64 if useRestorableVersion { currentRestorableVersion = ptr.To(restorableVersion) } - restore = factory.CreateRestoreForCluster(backup, currentRestorableVersion) + if !skipRestore { + restore = factory.CreateRestoreForCluster(backup, currentRestorableVersion) + } }) When("the continuous backup mode is used", func() { @@ -168,14 +172,40 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() { backupConfiguration.EncryptionEnabled = true }) - It( - "should restore the cluster successfully with a restorable version", - func() { - Expect( - fdbCluster.GetRange([]byte{prefix}, 25, 60), - ).Should(Equal(keyValues)) - }, - ) + When("running describe command", func() { + BeforeEach(func() { + skipRestore = true + }) + + JustBeforeEach(func() { + describeCommandOutput := backup.RunDescribeCommand() + + var describeData map[string]interface{} + err := json.Unmarshal([]byte(describeCommandOutput), &describeData) + Expect(err).NotTo(HaveOccurred()) + + restorable := describeData["Restorable"].(bool) + Expect(restorable).To(BeTrue()) + + // TODO (09harsh): Uncomment this when we have the fileLevelEncryption in json parser + // here: https://github.com/apple/foundationdb/blob/main/fdbclient/BackupContainer.actor.cpp#L193-L250 + //fileLevelEncryption := describeData["FileLevelEncryption"].(bool) + //Expect(fileLevelEncryption).To(BeTrue()) + }) + + It( + "should be able to restore the cluster successfully with a restorable version", + func() { + restore = factory.CreateRestoreForCluster( + backup, + currentRestorableVersion, + ) + Expect( + fdbCluster.GetRange([]byte{prefix}, 25, 60), + ).Should(Equal(keyValues)) + }, + ) + }) }) // TODO (johscheuer): Enable test once the CRD in CI is updated.