Skip to content

Commit cc24571

Browse files
fix Failures
1 parent 3deabc9 commit cc24571

File tree

4 files changed

+2609
-7
lines changed

4 files changed

+2609
-7
lines changed

e2e/fixtures/fdb_restore.go.rej

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
diff a/e2e/fixtures/fdb_restore.go b/e2e/fixtures/fdb_restore.go (rejected hunks)
2+
@@ -33,49 +35,62 @@ import (
3+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4+
)
5+
6+
+// FdbRestore represents a fdbv1beta2.FoundationDBRestore resource for doing restores to a FdbCluster.
7+
+type FdbRestore struct {
8+
+ restore *fdbv1beta2.FoundationDBRestore
9+
+ fdbCluster *FdbCluster
10+
+}
11+
+
12+
// CreateRestoreForCluster will create a FoundationDBRestore resource based on the provided backup resource.
13+
// For more information how the backup system with the operator is working please look at
14+
// the operator documentation: https://github.com/FoundationDB/fdb-kubernetes-operator/v2/blob/master/docs/manual/backup.md
15+
-func (factory *Factory) CreateRestoreForCluster(backup *FdbBackup) {
16+
+func (factory *Factory) CreateRestoreForCluster(backup *FdbBackup) *FdbRestore {
17+
gomega.Expect(backup).NotTo(gomega.BeNil())
18+
- restore := &fdbv1beta2.FoundationDBRestore{
19+
- ObjectMeta: metav1.ObjectMeta{
20+
- Name: backup.fdbCluster.Name(),
21+
- Namespace: backup.fdbCluster.Namespace(),
22+
- },
23+
- Spec: fdbv1beta2.FoundationDBRestoreSpec{
24+
- DestinationClusterName: backup.fdbCluster.Name(),
25+
- BlobStoreConfiguration: backup.backup.Spec.BlobStoreConfiguration,
26+
- CustomParameters: backup.backup.Spec.CustomParameters,
27+
+ restore := &FdbRestore{
28+
+ restore: &fdbv1beta2.FoundationDBRestore{
29+
+ ObjectMeta: metav1.ObjectMeta{
30+
+ Name: backup.fdbCluster.Name(),
31+
+ Namespace: backup.fdbCluster.Namespace(),
32+
+ },
33+
+ Spec: fdbv1beta2.FoundationDBRestoreSpec{
34+
+ DestinationClusterName: backup.fdbCluster.Name(),
35+
+ BlobStoreConfiguration: backup.backup.Spec.BlobStoreConfiguration,
36+
+ CustomParameters: backup.backup.Spec.CustomParameters,
37+
+ },
38+
},
39+
+ fdbCluster: backup.fdbCluster,
40+
}
41+
- gomega.Expect(factory.CreateIfAbsent(restore)).NotTo(gomega.HaveOccurred())
42+
+
43+
+ gomega.Expect(factory.CreateIfAbsent(restore.restore)).NotTo(gomega.HaveOccurred())
44+
45+
factory.AddShutdownHook(func() error {
46+
- return factory.GetControllerRuntimeClient().Delete(context.Background(), restore)
47+
+ restore.Destroy()
48+
+ return nil
49+
})
50+
51+
- waitForRestoreToComplete(backup)
52+
+ restore.waitForRestoreToComplete(backup)
53+
+
54+
+ return restore
55+
}
56+
57+
// waitForRestoreToComplete waits until the restore completed.
58+
-func waitForRestoreToComplete(backup *FdbBackup) {
59+
- ctrlClient := backup.fdbCluster.getClient()
60+
+func (restore *FdbRestore) waitForRestoreToComplete(backup *FdbBackup) {
61+
+ ctrlClient := restore.fdbCluster.getClient()
62+
63+
lastReconcile := time.Now()
64+
gomega.Eventually(func(g gomega.Gomega) fdbv1beta2.FoundationDBRestoreState {
65+
- restore := &fdbv1beta2.FoundationDBRestore{}
66+
- g.Expect(ctrlClient.Get(context.Background(), client.ObjectKeyFromObject(backup.backup), restore)).
67+
+ currentRestore := &fdbv1beta2.FoundationDBRestore{}
68+
+ g.Expect(ctrlClient.Get(context.Background(), client.ObjectKeyFromObject(restore.restore), currentRestore)).
69+
To(gomega.Succeed())
70+
- log.Println("restore state:", restore.Status.State)
71+
+ log.Println("restore state:", currentRestore.Status.State)
72+
73+
if time.Since(lastReconcile) > time.Minute {
74+
lastReconcile = time.Now()
75+
- patch := client.MergeFrom(restore.DeepCopy())
76+
- if restore.Annotations == nil {
77+
- restore.Annotations = make(map[string]string)
78+
+ patch := client.MergeFrom(currentRestore.DeepCopy())
79+
+ if currentRestore.Annotations == nil {
80+
+ currentRestore.Annotations = make(map[string]string)
81+
}
82+
- restore.Annotations["foundationdb.org/reconcile"] = strconv.FormatInt(
83+
+ currentRestore.Annotations["foundationdb.org/reconcile"] = strconv.FormatInt(
84+
time.Now().UnixNano(),
85+
10,
86+
)

e2e/test_operator_backups/operator_backup_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ var _ = BeforeSuite(func() {
6868

6969
// Create a blobstore for testing backups and restore
7070
factory.CreateBlobstoreIfAbsent(fdbCluster.Namespace())
71-
72-
// Note: Encryption key secret is automatically created during namespace setup
7371
})
7472

7573
var _ = AfterSuite(func() {
@@ -89,10 +87,9 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() {
8987
// in the backup store.
9088
AfterEach(func() {
9189
backup.Destroy()
92-
Expect(fdbCluster.WaitForReconciliation()).To(Succeed())
9390
})
9491

95-
When("the default backup system is used", Serial, func() {
92+
When("the default backup system is used", func() {
9693
BeforeEach(func() {
9794
log.Println("creating backup for cluster")
9895
backup = factory.CreateBackupForCluster(
@@ -114,7 +111,7 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() {
114111
})
115112
})
116113

117-
When("the default backup system is used with encryption", Serial, func() {
114+
When("the default backup system is used with encryption", func() {
118115
BeforeEach(func() {
119116
log.Println("creating encrypted backup for cluster")
120117
backup = factory.CreateBackupForCluster(
@@ -128,11 +125,11 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() {
128125
fdbCluster.WriteKeyValues(keyValues)
129126
backup.WaitForRestorableVersion(fdbCluster.GetClusterVersion())
130127
backup.Stop()
128+
fdbCluster.ClearRange([]byte{prefix}, 60)
129+
restore = factory.CreateRestoreForCluster(backup)
131130
})
132131

133132
It("should restore the encrypted cluster successfully", func() {
134-
fdbCluster.ClearRange([]byte{prefix}, 60)
135-
factory.CreateRestoreForCluster(backup)
136133
Expect(fdbCluster.GetRange([]byte{prefix}, 25, 60)).Should(Equal(keyValues))
137134
})
138135
})
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
diff a/e2e/test_operator_backups/operator_backup_test.go b/e2e/test_operator_backups/operator_backup_test.go (rejected hunks)
2+
@@ -62,12 +62,8 @@ var _ = BeforeSuite(func() {
3+
Skip("Skip backup tests with 7.1.63 as this version has a bug in the fdbbackup agent")
4+
}
5+
6+
- fdbCluster = factory.CreateFdbCluster(
7+
- fixtures.DefaultClusterConfig(false),
8+
- )
9+
-
10+
- // Create a blobstore for testing backups and restore
11+
- factory.CreateBlobstoreIfAbsent(fdbCluster.Namespace())
12+
+ // Create a blobstore for testing backups and restore.
13+
+ factory.CreateBlobstoreIfAbsent(factory.SingleNamespace())
14+
})
15+
16+
var _ = AfterSuite(func() {
17+
@@ -82,11 +78,25 @@ var _ = Describe("Operator Backup", Label("e2e", "pr"), func() {
18+
var keyValues []fixtures.KeyValue
19+
var prefix byte = 'a'
20+
var backup *fixtures.FdbBackup
21+
+ var restore *fixtures.FdbRestore
22+
+
23+
+ BeforeEach(func() {
24+
+ fdbCluster = factory.CreateFdbCluster(
25+
+ fixtures.DefaultClusterConfig(false),
26+
+ )
27+
+ })
28+
29+
- // Delete the backup resource after each test. Note that this will not delete the data
30+
- // in the backup store.
31+
+ // Delete the backup and restore resource after each test. And make sure that the data in the cluster is cleared.
32+
AfterEach(func() {
33+
- backup.Destroy()
34+
+ if backup != nil {
35+
+ backup.Destroy()
36+
+ }
37+
+ if restore != nil {
38+
+ restore.Destroy()
39+
+ }
40+
+
41+
+ // Delete the FDB cluster to have a clean start.
42+
+ Expect(fdbCluster.Destroy()).To(Succeed())
43+
})
44+
45+
When("the default backup system is used", func() {

0 commit comments

Comments
 (0)