@@ -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