@@ -13,6 +13,15 @@ import (
13
13
"sigs.k8s.io/controller-runtime/pkg/client"
14
14
)
15
15
16
+ type BackupRestoreType string
17
+
18
+ const (
19
+ csi BackupRestoreType = "csi"
20
+ restic BackupRestoreType = "restic"
21
+ )
22
+
23
+ type VerificationFunction func (client.Client , string ) error
24
+
16
25
var _ = Describe ("AWS backup restore tests" , func () {
17
26
var _ = BeforeEach (func () {
18
27
testSuiteInstanceName := "ts-" + instanceName
@@ -31,19 +40,35 @@ var _ = Describe("AWS backup restore tests", func() {
31
40
32
41
})
33
42
34
- type VerificationFunction func (client.Client , string ) error
35
-
36
43
type BackupRestoreCase struct {
37
44
ApplicationTemplate string
38
45
ApplicationNamespace string
39
46
Name string
40
- BackupRestoreType string
47
+ BackupRestoreType BackupRestoreType
41
48
PreBackupVerify VerificationFunction
42
49
PostRestoreVerify VerificationFunction
43
50
MaxK8SVersion * k8sVersion
44
51
MinK8SVersion * k8sVersion
45
52
}
46
53
54
+ parksAppReady := VerificationFunction (func (ocClient client.Client , namespace string ) error {
55
+ Eventually (isDCReady (ocClient , "parks-app" , "restify" ), timeoutMultiplier * time .Minute * 10 , time .Second * 10 ).Should (BeTrue ())
56
+ return nil
57
+ })
58
+ mssqlReady := VerificationFunction (func (ocClient client.Client , namespace string ) error {
59
+ // This test confirms that SCC restore logic in our plugin is working
60
+ Eventually (isDCReady (ocClient , "mssql-persistent" , "mssql-deployment" ), timeoutMultiplier * time .Minute * 10 , time .Second * 10 ).Should (BeTrue ())
61
+ Eventually (isDeploymentReady (ocClient , "mssql-persistent" , "mssql-app-deployment" ), timeoutMultiplier * time .Minute * 10 , time .Second * 10 ).Should (BeTrue ())
62
+ exists , err := doesSCCExist (ocClient , "mssql-persistent-scc" )
63
+ if err != nil {
64
+ return err
65
+ }
66
+ if ! exists {
67
+ return errors .New ("did not find MSSQL scc" )
68
+ }
69
+ return nil
70
+ })
71
+
47
72
DescribeTable ("backup and restore applications" ,
48
73
func (brCase BackupRestoreCase , expectedErr error ) {
49
74
@@ -56,15 +81,13 @@ var _ = Describe("AWS backup restore tests", func() {
56
81
log .Printf ("Waiting for velero pod to be running" )
57
82
Eventually (isVeleroPodRunning (namespace ), timeoutMultiplier * time .Minute * 3 , time .Second * 5 ).Should (BeTrue ())
58
83
59
- if brCase .BackupRestoreType == "restic" {
60
- if vel .CustomResource .Spec .EnableRestic == nil || * vel .CustomResource .Spec .EnableRestic {
61
- log .Printf ("Waiting for restic pods to be running" )
62
- Eventually (areResticPodsRunning (namespace ), timeoutMultiplier * time .Minute * 3 , time .Second * 5 ).Should (BeTrue ())
63
- }
84
+ if brCase .BackupRestoreType == restic {
85
+ log .Printf ("Waiting for restic pods to be running" )
86
+ Eventually (areResticPodsRunning (namespace ), timeoutMultiplier * time .Minute * 3 , time .Second * 5 ).Should (BeTrue ())
64
87
}
65
- if brCase .BackupRestoreType == " csi" {
88
+ if brCase .BackupRestoreType == csi {
66
89
log .Printf ("Creating VolumeSnapshot for CSI backuprestore of %s" , brCase .Name )
67
- err = installApplication (vel .Client , "./sample-applications/mssql-persistent /volumeSnapshotClass.yaml" )
90
+ err = installApplication (vel .Client , "./sample-applications/gp2-csi /volumeSnapshotClass.yaml" )
68
91
Expect (err ).ToNot (HaveOccurred ())
69
92
}
70
93
@@ -140,79 +163,49 @@ var _ = Describe("AWS backup restore tests", func() {
140
163
err = uninstallApplication (vel .Client , brCase .ApplicationTemplate )
141
164
Expect (err ).ToNot (HaveOccurred ())
142
165
143
- if brCase .BackupRestoreType == "csi" {
166
+ // Wait for namespace to be deleted
167
+ Eventually (isNamespaceDeleted (brCase .ApplicationNamespace ), timeoutMultiplier * time .Minute * 2 , time .Second * 5 ).Should (BeTrue ())
168
+
169
+ if brCase .BackupRestoreType == csi {
144
170
log .Printf ("Deleting VolumeSnapshot for CSI backuprestore of %s" , brCase .Name )
145
- err = uninstallApplication (vel .Client , "./sample-applications/mssql-persistent /volumeSnapshotClass.yaml" )
171
+ err = uninstallApplication (vel .Client , "./sample-applications/gp2-csi /volumeSnapshotClass.yaml" )
146
172
Expect (err ).ToNot (HaveOccurred ())
147
173
}
174
+
148
175
},
149
176
Entry ("MSSQL application CSI" , BackupRestoreCase {
150
177
ApplicationTemplate : "./sample-applications/mssql-persistent/mssql-persistent-csi-template.yaml" ,
151
178
ApplicationNamespace : "mssql-persistent" ,
152
179
Name : "mssql-e2e" ,
153
- BackupRestoreType : "csi" ,
154
- PreBackupVerify : VerificationFunction (func (ocClient client.Client , namespace string ) error {
155
- return nil
156
- }),
157
- PostRestoreVerify : VerificationFunction (func (ocClient client.Client , namespace string ) error {
158
- // This test confirms that SCC restore logic in our plugin is working
159
- exists , err := doesSCCExist (ocClient , "mssql-persistent-scc" )
160
- if err != nil {
161
- return err
162
- }
163
- if ! exists {
164
- return errors .New ("did not find MSSQL scc after restore" )
165
- }
166
- return nil
167
- }),
180
+ BackupRestoreType : csi ,
181
+ PreBackupVerify : mssqlReady ,
182
+ PostRestoreVerify : mssqlReady ,
168
183
}, nil ),
169
184
Entry ("Parks application <4.8.0" , BackupRestoreCase {
170
185
ApplicationTemplate : "./sample-applications/parks-app/manifest.yaml" ,
171
186
ApplicationNamespace : "parks-app" ,
172
187
Name : "parks-e2e" ,
173
- BackupRestoreType : "restic" ,
174
- PreBackupVerify : VerificationFunction (func (ocClient client.Client , namespace string ) error {
175
- Eventually (isDCReady (ocClient , "parks-app" , "restify" ), timeoutMultiplier * time .Minute * 10 , time .Second * 10 ).Should (BeTrue ())
176
- return nil
177
- }),
178
- PostRestoreVerify : VerificationFunction (func (ocClient client.Client , namespace string ) error {
179
- return nil
180
- }),
181
- MaxK8SVersion : & k8sVersionOcp47 ,
188
+ BackupRestoreType : restic ,
189
+ PreBackupVerify : parksAppReady ,
190
+ PostRestoreVerify : parksAppReady ,
191
+ MaxK8SVersion : & k8sVersionOcp47 ,
182
192
}, nil ),
183
193
Entry ("MSSQL application" , BackupRestoreCase {
184
194
ApplicationTemplate : "./sample-applications/mssql-persistent/mssql-persistent-template.yaml" ,
185
195
ApplicationNamespace : "mssql-persistent" ,
186
196
Name : "mssql-e2e" ,
187
- BackupRestoreType : "restic" ,
188
- PreBackupVerify : VerificationFunction (func (ocClient client.Client , namespace string ) error {
189
- return nil
190
- }),
191
- PostRestoreVerify : VerificationFunction (func (ocClient client.Client , namespace string ) error {
192
- // This test confirms that SCC restore logic in our plugin is working
193
- exists , err := doesSCCExist (ocClient , "mssql-persistent-scc" )
194
- if err != nil {
195
- return err
196
- }
197
- if ! exists {
198
- return errors .New ("did not find MSSQL scc after restore" )
199
- }
200
- return nil
201
- }),
197
+ BackupRestoreType : restic ,
198
+ PreBackupVerify : mssqlReady ,
199
+ PostRestoreVerify : mssqlReady ,
202
200
}, nil ),
203
201
Entry ("Parks application >=4.8.0" , BackupRestoreCase {
204
202
ApplicationTemplate : "./sample-applications/parks-app/manifest4.8.yaml" ,
205
203
ApplicationNamespace : "parks-app" ,
206
204
Name : "parks-e2e" ,
207
- BackupRestoreType : "restic" ,
208
- PreBackupVerify : VerificationFunction (func (ocClient client.Client , namespace string ) error {
209
- Eventually (isDCReady (ocClient , "parks-app" , "restify" ), timeoutMultiplier * time .Minute * 10 , time .Second * 10 ).Should (BeTrue ())
210
- return nil
211
- }),
212
- PostRestoreVerify : VerificationFunction (func (ocClient client.Client , namespace string ) error {
213
- return nil
214
- }),
215
- MinK8SVersion : & k8sVersionOcp48 ,
205
+ BackupRestoreType : restic ,
206
+ PreBackupVerify : parksAppReady ,
207
+ PostRestoreVerify : parksAppReady ,
208
+ MinK8SVersion : & k8sVersionOcp48 ,
216
209
}, nil ),
217
210
)
218
211
})
0 commit comments