Skip to content

Commit 98c7bd0

Browse files
nitishSrGitHub Co-pilot
authored andcommitted
Replace carriage return when getting provider secrets for registry + E2E changes (openshift#652)
* Replace carriage return when getting provider secrets for registry Co-authored-by: GitHub Co-pilot <[email protected]> * add tests * replaceCarriageReturn unit test * Registry credentials can use other secret names Co-authored-by: GitHub Co-pilot <[email protected]>
1 parent cf450d7 commit 98c7bd0

15 files changed

+288
-246
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ bin/
44
tests/e2e/e2e.test
55
cover.out
66
.DS_Store
7+
tests/e2e/templates/*.yaml
Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package e2e
1+
package e2e_test
22

33
import (
44
"errors"
@@ -10,19 +10,22 @@ import (
1010
. "github.com/onsi/ginkgo"
1111
. "github.com/onsi/ginkgo/extensions/table"
1212
. "github.com/onsi/gomega"
13+
. "github.com/openshift/oadp-operator/tests/e2e/lib"
14+
utils "github.com/openshift/oadp-operator/tests/e2e/utils"
1315
"sigs.k8s.io/controller-runtime/pkg/client"
1416
)
1517

1618
type VerificationFunction func(client.Client, string) error
1719

1820
var _ = Describe("AWS backup restore tests", func() {
21+
1922
var _ = BeforeEach(func() {
2023
testSuiteInstanceName := "ts-" + instanceName
2124
dpaCR.Name = testSuiteInstanceName
2225

23-
credData, err := readFile(cloud)
26+
credData, err := utils.ReadFile(cloud)
2427
Expect(err).NotTo(HaveOccurred())
25-
err = createCredentialsSecret(credData, namespace, getSecretRef(credSecretRef))
28+
err = CreateCredentialsSecret(credData, namespace, GetSecretRef(credSecretRef))
2629
Expect(err).NotTo(HaveOccurred())
2730
})
2831

@@ -39,19 +42,19 @@ var _ = Describe("AWS backup restore tests", func() {
3942
BackupRestoreType BackupRestoreType
4043
PreBackupVerify VerificationFunction
4144
PostRestoreVerify VerificationFunction
42-
MaxK8SVersion *k8sVersion
43-
MinK8SVersion *k8sVersion
45+
MaxK8SVersion *K8sVersion
46+
MinK8SVersion *K8sVersion
4447
}
4548

4649
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())
4851
return nil
4952
})
5053
mssqlReady := VerificationFunction(func(ocClient client.Client, namespace string) error {
5154
// 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")
5558
if err != nil {
5659
return err
5760
}
@@ -71,26 +74,22 @@ var _ = Describe("AWS backup restore tests", func() {
7174
Expect(err).NotTo(HaveOccurred())
7275

7376
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())
7578

76-
if brCase.BackupRestoreType == restic {
79+
if brCase.BackupRestoreType == RESTIC {
7780
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())
7982
}
8083

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())
8988
}
9089

9190
if dpaCR.CustomResource.Spec.BackupImages == nil || *dpaCR.CustomResource.Spec.BackupImages {
9291
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())
9493
}
9594
if notVersionTarget, reason := NotServerVersionTarget(brCase.MinK8SVersion, brCase.MaxK8SVersion); notVersionTarget {
9695
Skip(reason)
@@ -102,10 +101,10 @@ var _ = Describe("AWS backup restore tests", func() {
102101

103102
// install app
104103
log.Printf("Installing application for case %s", brCase.Name)
105-
err = installApplication(dpaCR.Client, brCase.ApplicationTemplate)
104+
err = InstallApplication(dpaCR.Client, brCase.ApplicationTemplate)
106105
Expect(err).ToNot(HaveOccurred())
107106
// 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())
109108

110109
// Run optional custom verification
111110
log.Printf("Running pre-backup function for case %s", brCase.Name)
@@ -114,41 +113,41 @@ var _ = Describe("AWS backup restore tests", func() {
114113

115114
// create backup
116115
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})
118117
Expect(err).ToNot(HaveOccurred())
119118

120119
// 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{}))
123122

124123
// check if backup succeeded
125-
succeeded, err := isBackupCompletedSuccessfully(dpaCR.Client, namespace, backupName)
124+
succeeded, err := IsBackupCompletedSuccessfully(dpaCR.Client, namespace, backupName)
126125
Expect(err).ToNot(HaveOccurred())
127126
Expect(succeeded).To(Equal(true))
128127
log.Printf("Backup for case %s succeeded", brCase.Name)
129128

130129
// uninstall app
131130
log.Printf("Uninstalling app for case %s", brCase.Name)
132-
err = uninstallApplication(dpaCR.Client, brCase.ApplicationTemplate)
131+
err = UninstallApplication(dpaCR.Client, brCase.ApplicationTemplate)
133132
Expect(err).ToNot(HaveOccurred())
134133

135134
// 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())
137136

138137
// run restore
139138
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)
141140
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{}))
144143

145144
// Check if restore succeeded
146-
succeeded, err = isRestoreCompletedSuccessfully(dpaCR.Client, namespace, restoreName)
145+
succeeded, err = IsRestoreCompletedSuccessfully(dpaCR.Client, namespace, restoreName)
147146
Expect(err).ToNot(HaveOccurred())
148147
Expect(succeeded).To(Equal(true))
149148

150149
// 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())
152151

153152
// Run optional custom verification
154153
log.Printf("Running post-restore function for case %s", brCase.Name)
@@ -157,15 +156,15 @@ var _ = Describe("AWS backup restore tests", func() {
157156

158157
// Test is successful, clean up everything
159158
log.Printf("Uninstalling application for case %s", brCase.Name)
160-
err = uninstallApplication(dpaCR.Client, brCase.ApplicationTemplate)
159+
err = UninstallApplication(dpaCR.Client, brCase.ApplicationTemplate)
161160
Expect(err).ToNot(HaveOccurred())
162161

163162
// 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())
165164

166-
if brCase.BackupRestoreType == csi {
165+
if brCase.BackupRestoreType == CSI {
167166
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")
169168
Expect(err).ToNot(HaveOccurred())
170169
}
171170

@@ -174,35 +173,35 @@ var _ = Describe("AWS backup restore tests", func() {
174173
ApplicationTemplate: "./sample-applications/mssql-persistent/mssql-persistent-csi-template.yaml",
175174
ApplicationNamespace: "mssql-persistent",
176175
Name: "mssql-e2e",
177-
BackupRestoreType: csi,
176+
BackupRestoreType: CSI,
178177
PreBackupVerify: mssqlReady,
179178
PostRestoreVerify: mssqlReady,
180179
}, nil),
181180
Entry("Parks application <4.8.0", BackupRestoreCase{
182181
ApplicationTemplate: "./sample-applications/parks-app/manifest.yaml",
183182
ApplicationNamespace: "parks-app",
184183
Name: "parks-e2e",
185-
BackupRestoreType: restic,
184+
BackupRestoreType: RESTIC,
186185
PreBackupVerify: parksAppReady,
187186
PostRestoreVerify: parksAppReady,
188-
MaxK8SVersion: &k8sVersionOcp47,
187+
MaxK8SVersion: &K8sVersionOcp47,
189188
}, nil),
190189
Entry("MSSQL application", BackupRestoreCase{
191190
ApplicationTemplate: "./sample-applications/mssql-persistent/mssql-persistent-template.yaml",
192191
ApplicationNamespace: "mssql-persistent",
193192
Name: "mssql-e2e",
194-
BackupRestoreType: restic,
193+
BackupRestoreType: RESTIC,
195194
PreBackupVerify: mssqlReady,
196195
PostRestoreVerify: mssqlReady,
197196
}, nil),
198197
Entry("Parks application >=4.8.0", BackupRestoreCase{
199198
ApplicationTemplate: "./sample-applications/parks-app/manifest4.8.yaml",
200199
ApplicationNamespace: "parks-app",
201200
Name: "parks-e2e",
202-
BackupRestoreType: restic,
201+
BackupRestoreType: RESTIC,
203202
PreBackupVerify: parksAppReady,
204203
PostRestoreVerify: parksAppReady,
205-
MinK8SVersion: &k8sVersionOcp48,
204+
MinK8SVersion: &K8sVersionOcp48,
206205
}, nil),
207206
)
208207
})

0 commit comments

Comments
 (0)