@@ -42,8 +42,14 @@ var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
4242 Context ("1-025-validate-managed-by-change" , func () {
4343
4444 var (
45- ctx context.Context
46- k8sClient client.Client
45+ ctx context.Context
46+ k8sClient client.Client
47+ test_1_25_argo1 * corev1.Namespace
48+ test_1_25_argo2 * corev1.Namespace
49+ test_1_25_target * corev1.Namespace
50+ cleanup1 func ()
51+ cleanup2 func ()
52+ cleanup3 func ()
4753 )
4854
4955 BeforeEach (func () {
@@ -52,27 +58,39 @@ var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
5258 ctx = context .Background ()
5359 })
5460
61+ AfterEach (func () {
62+
63+ fixture .OutputDebugOnFail ("test-1-25-argo1" , "test-1-25-argo2" , "test-1-25-target" )
64+
65+ if cleanup3 != nil {
66+ cleanup3 ()
67+ }
68+ if cleanup2 != nil {
69+ cleanup2 ()
70+ }
71+ if cleanup1 != nil {
72+ cleanup1 ()
73+ }
74+ })
75+
5576 It ("ensuring that managed-by label can transition between two different Argo CD instances" , func () {
5677
5778 By ("creating 3 namespaces: 2 contain argo cd instances, and one will be managed by one of those namespaces" )
5879
59- test_1_25_argo1NS , cleanup1 := fixture .CreateNamespaceWithCleanupFunc ("test-1-25-argo1" )
60- defer cleanup1 ()
80+ test_1_25_argo1 , cleanup1 = fixture .CreateNamespaceWithCleanupFunc ("test-1-25-argo1" )
6181
62- test_1_25_argo2NS , cleanup2 := fixture .CreateNamespaceWithCleanupFunc ("test-1-25-argo2" )
63- defer cleanup2 ()
82+ test_1_25_argo2 , cleanup2 = fixture .CreateNamespaceWithCleanupFunc ("test-1-25-argo2" )
6483
65- test_1_25_targetNS , cleanup3 := fixture .CreateManagedNamespaceWithCleanupFunc ("test-1-25-target" , test_1_25_argo1NS .Name )
66- defer cleanup3 ()
84+ test_1_25_target , cleanup3 = fixture .CreateManagedNamespaceWithCleanupFunc ("test-1-25-target" , test_1_25_argo1 .Name )
6785
6886 argoCDtest_1_25_argo1 := & argov1beta1api.ArgoCD {
69- ObjectMeta : metav1.ObjectMeta {Name : "argocd" , Namespace : test_1_25_argo1NS .Name },
87+ ObjectMeta : metav1.ObjectMeta {Name : "argocd" , Namespace : test_1_25_argo1 .Name },
7088 Spec : argov1beta1api.ArgoCDSpec {},
7189 }
7290 Expect (k8sClient .Create (ctx , argoCDtest_1_25_argo1 )).To (Succeed ())
7391
7492 argoCDtest_1_25_argo2 := & argov1beta1api.ArgoCD {
75- ObjectMeta : metav1.ObjectMeta {Name : "argocd" , Namespace : test_1_25_argo2NS .Name },
93+ ObjectMeta : metav1.ObjectMeta {Name : "argocd" , Namespace : test_1_25_argo2 .Name },
7694 Spec : argov1beta1api.ArgoCDSpec {},
7795 }
7896 Expect (k8sClient .Create (ctx , argoCDtest_1_25_argo2 )).To (Succeed ())
@@ -91,7 +109,7 @@ var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
91109 TargetRevision : "HEAD" ,
92110 },
93111 Destination : argocdv1alpha1.ApplicationDestination {
94- Namespace : test_1_25_targetNS .Name ,
112+ Namespace : test_1_25_target .Name ,
95113 Server : "https://kubernetes.default.svc" ,
96114 },
97115 Project : "default" ,
@@ -104,20 +122,20 @@ var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
104122 Expect (k8sClient .Create (ctx , app )).To (Succeed ())
105123
106124 By ("waiting for all pods to be ready in both Argo CD namespaces" )
107- fixture .WaitForAllPodsInTheNamespaceToBeReady (test_1_25_argo1NS .Name , k8sClient )
108- fixture .WaitForAllPodsInTheNamespaceToBeReady (test_1_25_argo2NS .Name , k8sClient )
125+ fixture .WaitForAllPodsInTheNamespaceToBeReady (test_1_25_argo1 .Name , k8sClient )
126+ fixture .WaitForAllPodsInTheNamespaceToBeReady (test_1_25_argo2 .Name , k8sClient )
109127
110128 By ("verifying Argo CD Application deployed as expected and is healthy and synced" )
111129 Eventually (app , "3m" , "5s" ).Should (appFixture .HaveHealthStatusCode (health .HealthStatusHealthy ))
112130 Eventually (app , "60s" , "5s" ).Should (appFixture .HaveSyncStatusCode (argocdv1alpha1 .SyncStatusCodeSynced ))
113131
114132 By ("update 'test_1_25_target' NS to be managed by the second Argo CD instance, rather than the first" )
115- namespaceFixture .Update (test_1_25_targetNS , func (n * corev1.Namespace ) {
133+ namespaceFixture .Update (test_1_25_target , func (n * corev1.Namespace ) {
116134 n .Labels ["argocd.argoproj.io/managed-by" ] = "test-1-25-argo2"
117135 })
118136
119137 By ("verifying that RoleBinding in 'test_1_25_target' is updated to the second namespace" )
120- roleBindingIntest_1_25_targetNS := & rbacv1.RoleBinding {ObjectMeta : metav1.ObjectMeta {Name : "argocd-argocd-application-controller" , Namespace : test_1_25_targetNS .Name }}
138+ roleBindingIntest_1_25_targetNS := & rbacv1.RoleBinding {ObjectMeta : metav1.ObjectMeta {Name : "argocd-argocd-application-controller" , Namespace : test_1_25_target .Name }}
121139 Eventually (roleBindingIntest_1_25_targetNS ).Should (rolebindingFixture .HaveSubject (rbacv1.Subject {
122140 Kind : "ServiceAccount" ,
123141 Name : "argocd-argocd-application-controller" ,
@@ -142,7 +160,7 @@ var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
142160 TargetRevision : "HEAD" ,
143161 },
144162 Destination : argocdv1alpha1.ApplicationDestination {
145- Namespace : test_1_25_targetNS .Name ,
163+ Namespace : test_1_25_target .Name ,
146164 Server : "https://kubernetes.default.svc" ,
147165 },
148166 Project : "default" ,
@@ -155,12 +173,12 @@ var _ = Describe("GitOps Operator Parallel E2E Tests", func() {
155173 Expect (k8sClient .Create (ctx , app_argo2 )).To (Succeed ())
156174
157175 By ("First Argo CD instance Application should be unhealthy, because it is no longer managing the namespace" )
158- Eventually (app , "4m" , "1s " ).Should (appFixture .HaveHealthStatusCode (health .HealthStatusMissing ))
159- Eventually (app , "4m" , "1s " ).Should (appFixture .HaveSyncStatusCode (argocdv1alpha1 .SyncStatusCodeUnknown ))
176+ Eventually (app , "4m" , "5s " ).Should (appFixture .HaveHealthStatusCode (health .HealthStatusMissing ))
177+ Eventually (app , "4m" , "5s " ).Should (appFixture .HaveSyncStatusCode (argocdv1alpha1 .SyncStatusCodeUnknown ))
160178
161179 By ("Second Argo CD instance Application should be healthy, because it is now managing the namespace" )
162- Eventually (app_argo2 , "60s " , "1s " ).Should (appFixture .HaveHealthStatusCode (health .HealthStatusHealthy ))
163- Eventually (app_argo2 , "60s " , "1s " ).Should (appFixture .HaveSyncStatusCode (argocdv1alpha1 .SyncStatusCodeSynced ))
180+ Eventually (app_argo2 , "4m " , "5s " ).Should (appFixture .HaveHealthStatusCode (health .HealthStatusHealthy ))
181+ Eventually (app_argo2 , "4m " , "5s " ).Should (appFixture .HaveSyncStatusCode (argocdv1alpha1 .SyncStatusCodeSynced ))
164182 })
165183
166184 })
0 commit comments