Skip to content

Commit 3773521

Browse files
committed
Get ready for adding more verification tasks
1 parent d8296b4 commit 3773521

File tree

1 file changed

+34
-15
lines changed

1 file changed

+34
-15
lines changed

tests/e2e/hcp_external_cluster_backup_restore_suite_test.go

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package e2e_test
22

33
import (
44
"context"
5+
"errors"
56
"time"
67

78
"github.com/onsi/ginkgo/v2"
@@ -13,6 +14,10 @@ import (
1314
libhcp "github.com/openshift/oadp-operator/tests/e2e/lib/hcp"
1415
)
1516

17+
const (
18+
testNamespace = "test"
19+
)
20+
1621
// External cluster backup and restore tests will skip creating HostedCluster resource. They expect the cluster
1722
// to already have HostedCluster with a data plane.
1823
// The tests are skipped unless hc_backup_restore_mode flag is properly configured.
@@ -76,24 +81,38 @@ var _ = ginkgo.Describe("HCP external cluster Backup and Restore tests", ginkgo.
7681
})
7782

7883
func preBackupVerifyGuest() VerificationFunctionGuest {
79-
return func(crClientGuest client.Client, namespace string) error {
80-
ns := &corev1.Namespace{}
81-
ns.Name = "test"
82-
err := crClientGuest.Create(context.Background(), ns)
83-
if err != nil && !apierrors.IsAlreadyExists(err) {
84-
return err
85-
}
86-
return nil
84+
return func(crClientGuest client.Client, _ string) error {
85+
var errs []error
86+
errs = append(errs, createTestNamespace(crClientGuest))
87+
// Add more verifications here if needed
88+
return errors.Join(errs...)
8789
}
8890
}
8991

9092
func postBackupVerifyGuest() VerificationFunctionGuest {
91-
return func(crClientGuest client.Client, namespace string) error {
92-
ns := &corev1.Namespace{}
93-
err := crClientGuest.Get(context.Background(), client.ObjectKey{Name: "test"}, ns)
94-
if err != nil {
95-
return err
96-
}
97-
return nil
93+
return func(crClientGuest client.Client, _ string) error {
94+
var errs []error
95+
errs = append(errs, validateTestNamespace(crClientGuest))
96+
// Add more verifications here if needed
97+
return errors.Join(errs...)
98+
}
99+
}
100+
101+
func createTestNamespace(crClientGuest client.Client) error {
102+
ns := &corev1.Namespace{}
103+
ns.Name = testNamespace
104+
err := crClientGuest.Create(context.Background(), ns)
105+
if err != nil && !apierrors.IsAlreadyExists(err) {
106+
return err
107+
}
108+
return nil
109+
}
110+
111+
func validateTestNamespace(crClientGuest client.Client) error {
112+
ns := &corev1.Namespace{}
113+
err := crClientGuest.Get(context.Background(), client.ObjectKey{Name: testNamespace}, ns)
114+
if err != nil {
115+
return err
98116
}
117+
return nil
99118
}

0 commit comments

Comments
 (0)