Skip to content

Commit 2203f87

Browse files
committed
Update
1 parent 5e3c44c commit 2203f87

2 files changed

Lines changed: 29 additions & 9 deletions

File tree

test/openshift/e2e/ginkgo/parallel/1-090_validate_permissions_test.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package parallel
1919
import (
2020
"context"
2121
"fmt"
22+
"strings"
2223

2324
. "github.com/onsi/ginkgo/v2"
2425
. "github.com/onsi/gomega"
@@ -699,10 +700,23 @@ spec:
699700

700701
Expect(yaml.UnmarshalStrict([]byte(csvString), expectedCsv)).To(Succeed())
701702

703+
By("looking for a ClusterServiceVersion for openshift-gitops across all namespaces")
704+
gitopsCSVsFound := []olmv1alpha1.ClusterServiceVersion{}
705+
var csvList olmv1alpha1.ClusterServiceVersionList
706+
Expect(k8sClient.List(ctx, &csvList)).To(Succeed())
707+
for index := range csvList.Items {
708+
csv := csvList.Items[index]
709+
if strings.Contains(csv.Name, "openshift-gitops-operator") {
710+
gitopsCSVsFound = append(gitopsCSVsFound, csv)
711+
}
712+
}
713+
By("if more than one possible CSV is found, we will fail.")
714+
Expect(gitopsCSVsFound).To(HaveLen(1), fmt.Sprintf("multiple CSVs were found: %v", gitopsCSVsFound))
715+
702716
actualCsv := &olmv1alpha1.ClusterServiceVersion{
703717
ObjectMeta: metav1.ObjectMeta{
704-
Name: "openshift-gitops-operator.v1.16.0",
705-
Namespace: "openshift-operators",
718+
Name: gitopsCSVsFound[0].Name,
719+
Namespace: gitopsCSVsFound[0].Namespace,
706720
},
707721
}
708722
Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(actualCsv), actualCsv)).To(Succeed())

test/openshift/e2e/ginkgo/sequential/1-034_validate_custom_roles_test.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,15 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
4040

4141
By("creating custom Argo CD Namespace test-1-034-custom")
4242
test1NS := fixture.CreateNamespace("test-1-034-custom")
43+
defer func() {
44+
Expect(k8sClient.Delete(ctx, &test1NS)).To(Succeed())
45+
}()
4346

4447
By("creating a test namespace with managed-by label, managed by test1 ns")
4548
customRoleNS := fixture.CreateManagedNamespace("custom-role-namespace", test1NS.Name)
49+
defer func() {
50+
Expect(k8sClient.Delete(ctx, &customRoleNS)).To(Succeed())
51+
}()
4652

4753
By("creating a sample cluster role for application-controller and server")
4854
clusterRole := &rbacv1.ClusterRole{
@@ -58,12 +64,19 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
5864
},
5965
}
6066
Expect(k8sClient.Create(ctx, clusterRole)).To(Succeed())
67+
defer func() {
68+
Expect(k8sClient.Delete(ctx, clusterRole)).To(Succeed())
69+
Eventually(clusterRole).Should(k8sFixture.NotExistByName())
70+
}()
6171

6272
By("creating an Argo CD instance in the new namespace")
6373
argoCDInTest1NS := &argov1beta1api.ArgoCD{
6474
ObjectMeta: metav1.ObjectMeta{Name: "argocd", Namespace: test1NS.Name},
6575
}
6676
Expect(k8sClient.Create(ctx, argoCDInTest1NS)).To(Succeed())
77+
defer func() {
78+
Expect(k8sClient.Delete(ctx, argoCDInTest1NS)).To(Succeed()) // clean up on exit
79+
}()
6780

6881
Eventually(argoCDInTest1NS, "3m", "5s").Should(argocdFixture.BeAvailable())
6982

@@ -177,13 +190,6 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
177190
Namespace: test1NS.Name,
178191
}}))
179192

180-
By("deleting namespaces created by the test")
181-
182-
Expect(k8sClient.Delete(ctx, argoCDInTest1NS)).To(Succeed())
183-
Expect(k8sClient.Delete(ctx, &test1NS)).To(Succeed())
184-
Expect(k8sClient.Delete(ctx, &customRoleNS)).To(Succeed())
185-
Expect(k8sClient.Delete(ctx, &rbacv1.ClusterRole{ObjectMeta: metav1.ObjectMeta{Name: "custom-argocd-role"}})).To(Succeed())
186-
187193
})
188194
})
189195
})

0 commit comments

Comments
 (0)