Skip to content

Commit 0c8f98e

Browse files
committed
adding a test that runs describe command on encrypted backup
1 parent 9654776 commit 0c8f98e

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

e2e/fixtures/fdb_backup.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ package fixtures
2323
import (
2424
"context"
2525
"encoding/json"
26+
"fmt"
2627
"log"
2728
"time"
2829

@@ -221,6 +222,21 @@ func (fdbBackup *FdbBackup) Pause() {
221222
fdbBackup.setState(fdbv1beta2.BackupStatePaused)
222223
}
223224

225+
// RunDescribeCommand run the describe command on the backup pod.
226+
func (fdbBackup *FdbBackup) RunDescribeCommand() string {
227+
backupPod := fdbBackup.GetBackupPod()
228+
command := fmt.Sprintf(
229+
"fdbbackup describe -d \"%s\" --json",
230+
fdbBackup.backup.BackupURL())
231+
out, _, err := fdbBackup.fdbCluster.ExecuteCmdOnPod(
232+
*backupPod,
233+
fdbv1beta2.MainContainerName,
234+
command,
235+
false)
236+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
237+
return out
238+
}
239+
224240
// WaitForReconciliation waits until the FdbBackup resource is fully reconciled.
225241
func (fdbBackup *FdbBackup) WaitForReconciliation() {
226242
objectKey := client.ObjectKeyFromObject(fdbBackup.backup)

e2e/test_operator_backups/operator_backup_test.go

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This test suite contains tests related to backup and restore with the operator.
2525
*/
2626

2727
import (
28+
"encoding/json"
2829
"log"
2930

3031
fdbv1beta2 "github.com/FoundationDB/fdb-kubernetes-operator/v2/api/v1beta2"
@@ -105,6 +106,8 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() {
105106
When("the default backup system is used", func() {
106107
var useRestorableVersion bool
107108
var backupConfiguration *fixtures.FdbBackupConfiguration
109+
var currentRestorableVersion *uint64
110+
var skipRestore bool
108111

109112
JustBeforeEach(func() {
110113
log.Println("creating backup for cluster")
@@ -135,11 +138,12 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() {
135138

136139
// Delete the data and restore it again.
137140
fdbCluster.ClearRange([]byte{prefix}, 60)
138-
var currentRestorableVersion *uint64
139141
if useRestorableVersion {
140142
currentRestorableVersion = ptr.To(restorableVersion)
141143
}
142-
restore = factory.CreateRestoreForCluster(backup, currentRestorableVersion)
144+
if !skipRestore {
145+
restore = factory.CreateRestoreForCluster(backup, currentRestorableVersion)
146+
}
143147
})
144148

145149
When("the continuous backup mode is used", func() {
@@ -168,6 +172,36 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() {
168172
backupConfiguration.EncryptionEnabled = true
169173
})
170174

175+
When("running describe command", func() {
176+
var describeOutput string
177+
178+
BeforeEach(func() {
179+
skipRestore = true
180+
})
181+
182+
JustBeforeEach(func() {
183+
describeOutput = backup.RunDescribeCommand()
184+
})
185+
186+
// TODO (09harsh): Enable this test when we have the fileLevelEncryption in json parser
187+
// here: https://github.com/apple/foundationdb/blob/main/fdbclient/BackupContainer.actor.cpp#L193-L250
188+
PIt("should have file level encryption enabled", func() {
189+
var describeData map[string]interface{}
190+
err := json.Unmarshal([]byte(describeOutput), &describeData)
191+
Expect(err).NotTo(HaveOccurred())
192+
fileLevelEncryption := describeData["FileLevelEncryption"].(bool)
193+
Expect(fileLevelEncryption).To(BeTrue())
194+
})
195+
196+
It(
197+
"should be able to restore the cluster successfully with a restorable version",
198+
func() {
199+
restore = factory.CreateRestoreForCluster(backup, currentRestorableVersion)
200+
Expect(fdbCluster.GetRange([]byte{prefix}, 25, 60)).Should(Equal(keyValues))
201+
},
202+
)
203+
})
204+
171205
It(
172206
"should restore the cluster successfully with a restorable version",
173207
func() {

0 commit comments

Comments
 (0)