From 279cb732b10208bf69b3c024351cf0dd4aa4cb0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Mon, 12 Oct 2026 14:41:56 +0200 Subject: [PATCH] feat: Add tests for https://github.com/redhat-developer/gitops-must-gather/pull/51 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Oliver Gondža --- .../1-120_validate_running_must_gather.go | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/test/openshift/e2e/ginkgo/sequential/1-120_validate_running_must_gather.go b/test/openshift/e2e/ginkgo/sequential/1-120_validate_running_must_gather.go index 9dd09c785bb..41ccd4afe9b 100644 --- a/test/openshift/e2e/ginkgo/sequential/1-120_validate_running_must_gather.go +++ b/test/openshift/e2e/ginkgo/sequential/1-120_validate_running_must_gather.go @@ -102,13 +102,8 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() { Expect(path.Join(csr, "config.openshift.io/clusterversions/version.yaml")).To(BeValidResourceFile()) n := path.Join(resources, "namespaces") - Expect(n).To(BeADirectory()) - Expect(path.Join(n, "openshift-gitops/openshift-gitops.yaml")).To(BeValidResourceFile()) - Expect(path.Join(n, "openshift-gitops/route.openshift.io/routes.yaml")).To(BeValidResourceFile()) - Expect(path.Join(n, "openshift-gitops/argoproj.io/appprojects.yaml")).To(BeValidResourceFile()) - logs := path.Join(n, "openshift-gitops/pods/openshift-gitops-application-controller-0/argocd-application-controller/argocd-application-controller/logs/") - Expect(path.Join(logs, "current.log")).To(BeARegularFile()) - Expect(path.Join(logs, "previous.log")).To(BeARegularFile()) + assertNamespaceLogs(n, "openshift-gitops", "openshift-gitops") + assertNamespaceLogs(n, ns.Name, "left-argocd") Expect(path.Join(n, nsf.Name, "core/pods.yaml")).To(BeValidResourceFile()) }) @@ -157,6 +152,29 @@ func resourcesDir(destDir string) string { return path.Join(destDir, subdirs[0]) } +// assertNamespaceLogs checks must-gather output for an Argo CD instance named the same as namespace. +// On failure, the message lists every file under namespacesDir. +func assertNamespaceLogs(namespacesDir, namespace string, instanceName string) { + Expect(namespacesDir).To(BeADirectory()) + + base := path.Join(namespacesDir, namespace) + Expect(path.Join(base, namespace+".yaml")).To(BeValidResourceFile()) + Expect(path.Join(base, "route.openshift.io/routes.yaml")).To(BeValidResourceFile()) + Expect(path.Join(base, "argoproj.io/appprojects.yaml")).To(BeValidResourceFile()) + Expect(path.Join(base, "core/pods.yaml")).To(BeValidResourceFile()) + // Test roles and rolebindings as they are collected separately + Expect(path.Join(base, "rbac.authorization.k8s.io/roles/"+instanceName+"-argocd-server.yaml")).To(BeValidResourceFile()) + Expect(path.Join(base, "rbac.authorization.k8s.io/rolebindings/"+instanceName+"-argocd-server.yaml")).To(BeValidResourceFile()) + + podLogs := path.Join( + base, "pods", instanceName+"-application-controller-0", + "argocd-application-controller", "argocd-application-controller", "logs", + ) + Expect(path.Join(podLogs, "current.log")).To(BeARegularFile()) + Expect(path.Join(podLogs, "previous.log")).To(BeARegularFile()) + +} + func mustGatherImage() string { injected := os.Getenv("E2E_MUST_GATHER_IMAGE") if injected == "" {