@@ -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,13 +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" {
84
+ if brCase .BackupRestoreType == restic {
60
85
if vel .CustomResource .Spec .EnableRestic == nil || * vel .CustomResource .Spec .EnableRestic {
61
86
log .Printf ("Waiting for restic pods to be running" )
62
87
Eventually (areResticPodsRunning (namespace ), timeoutMultiplier * time .Minute * 3 , time .Second * 5 ).Should (BeTrue ())
63
88
}
64
89
}
65
- if brCase .BackupRestoreType == " csi" {
90
+ if brCase .BackupRestoreType == csi {
66
91
log .Printf ("Creating VolumeSnapshot for CSI backuprestore of %s" , brCase .Name )
67
92
err = installApplication (vel .Client , "./sample-applications/mssql-persistent/volumeSnapshotClass.yaml" )
68
93
Expect (err ).ToNot (HaveOccurred ())
@@ -140,79 +165,49 @@ var _ = Describe("AWS backup restore tests", func() {
140
165
err = uninstallApplication (vel .Client , brCase .ApplicationTemplate )
141
166
Expect (err ).ToNot (HaveOccurred ())
142
167
143
- if brCase .BackupRestoreType == "csi" {
168
+ // Wait for namespace to be deleted
169
+ Eventually (isNamespaceDeleted (brCase .ApplicationNamespace ), timeoutMultiplier * time .Minute * 2 , time .Second * 5 ).Should (BeTrue ())
170
+
171
+ if brCase .BackupRestoreType == csi {
144
172
log .Printf ("Deleting VolumeSnapshot for CSI backuprestore of %s" , brCase .Name )
145
173
err = uninstallApplication (vel .Client , "./sample-applications/mssql-persistent/volumeSnapshotClass.yaml" )
146
174
Expect (err ).ToNot (HaveOccurred ())
147
175
}
176
+
148
177
},
149
178
Entry ("MSSQL application CSI" , BackupRestoreCase {
150
179
ApplicationTemplate : "./sample-applications/mssql-persistent/mssql-persistent-csi-template.yaml" ,
151
180
ApplicationNamespace : "mssql-persistent" ,
152
181
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
- }),
182
+ BackupRestoreType : csi ,
183
+ PreBackupVerify : mssqlReady ,
184
+ PostRestoreVerify : mssqlReady ,
168
185
}, nil ),
169
186
Entry ("Parks application <4.8.0" , BackupRestoreCase {
170
187
ApplicationTemplate : "./sample-applications/parks-app/manifest.yaml" ,
171
188
ApplicationNamespace : "parks-app" ,
172
189
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 ,
190
+ BackupRestoreType : restic ,
191
+ PreBackupVerify : parksAppReady ,
192
+ PostRestoreVerify : parksAppReady ,
193
+ MaxK8SVersion : & k8sVersionOcp47 ,
182
194
}, nil ),
183
195
Entry ("MSSQL application" , BackupRestoreCase {
184
196
ApplicationTemplate : "./sample-applications/mssql-persistent/mssql-persistent-template.yaml" ,
185
197
ApplicationNamespace : "mssql-persistent" ,
186
198
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
- }),
199
+ BackupRestoreType : restic ,
200
+ PreBackupVerify : mssqlReady ,
201
+ PostRestoreVerify : mssqlReady ,
202
202
}, nil ),
203
203
Entry ("Parks application >=4.8.0" , BackupRestoreCase {
204
204
ApplicationTemplate : "./sample-applications/parks-app/manifest4.8.yaml" ,
205
205
ApplicationNamespace : "parks-app" ,
206
206
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 ,
207
+ BackupRestoreType : restic ,
208
+ PreBackupVerify : parksAppReady ,
209
+ PostRestoreVerify : parksAppReady ,
210
+ MinK8SVersion : & k8sVersionOcp48 ,
216
211
}, nil ),
217
212
)
218
213
})
0 commit comments