Skip to content

Commit 19005cb

Browse files
authored
fix: argocd-operator missing role and enhance e2e verifications (#118)
Signed-off-by: Mike Ng <[email protected]>
1 parent 1036aec commit 19005cb

File tree

3 files changed

+448
-17
lines changed

3 files changed

+448
-17
lines changed

internal/addon/charts/argocd-agent-addon/templates/operator.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,8 @@ spec:
403403
command:
404404
- /manager
405405
env:
406+
- name: ARGOCD_CLUSTER_CONFIG_NAMESPACES
407+
value: "*"
406408
- name: WATCH_NAMESPACE
407409
valueFrom:
408410
fieldRef:

test/e2e/addon_e2e_deploy_test.go

Lines changed: 213 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,127 @@ var _ = Describe("ArgoCD Agent Addon Deployment E2E", Label("deploy"), Ordered,
122122
}).Should(Succeed())
123123
})
124124

125+
It("should verify GitOpsCluster status conditions on hub", func() {
126+
By("verifying GitOpsCluster exists")
127+
Eventually(func(g Gomega) {
128+
cmd := exec.Command("kubectl", "--context", hubContext,
129+
"get", "gitopscluster", "gitops-cluster",
130+
"-n", argoCDNamespace)
131+
_, err := utils.Run(cmd)
132+
g.Expect(err).NotTo(HaveOccurred())
133+
}).Should(Succeed())
134+
135+
By("verifying GitOpsCluster RBACReady condition")
136+
Eventually(func(g Gomega) {
137+
cmd := exec.Command("kubectl", "--context", hubContext,
138+
"get", "gitopscluster", "gitops-cluster",
139+
"-n", argoCDNamespace,
140+
"-o", "jsonpath={.status.conditions[?(@.type=='RBACReady')].status}")
141+
output, err := utils.Run(cmd)
142+
g.Expect(err).NotTo(HaveOccurred())
143+
g.Expect(output).To(Equal("True"))
144+
}).Should(Succeed())
145+
146+
By("verifying GitOpsCluster ServerDiscovered condition")
147+
Eventually(func(g Gomega) {
148+
cmd := exec.Command("kubectl", "--context", hubContext,
149+
"get", "gitopscluster", "gitops-cluster",
150+
"-n", argoCDNamespace,
151+
"-o", "jsonpath={.status.conditions[?(@.type=='ServerDiscovered')].status}")
152+
output, err := utils.Run(cmd)
153+
g.Expect(err).NotTo(HaveOccurred())
154+
g.Expect(output).To(Equal("True"))
155+
}).Should(Succeed())
156+
157+
By("verifying GitOpsCluster JWTSecretReady condition")
158+
Eventually(func(g Gomega) {
159+
cmd := exec.Command("kubectl", "--context", hubContext,
160+
"get", "gitopscluster", "gitops-cluster",
161+
"-n", argoCDNamespace,
162+
"-o", "jsonpath={.status.conditions[?(@.type=='JWTSecretReady')].status}")
163+
output, err := utils.Run(cmd)
164+
g.Expect(err).NotTo(HaveOccurred())
165+
g.Expect(output).To(Equal("True"))
166+
}).Should(Succeed())
167+
168+
By("verifying GitOpsCluster CACertificateReady condition")
169+
Eventually(func(g Gomega) {
170+
cmd := exec.Command("kubectl", "--context", hubContext,
171+
"get", "gitopscluster", "gitops-cluster",
172+
"-n", argoCDNamespace,
173+
"-o", "jsonpath={.status.conditions[?(@.type=='CACertificateReady')].status}")
174+
output, err := utils.Run(cmd)
175+
g.Expect(err).NotTo(HaveOccurred())
176+
g.Expect(output).To(Equal("True"))
177+
}).Should(Succeed())
178+
179+
By("verifying GitOpsCluster PrincipalCertificateReady condition")
180+
Eventually(func(g Gomega) {
181+
cmd := exec.Command("kubectl", "--context", hubContext,
182+
"get", "gitopscluster", "gitops-cluster",
183+
"-n", argoCDNamespace,
184+
"-o", "jsonpath={.status.conditions[?(@.type=='PrincipalCertificateReady')].status}")
185+
output, err := utils.Run(cmd)
186+
g.Expect(err).NotTo(HaveOccurred())
187+
g.Expect(output).To(Equal("True"))
188+
}).Should(Succeed())
189+
190+
By("verifying GitOpsCluster ResourceProxyCertificateReady condition")
191+
Eventually(func(g Gomega) {
192+
cmd := exec.Command("kubectl", "--context", hubContext,
193+
"get", "gitopscluster", "gitops-cluster",
194+
"-n", argoCDNamespace,
195+
"-o", "jsonpath={.status.conditions[?(@.type=='ResourceProxyCertificateReady')].status}")
196+
output, err := utils.Run(cmd)
197+
g.Expect(err).NotTo(HaveOccurred())
198+
g.Expect(output).To(Equal("True"))
199+
}).Should(Succeed())
200+
201+
By("verifying GitOpsCluster PlacementEvaluated condition")
202+
Eventually(func(g Gomega) {
203+
cmd := exec.Command("kubectl", "--context", hubContext,
204+
"get", "gitopscluster", "gitops-cluster",
205+
"-n", argoCDNamespace,
206+
"-o", "jsonpath={.status.conditions[?(@.type=='PlacementEvaluated')].status}")
207+
output, err := utils.Run(cmd)
208+
g.Expect(err).NotTo(HaveOccurred())
209+
g.Expect(output).To(Equal("True"))
210+
}).Should(Succeed())
211+
212+
By("verifying GitOpsCluster ClustersImported condition")
213+
Eventually(func(g Gomega) {
214+
cmd := exec.Command("kubectl", "--context", hubContext,
215+
"get", "gitopscluster", "gitops-cluster",
216+
"-n", argoCDNamespace,
217+
"-o", "jsonpath={.status.conditions[?(@.type=='ClustersImported')].status}")
218+
output, err := utils.Run(cmd)
219+
g.Expect(err).NotTo(HaveOccurred())
220+
g.Expect(output).To(Equal("True"))
221+
}).Should(Succeed())
222+
223+
By("verifying GitOpsCluster ManifestWorkCreated condition")
224+
Eventually(func(g Gomega) {
225+
cmd := exec.Command("kubectl", "--context", hubContext,
226+
"get", "gitopscluster", "gitops-cluster",
227+
"-n", argoCDNamespace,
228+
"-o", "jsonpath={.status.conditions[?(@.type=='ManifestWorkCreated')].status}")
229+
output, err := utils.Run(cmd)
230+
g.Expect(err).NotTo(HaveOccurred())
231+
g.Expect(output).To(Equal("True"))
232+
}).Should(Succeed())
233+
234+
By("verifying GitOpsCluster AddonConfigured condition")
235+
Eventually(func(g Gomega) {
236+
cmd := exec.Command("kubectl", "--context", hubContext,
237+
"get", "gitopscluster", "gitops-cluster",
238+
"-n", argoCDNamespace,
239+
"-o", "jsonpath={.status.conditions[?(@.type=='AddonConfigured')].status}")
240+
output, err := utils.Run(cmd)
241+
g.Expect(err).NotTo(HaveOccurred())
242+
g.Expect(output).To(Equal("True"))
243+
}).Should(Succeed())
244+
})
245+
125246
It("should create ClusterManagementAddOn on hub", func() {
126247
By("verifying ClusterManagementAddOn exists")
127248
Eventually(func(g Gomega) {
@@ -132,6 +253,70 @@ var _ = Describe("ArgoCD Agent Addon Deployment E2E", Label("deploy"), Ordered,
132253
}).Should(Succeed())
133254
})
134255

256+
It("should verify all ArgoCD pods running on hub", func() {
257+
By("verifying ArgoCD principal pod is running")
258+
Eventually(func(g Gomega) {
259+
cmd := exec.Command("kubectl", "--context", hubContext,
260+
"get", "pods",
261+
"-n", argoCDNamespace,
262+
"-l", "app.kubernetes.io/name=argocd-agent-principal",
263+
"-o", "jsonpath={.items[0].status.phase}")
264+
output, err := utils.Run(cmd)
265+
g.Expect(err).NotTo(HaveOccurred())
266+
g.Expect(output).To(Equal("Running"))
267+
}).Should(Succeed())
268+
269+
By("verifying ArgoCD redis pod is running on hub")
270+
Eventually(func(g Gomega) {
271+
cmd := exec.Command("kubectl", "--context", hubContext,
272+
"get", "pods",
273+
"-n", argoCDNamespace,
274+
"-l", "app.kubernetes.io/name=argocd-redis",
275+
"-o", "jsonpath={.items[0].status.phase}")
276+
output, err := utils.Run(cmd)
277+
g.Expect(err).NotTo(HaveOccurred())
278+
g.Expect(output).To(Equal("Running"))
279+
}).Should(Succeed())
280+
281+
By("verifying ArgoCD repo-server pod is running on hub")
282+
Eventually(func(g Gomega) {
283+
cmd := exec.Command("kubectl", "--context", hubContext,
284+
"get", "pods",
285+
"-n", argoCDNamespace,
286+
"-l", "app.kubernetes.io/name=argocd-repo-server",
287+
"-o", "jsonpath={.items[0].status.phase}")
288+
output, err := utils.Run(cmd)
289+
g.Expect(err).NotTo(HaveOccurred())
290+
g.Expect(output).To(Equal("Running"))
291+
}).Should(Succeed())
292+
293+
By("verifying ArgoCD server pod is running on hub")
294+
Eventually(func(g Gomega) {
295+
cmd := exec.Command("kubectl", "--context", hubContext,
296+
"get", "pods",
297+
"-n", argoCDNamespace,
298+
"-l", "app.kubernetes.io/name=argocd-server",
299+
"-o", "jsonpath={.items[0].status.phase}")
300+
output, err := utils.Run(cmd)
301+
g.Expect(err).NotTo(HaveOccurred())
302+
g.Expect(output).To(Equal("Running"))
303+
}).Should(Succeed())
304+
305+
By("checking ArgoCD principal pod logs for event processing")
306+
var principalPodName string
307+
Eventually(func(g Gomega) {
308+
cmd := exec.Command("kubectl", "--context", hubContext,
309+
"get", "pods",
310+
"-n", argoCDNamespace,
311+
"-l", "app.kubernetes.io/name=argocd-agent-principal",
312+
"-o", "jsonpath={.items[0].metadata.name}")
313+
output, err := utils.Run(cmd)
314+
g.Expect(err).NotTo(HaveOccurred())
315+
g.Expect(output).NotTo(BeEmpty())
316+
principalPodName = output
317+
}).Should(Succeed())
318+
})
319+
135320
It("should reconcile GitOpsCluster and create ManagedClusterAddOn", func() {
136321
By("verifying GitOpsCluster is created")
137322
Eventually(func(g Gomega) {
@@ -280,29 +465,40 @@ var _ = Describe("ArgoCD Agent Addon Deployment E2E", Label("deploy"), Ordered,
280465
g.Expect(output).To(Equal("Running"))
281466
}).Should(Succeed())
282467

283-
By("checking ArgoCD agent pod logs for errors")
468+
By("verifying ArgoCD application-controller pod is running")
284469
Eventually(func(g Gomega) {
285470
cmd := exec.Command("kubectl", "--context", cluster1Context,
286-
"logs", podName,
471+
"get", "pods",
287472
"-n", argoCDNamespace,
288-
"--tail=50")
473+
"-l", "app.kubernetes.io/name=argocd-application-controller",
474+
"-o", "jsonpath={.items[0].status.phase}")
289475
output, err := utils.Run(cmd)
290476
g.Expect(err).NotTo(HaveOccurred())
291-
// Check that logs don't contain common error indicators
292-
lowerOutput := strings.ToLower(output)
293-
g.Expect(lowerOutput).NotTo(ContainSubstring("panic:"), "ArgoCD agent logs should not contain panics")
294-
g.Expect(lowerOutput).NotTo(ContainSubstring("fatal error"), "ArgoCD agent logs should not contain fatal errors")
477+
g.Expect(output).To(Equal("Running"))
478+
}).Should(Succeed())
295479

296-
// Log a sample for visibility
297-
lines := strings.Split(output, "\n")
298-
if len(lines) > 5 {
299-
fmt.Fprintf(GinkgoWriter, "Last 5 log lines from ArgoCD agent:\n")
300-
for _, line := range lines[len(lines)-6 : len(lines)-1] {
301-
if line != "" {
302-
fmt.Fprintf(GinkgoWriter, " %s\n", line)
303-
}
304-
}
305-
}
480+
By("verifying ArgoCD redis pod is running on cluster1")
481+
Eventually(func(g Gomega) {
482+
cmd := exec.Command("kubectl", "--context", cluster1Context,
483+
"get", "pods",
484+
"-n", argoCDNamespace,
485+
"-l", "app.kubernetes.io/name=argocd-redis",
486+
"-o", "jsonpath={.items[0].status.phase}")
487+
output, err := utils.Run(cmd)
488+
g.Expect(err).NotTo(HaveOccurred())
489+
g.Expect(output).To(Equal("Running"))
490+
}).Should(Succeed())
491+
492+
By("verifying ArgoCD repo-server pod is running on cluster1")
493+
Eventually(func(g Gomega) {
494+
cmd := exec.Command("kubectl", "--context", cluster1Context,
495+
"get", "pods",
496+
"-n", argoCDNamespace,
497+
"-l", "app.kubernetes.io/name=argocd-repo-server",
498+
"-o", "jsonpath={.items[0].status.phase}")
499+
output, err := utils.Run(cmd)
500+
g.Expect(err).NotTo(HaveOccurred())
501+
g.Expect(output).To(Equal("Running"))
306502
}).Should(Succeed())
307503
})
308504
})

0 commit comments

Comments
 (0)