1
- package e2e
1
+ package e2e_test
2
2
3
3
import (
4
4
"errors"
@@ -10,19 +10,22 @@ import (
10
10
. "github.com/onsi/ginkgo"
11
11
. "github.com/onsi/ginkgo/extensions/table"
12
12
. "github.com/onsi/gomega"
13
+ . "github.com/openshift/oadp-operator/tests/e2e/lib"
14
+ utils "github.com/openshift/oadp-operator/tests/e2e/utils"
13
15
"sigs.k8s.io/controller-runtime/pkg/client"
14
16
)
15
17
16
18
type VerificationFunction func (client.Client , string ) error
17
19
18
20
var _ = Describe ("AWS backup restore tests" , func () {
21
+
19
22
var _ = BeforeEach (func () {
20
23
testSuiteInstanceName := "ts-" + instanceName
21
24
dpaCR .Name = testSuiteInstanceName
22
25
23
- credData , err := readFile (cloud )
26
+ credData , err := utils . ReadFile (cloud )
24
27
Expect (err ).NotTo (HaveOccurred ())
25
- err = createCredentialsSecret (credData , namespace , getSecretRef (credSecretRef ))
28
+ err = CreateCredentialsSecret (credData , namespace , GetSecretRef (credSecretRef ))
26
29
Expect (err ).NotTo (HaveOccurred ())
27
30
})
28
31
@@ -39,19 +42,19 @@ var _ = Describe("AWS backup restore tests", func() {
39
42
BackupRestoreType BackupRestoreType
40
43
PreBackupVerify VerificationFunction
41
44
PostRestoreVerify VerificationFunction
42
- MaxK8SVersion * k8sVersion
43
- MinK8SVersion * k8sVersion
45
+ MaxK8SVersion * K8sVersion
46
+ MinK8SVersion * K8sVersion
44
47
}
45
48
46
49
parksAppReady := VerificationFunction (func (ocClient client.Client , namespace string ) error {
47
- Eventually (isDCReady (ocClient , "parks-app" , "restify" ), timeoutMultiplier * time .Minute * 10 , time .Second * 10 ).Should (BeTrue ())
50
+ Eventually (IsDCReady (ocClient , "parks-app" , "restify" ), timeoutMultiplier * time .Minute * 10 , time .Second * 10 ).Should (BeTrue ())
48
51
return nil
49
52
})
50
53
mssqlReady := VerificationFunction (func (ocClient client.Client , namespace string ) error {
51
54
// This test confirms that SCC restore logic in our plugin is working
52
- Eventually (isDCReady (ocClient , "mssql-persistent" , "mssql-deployment" ), timeoutMultiplier * time .Minute * 10 , time .Second * 10 ).Should (BeTrue ())
53
- Eventually (isDeploymentReady (ocClient , "mssql-persistent" , "mssql-app-deployment" ), timeoutMultiplier * time .Minute * 10 , time .Second * 10 ).Should (BeTrue ())
54
- exists , err := doesSCCExist (ocClient , "mssql-persistent-scc" )
55
+ Eventually (IsDCReady (ocClient , "mssql-persistent" , "mssql-deployment" ), timeoutMultiplier * time .Minute * 10 , time .Second * 10 ).Should (BeTrue ())
56
+ Eventually (IsDeploymentReady (ocClient , "mssql-persistent" , "mssql-app-deployment" ), timeoutMultiplier * time .Minute * 10 , time .Second * 10 ).Should (BeTrue ())
57
+ exists , err := DoesSCCExist (ocClient , "mssql-persistent-scc" )
55
58
if err != nil {
56
59
return err
57
60
}
@@ -71,26 +74,22 @@ var _ = Describe("AWS backup restore tests", func() {
71
74
Expect (err ).NotTo (HaveOccurred ())
72
75
73
76
log .Printf ("Waiting for velero pod to be running" )
74
- Eventually (areVeleroPodsRunning (namespace ), timeoutMultiplier * time .Minute * 3 , time .Second * 5 ).Should (BeTrue ())
77
+ Eventually (AreVeleroPodsRunning (namespace ), timeoutMultiplier * time .Minute * 3 , time .Second * 5 ).Should (BeTrue ())
75
78
76
- if brCase .BackupRestoreType == restic {
79
+ if brCase .BackupRestoreType == RESTIC {
77
80
log .Printf ("Waiting for restic pods to be running" )
78
- Eventually (areResticPodsRunning (namespace ), timeoutMultiplier * time .Minute * 3 , time .Second * 5 ).Should (BeTrue ())
81
+ Eventually (AreResticPodsRunning (namespace ), timeoutMultiplier * time .Minute * 3 , time .Second * 5 ).Should (BeTrue ())
79
82
}
80
83
81
- if brCase .BackupRestoreType == csi {
82
- if clusterProfile == "aws" {
83
- log .Printf ("Creating VolumeSnapshot for CSI backuprestore of %s" , brCase .Name )
84
- err = installApplication (dpaCR .Client , "./sample-applications/gp2-csi/volumeSnapshotClass.yaml" )
85
- Expect (err ).ToNot (HaveOccurred ())
86
- } else {
87
- Skip ("CSI testing is not provided for this cluster provider." )
88
- }
84
+ if brCase .BackupRestoreType == CSI {
85
+ log .Printf ("Creating VolumeSnapshot for CSI backuprestore of %s" , brCase .Name )
86
+ err = InstallApplication (dpaCR .Client , "./sample-applications/gp2-csi/volumeSnapshotClass.yaml" )
87
+ Expect (err ).ToNot (HaveOccurred ())
89
88
}
90
89
91
90
if dpaCR .CustomResource .Spec .BackupImages == nil || * dpaCR .CustomResource .Spec .BackupImages {
92
91
log .Printf ("Waiting for registry pods to be running" )
93
- Eventually (areRegistryDeploymentsAvailable (namespace ), timeoutMultiplier * time .Minute * 3 , time .Second * 5 ).Should (BeTrue ())
92
+ Eventually (AreRegistryDeploymentsAvailable (namespace ), timeoutMultiplier * time .Minute * 3 , time .Second * 5 ).Should (BeTrue ())
94
93
}
95
94
if notVersionTarget , reason := NotServerVersionTarget (brCase .MinK8SVersion , brCase .MaxK8SVersion ); notVersionTarget {
96
95
Skip (reason )
@@ -102,10 +101,10 @@ var _ = Describe("AWS backup restore tests", func() {
102
101
103
102
// install app
104
103
log .Printf ("Installing application for case %s" , brCase .Name )
105
- err = installApplication (dpaCR .Client , brCase .ApplicationTemplate )
104
+ err = InstallApplication (dpaCR .Client , brCase .ApplicationTemplate )
106
105
Expect (err ).ToNot (HaveOccurred ())
107
106
// wait for pods to be running
108
- Eventually (areApplicationPodsRunning (brCase .ApplicationNamespace ), timeoutMultiplier * time .Minute * 9 , time .Second * 5 ).Should (BeTrue ())
107
+ Eventually (AreApplicationPodsRunning (brCase .ApplicationNamespace ), timeoutMultiplier * time .Minute * 9 , time .Second * 5 ).Should (BeTrue ())
109
108
110
109
// Run optional custom verification
111
110
log .Printf ("Running pre-backup function for case %s" , brCase .Name )
@@ -114,41 +113,41 @@ var _ = Describe("AWS backup restore tests", func() {
114
113
115
114
// create backup
116
115
log .Printf ("Creating backup %s for case %s" , backupName , brCase .Name )
117
- err = createBackupForNamespaces (dpaCR .Client , namespace , backupName , []string {brCase .ApplicationNamespace })
116
+ err = CreateBackupForNamespaces (dpaCR .Client , namespace , backupName , []string {brCase .ApplicationNamespace })
118
117
Expect (err ).ToNot (HaveOccurred ())
119
118
120
119
// wait for backup to not be running
121
- Eventually (isBackupDone (dpaCR .Client , namespace , backupName ), timeoutMultiplier * time .Minute * 4 , time .Second * 10 ).Should (BeTrue ())
122
- Expect (getVeleroContainerFailureLogs (dpaCR .Namespace )).To (Equal ([]string {}))
120
+ Eventually (IsBackupDone (dpaCR .Client , namespace , backupName ), timeoutMultiplier * time .Minute * 4 , time .Second * 10 ).Should (BeTrue ())
121
+ Expect (GetVeleroContainerFailureLogs (dpaCR .Namespace )).To (Equal ([]string {}))
123
122
124
123
// check if backup succeeded
125
- succeeded , err := isBackupCompletedSuccessfully (dpaCR .Client , namespace , backupName )
124
+ succeeded , err := IsBackupCompletedSuccessfully (dpaCR .Client , namespace , backupName )
126
125
Expect (err ).ToNot (HaveOccurred ())
127
126
Expect (succeeded ).To (Equal (true ))
128
127
log .Printf ("Backup for case %s succeeded" , brCase .Name )
129
128
130
129
// uninstall app
131
130
log .Printf ("Uninstalling app for case %s" , brCase .Name )
132
- err = uninstallApplication (dpaCR .Client , brCase .ApplicationTemplate )
131
+ err = UninstallApplication (dpaCR .Client , brCase .ApplicationTemplate )
133
132
Expect (err ).ToNot (HaveOccurred ())
134
133
135
134
// Wait for namespace to be deleted
136
- Eventually (isNamespaceDeleted (brCase .ApplicationNamespace ), timeoutMultiplier * time .Minute * 2 , time .Second * 5 ).Should (BeTrue ())
135
+ Eventually (IsNamespaceDeleted (brCase .ApplicationNamespace ), timeoutMultiplier * time .Minute * 2 , time .Second * 5 ).Should (BeTrue ())
137
136
138
137
// run restore
139
138
log .Printf ("Creating restore %s for case %s" , restoreName , brCase .Name )
140
- err = createRestoreFromBackup (dpaCR .Client , namespace , backupName , restoreName )
139
+ err = CreateRestoreFromBackup (dpaCR .Client , namespace , backupName , restoreName )
141
140
Expect (err ).ToNot (HaveOccurred ())
142
- Eventually (isRestoreDone (dpaCR .Client , namespace , restoreName ), timeoutMultiplier * time .Minute * 4 , time .Second * 10 ).Should (BeTrue ())
143
- Expect (getVeleroContainerFailureLogs (dpaCR .Namespace )).To (Equal ([]string {}))
141
+ Eventually (IsRestoreDone (dpaCR .Client , namespace , restoreName ), timeoutMultiplier * time .Minute * 4 , time .Second * 10 ).Should (BeTrue ())
142
+ Expect (GetVeleroContainerFailureLogs (dpaCR .Namespace )).To (Equal ([]string {}))
144
143
145
144
// Check if restore succeeded
146
- succeeded , err = isRestoreCompletedSuccessfully (dpaCR .Client , namespace , restoreName )
145
+ succeeded , err = IsRestoreCompletedSuccessfully (dpaCR .Client , namespace , restoreName )
147
146
Expect (err ).ToNot (HaveOccurred ())
148
147
Expect (succeeded ).To (Equal (true ))
149
148
150
149
// verify app is running
151
- Eventually (areApplicationPodsRunning (brCase .ApplicationNamespace ), timeoutMultiplier * time .Minute * 9 , time .Second * 5 ).Should (BeTrue ())
150
+ Eventually (AreApplicationPodsRunning (brCase .ApplicationNamespace ), timeoutMultiplier * time .Minute * 9 , time .Second * 5 ).Should (BeTrue ())
152
151
153
152
// Run optional custom verification
154
153
log .Printf ("Running post-restore function for case %s" , brCase .Name )
@@ -157,15 +156,15 @@ var _ = Describe("AWS backup restore tests", func() {
157
156
158
157
// Test is successful, clean up everything
159
158
log .Printf ("Uninstalling application for case %s" , brCase .Name )
160
- err = uninstallApplication (dpaCR .Client , brCase .ApplicationTemplate )
159
+ err = UninstallApplication (dpaCR .Client , brCase .ApplicationTemplate )
161
160
Expect (err ).ToNot (HaveOccurred ())
162
161
163
162
// Wait for namespace to be deleted
164
- Eventually (isNamespaceDeleted (brCase .ApplicationNamespace ), timeoutMultiplier * time .Minute * 2 , time .Second * 5 ).Should (BeTrue ())
163
+ Eventually (IsNamespaceDeleted (brCase .ApplicationNamespace ), timeoutMultiplier * time .Minute * 2 , time .Second * 5 ).Should (BeTrue ())
165
164
166
- if brCase .BackupRestoreType == csi {
165
+ if brCase .BackupRestoreType == CSI {
167
166
log .Printf ("Deleting VolumeSnapshot for CSI backuprestore of %s" , brCase .Name )
168
- err = uninstallApplication (dpaCR .Client , "./sample-applications/gp2-csi/volumeSnapshotClass.yaml" )
167
+ err = UninstallApplication (dpaCR .Client , "./sample-applications/gp2-csi/volumeSnapshotClass.yaml" )
169
168
Expect (err ).ToNot (HaveOccurred ())
170
169
}
171
170
@@ -174,35 +173,35 @@ var _ = Describe("AWS backup restore tests", func() {
174
173
ApplicationTemplate : "./sample-applications/mssql-persistent/mssql-persistent-csi-template.yaml" ,
175
174
ApplicationNamespace : "mssql-persistent" ,
176
175
Name : "mssql-e2e" ,
177
- BackupRestoreType : csi ,
176
+ BackupRestoreType : CSI ,
178
177
PreBackupVerify : mssqlReady ,
179
178
PostRestoreVerify : mssqlReady ,
180
179
}, nil ),
181
180
Entry ("Parks application <4.8.0" , BackupRestoreCase {
182
181
ApplicationTemplate : "./sample-applications/parks-app/manifest.yaml" ,
183
182
ApplicationNamespace : "parks-app" ,
184
183
Name : "parks-e2e" ,
185
- BackupRestoreType : restic ,
184
+ BackupRestoreType : RESTIC ,
186
185
PreBackupVerify : parksAppReady ,
187
186
PostRestoreVerify : parksAppReady ,
188
- MaxK8SVersion : & k8sVersionOcp47 ,
187
+ MaxK8SVersion : & K8sVersionOcp47 ,
189
188
}, nil ),
190
189
Entry ("MSSQL application" , BackupRestoreCase {
191
190
ApplicationTemplate : "./sample-applications/mssql-persistent/mssql-persistent-template.yaml" ,
192
191
ApplicationNamespace : "mssql-persistent" ,
193
192
Name : "mssql-e2e" ,
194
- BackupRestoreType : restic ,
193
+ BackupRestoreType : RESTIC ,
195
194
PreBackupVerify : mssqlReady ,
196
195
PostRestoreVerify : mssqlReady ,
197
196
}, nil ),
198
197
Entry ("Parks application >=4.8.0" , BackupRestoreCase {
199
198
ApplicationTemplate : "./sample-applications/parks-app/manifest4.8.yaml" ,
200
199
ApplicationNamespace : "parks-app" ,
201
200
Name : "parks-e2e" ,
202
- BackupRestoreType : restic ,
201
+ BackupRestoreType : RESTIC ,
203
202
PreBackupVerify : parksAppReady ,
204
203
PostRestoreVerify : parksAppReady ,
205
- MinK8SVersion : & k8sVersionOcp48 ,
204
+ MinK8SVersion : & K8sVersionOcp48 ,
206
205
}, nil ),
207
206
)
208
207
})
0 commit comments