Skip to content

Commit 079fde0

Browse files
Update logic for encryption
1 parent dd97fe6 commit 079fde0

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

e2e/fixtures/fdb_backup.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ type FdbBackup struct {
4646
type FdbBackupConfiguration struct {
4747
// BackupType defines the backup type that should be used for this backup.
4848
BackupType *fdbv1beta2.BackupType
49+
// EncryptionEnabled determines whether backup encryption should be used.
50+
EncryptionEnabled bool
4951
}
5052

5153
// CreateBackupForCluster will create a FoundationDBBackup for the provided cluster.
@@ -71,7 +73,6 @@ func (factory *Factory) CreateBackupForCluster(
7173
AllowTagOverride: ptr.To(true),
7274
ClusterName: fdbCluster.Name(),
7375
Version: fdbVersion.String(),
74-
EncryptionKeyPath: "/tmp/encryption-key/key.bin",
7576
BlobStoreConfiguration: &fdbv1beta2.BlobStoreConfiguration{
7677
AccountName: "seaweedfs@seaweedfs:8333",
7778
URLParameters: []fdbv1beta2.URLParameter{
@@ -162,6 +163,11 @@ func (factory *Factory) CreateBackupForCluster(
162163
},
163164
}
164165

166+
// Set encryption key path only if encryption is enabled
167+
if config.EncryptionEnabled {
168+
backup.Spec.EncryptionKeyPath = "/tmp/encryption-key/key.bin"
169+
}
170+
165171
gomega.Expect(factory.CreateIfAbsent(backup)).NotTo(gomega.HaveOccurred())
166172

167173
curBackup := &FdbBackup{

e2e/test_operator_backups/operator_backup_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() {
8888
// in the backup store.
8989
AfterEach(func() {
9090
backup.Destroy()
91+
Expect(fdbCluster.WaitForReconciliation()).To(Succeed())
9192
})
9293

9394
When("the default backup system is used", func() {
@@ -127,6 +128,29 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() {
127128
})
128129
})
129130

131+
When("the default backup system is used with encryption", Serial, func() {
132+
BeforeEach(func() {
133+
log.Println("creating encrypted backup for cluster")
134+
backup = factory.CreateBackupForCluster(
135+
fdbCluster,
136+
&fixtures.FdbBackupConfiguration{
137+
BackupType: ptr.To(fdbv1beta2.BackupTypeDefault),
138+
EncryptionEnabled: true,
139+
},
140+
)
141+
keyValues = fdbCluster.GenerateRandomValues(10, prefix)
142+
fdbCluster.WriteKeyValues(keyValues)
143+
backup.WaitForRestorableVersion(fdbCluster.GetClusterVersion())
144+
backup.Stop()
145+
})
146+
147+
It("should restore the encrypted cluster successfully", func() {
148+
fdbCluster.ClearRange([]byte{prefix}, 60)
149+
factory.CreateRestoreForCluster(backup)
150+
Expect(fdbCluster.GetRange([]byte{prefix}, 25, 60)).Should(Equal(keyValues))
151+
})
152+
})
153+
130154
PWhen("the partitioned backup system is used", func() {
131155
BeforeEach(func() {
132156
log.Println("creating backup for cluster with partitioned log system")

0 commit comments

Comments
 (0)