Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions e2e/fixtures/fdb_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package fixtures
import (
"context"
"encoding/json"
"fmt"
"log"
"time"

Expand Down Expand Up @@ -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)
Expand Down
50 changes: 40 additions & 10 deletions e2e/test_operator_backups/operator_backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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.
Expand Down