From 3319f04ee2b1e2f53be79386c8cd814c49ea99e8 Mon Sep 17 00:00:00 2001 From: harsh maheshwari <09harshmaheshwari@gmail.com> Date: Thu, 11 Dec 2025 14:48:32 +0530 Subject: [PATCH 1/6] adding a test that runs describe command on encrypted backup --- e2e/fixtures/fdb_backup.go | 16 ++++++++ .../operator_backup_test.go | 38 ++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) 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..9d41e6dd7 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,6 +172,36 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() { backupConfiguration.EncryptionEnabled = true }) + When("running describe command", func() { + var describeOutput string + + BeforeEach(func() { + skipRestore = true + }) + + JustBeforeEach(func() { + describeOutput = backup.RunDescribeCommand() + }) + + // TODO (09harsh): Enable this test when we have the fileLevelEncryption in json parser + // here: https://github.com/apple/foundationdb/blob/main/fdbclient/BackupContainer.actor.cpp#L193-L250 + PIt("should have file level encryption enabled", func() { + var describeData map[string]interface{} + err := json.Unmarshal([]byte(describeOutput), &describeData) + Expect(err).NotTo(HaveOccurred()) + 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)) + }, + ) + }) + It( "should restore the cluster successfully with a restorable version", func() { From 9887f9d0ccb7bbec710b1b20df9bb094bfbb11e0 Mon Sep 17 00:00:00 2001 From: harsh maheshwari <09harshmaheshwari@gmail.com> Date: Thu, 11 Dec 2025 15:24:32 +0530 Subject: [PATCH 2/6] go fmt changes --- e2e/test_operator_backups/operator_backup_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/e2e/test_operator_backups/operator_backup_test.go b/e2e/test_operator_backups/operator_backup_test.go index 9d41e6dd7..4c134b9e2 100644 --- a/e2e/test_operator_backups/operator_backup_test.go +++ b/e2e/test_operator_backups/operator_backup_test.go @@ -196,8 +196,13 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() { 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)) + restore = factory.CreateRestoreForCluster( + backup, + currentRestorableVersion, + ) + Expect( + fdbCluster.GetRange([]byte{prefix}, 25, 60), + ).Should(Equal(keyValues)) }, ) }) From 3c967f8f0b0c60db36e621fca20b059009025b9c Mon Sep 17 00:00:00 2001 From: harsh maheshwari <09harshmaheshwari@gmail.com> Date: Wed, 17 Dec 2025 12:53:06 +0530 Subject: [PATCH 3/6] creating one test instead of two --- .../operator_backup_test.go | 34 +++++-------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/e2e/test_operator_backups/operator_backup_test.go b/e2e/test_operator_backups/operator_backup_test.go index 4c134b9e2..e202bd07f 100644 --- a/e2e/test_operator_backups/operator_backup_test.go +++ b/e2e/test_operator_backups/operator_backup_test.go @@ -25,15 +25,13 @@ 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" "github.com/FoundationDB/fdb-kubernetes-operator/v2/e2e/fixtures" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/utils/ptr" + "log" ) var ( @@ -173,24 +171,19 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() { }) When("running describe command", func() { - var describeOutput string - BeforeEach(func() { skipRestore = true }) JustBeforeEach(func() { - describeOutput = backup.RunDescribeCommand() - }) - - // TODO (09harsh): Enable this test when we have the fileLevelEncryption in json parser - // here: https://github.com/apple/foundationdb/blob/main/fdbclient/BackupContainer.actor.cpp#L193-L250 - PIt("should have file level encryption enabled", func() { - var describeData map[string]interface{} - err := json.Unmarshal([]byte(describeOutput), &describeData) - Expect(err).NotTo(HaveOccurred()) - fileLevelEncryption := describeData["FileLevelEncryption"].(bool) - Expect(fileLevelEncryption).To(BeTrue()) + _ = backup.RunDescribeCommand() + // 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 + //var describeData map[string]interface{} + //err := json.Unmarshal([]byte(describeCommandOutput), &describeData) + //Expect(err).NotTo(HaveOccurred()) + //fileLevelEncryption := describeData["FileLevelEncryption"].(bool) + //Expect(fileLevelEncryption).To(BeTrue()) }) It( @@ -206,15 +199,6 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() { }, ) }) - - It( - "should restore the cluster successfully with a restorable version", - func() { - Expect( - fdbCluster.GetRange([]byte{prefix}, 25, 60), - ).Should(Equal(keyValues)) - }, - ) }) // TODO (johscheuer): Enable test once the CRD in CI is updated. From c7839cc6d2bd5b52139434c17fa0ee1da0b1fa72 Mon Sep 17 00:00:00 2001 From: harsh maheshwari <09harshmaheshwari@gmail.com> Date: Wed, 17 Dec 2025 14:39:37 +0530 Subject: [PATCH 4/6] fmt changes --- e2e/test_operator_backups/operator_backup_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e/test_operator_backups/operator_backup_test.go b/e2e/test_operator_backups/operator_backup_test.go index e202bd07f..ce6cd894e 100644 --- a/e2e/test_operator_backups/operator_backup_test.go +++ b/e2e/test_operator_backups/operator_backup_test.go @@ -25,13 +25,14 @@ This test suite contains tests related to backup and restore with the operator. */ import ( + "log" + fdbv1beta2 "github.com/FoundationDB/fdb-kubernetes-operator/v2/api/v1beta2" "github.com/FoundationDB/fdb-kubernetes-operator/v2/e2e/fixtures" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" "k8s.io/utils/ptr" - "log" ) var ( From ccf449e4aa659dbbe70bbb08233c9877d61e189f Mon Sep 17 00:00:00 2001 From: harsh maheshwari <09harshmaheshwari@gmail.com> Date: Wed, 17 Dec 2025 15:32:00 +0530 Subject: [PATCH 5/6] checking describe output --- e2e/test_operator_backups/operator_backup_test.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/e2e/test_operator_backups/operator_backup_test.go b/e2e/test_operator_backups/operator_backup_test.go index ce6cd894e..0c377d801 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" @@ -177,12 +178,17 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() { }) JustBeforeEach(func() { - _ = backup.RunDescribeCommand() + 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 - //var describeData map[string]interface{} - //err := json.Unmarshal([]byte(describeCommandOutput), &describeData) - //Expect(err).NotTo(HaveOccurred()) //fileLevelEncryption := describeData["FileLevelEncryption"].(bool) //Expect(fileLevelEncryption).To(BeTrue()) }) From cddd511236011202fe6b043107c560e3c87ace22 Mon Sep 17 00:00:00 2001 From: harsh maheshwari <09harshmaheshwari@gmail.com> Date: Wed, 17 Dec 2025 16:36:46 +0530 Subject: [PATCH 6/6] fmt changes --- e2e/test_operator_backups/operator_backup_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/test_operator_backups/operator_backup_test.go b/e2e/test_operator_backups/operator_backup_test.go index 0c377d801..96281036e 100644 --- a/e2e/test_operator_backups/operator_backup_test.go +++ b/e2e/test_operator_backups/operator_backup_test.go @@ -186,7 +186,7 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() { 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)