From 007bc3c38f45ff43e1a87c082c1c28e84e2b03a8 Mon Sep 17 00:00:00 2001 From: Bruno Andrade Date: Tue, 27 Jan 2026 21:39:57 -0300 Subject: [PATCH] UPSTREAM: : automate OCP-40945 --- tests-extension/test/qe/specs/olmv0_opm.go | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests-extension/test/qe/specs/olmv0_opm.go b/tests-extension/test/qe/specs/olmv0_opm.go index 3677dab259..f608ff9b6e 100644 --- a/tests-extension/test/qe/specs/olmv0_opm.go +++ b/tests-extension/test/qe/specs/olmv0_opm.go @@ -165,6 +165,64 @@ var _ = g.Describe("[sig-operator][Jira:OLM] OLMv0 opm should", g.Label("NonHype o.Expect(output).To(o.ContainSubstring("quay.io/windupeng/windup-operator-native:0.0.5")) }) + g.It("PolarionID:40945-[OTP][Skipped:Disconnected] opm render community operator index to local yaml", g.Label("original-name:[sig-operator][Jira:OLM] OLMv0 opm should PolarionID:40945-[Skipped:Disconnected] opm render community operator index to local yaml"), func() { + err := opmcli.EnsureContainerPolicy() + o.Expect(err).NotTo(o.HaveOccurred()) + + baseDir, err := os.MkdirTemp("", "opm-render-community-") + o.Expect(err).NotTo(o.HaveOccurred()) + defer func() { + _ = os.RemoveAll(baseDir) + }() + + authDir := filepath.Join(baseDir, "pull-secret") + err = os.MkdirAll(authDir, 0755) + o.Expect(err).NotTo(o.HaveOccurred()) + + if err = exutil.GetPullSec(oc, authDir); err != nil { + g.Skip("Skipping test: unable to extract pull-secret: " + err.Error()) + } + + authFile := filepath.Join(authDir, ".dockerconfigjson") + if _, err = os.Stat(authFile); err != nil { + legacyAuthFile := filepath.Join(authDir, ".dockercfg") + if _, legacyErr := os.Stat(legacyAuthFile); legacyErr == nil { + authFile = legacyAuthFile + } else { + g.Skip("Skipping test: pull-secret auth file not found: " + err.Error()) + } + } + + renderCLI := opmcli.NewOpmCLI().SetAuthFile(authFile) + + outputDir := filepath.Join(baseDir, "community-operators") + err = os.MkdirAll(outputDir, 0755) + o.Expect(err).NotTo(o.HaveOccurred()) + + output, err := renderCLI.Run("render").Args("registry.redhat.io/redhat/community-operator-index:v4.6", "-o", "yaml").Output() + if err != nil && strings.Contains(output, "authentication required") { + g.Skip("Skipping test: registry.redhat.io authentication required") + } + if err != nil && strings.Contains(output, "failed to pull image") { + g.Skip("Skipping test: failed to pull community operator index image") + } + o.Expect(err).NotTo(o.HaveOccurred()) + + indexFilePath := filepath.Join(outputDir, "index.yaml") + if err = os.WriteFile(indexFilePath, []byte(output), 0644); err != nil { + e2e.Failf("Writefile %s Error: %v", indexFilePath, err) + } + + info, err := os.Stat(indexFilePath) + o.Expect(err).NotTo(o.HaveOccurred()) + o.Expect(info.Size()).To(o.BeNumerically(">", 0)) + + content, err := os.ReadFile(indexFilePath) + o.Expect(err).NotTo(o.HaveOccurred()) + o.Expect(string(content)).To(o.ContainSubstring("schema: olm.bundle")) + o.Expect(string(content)).To(o.ContainSubstring("schema: olm.package")) + }) + g.It("PolarionID:43248-[OTP]Support ignoring files when loading declarative configs", g.Label("original-name:[sig-operator][Jira:OLM] OLMv0 opm should PolarionID:43248-Support ignoring files when loading declarative configs"), func() { opmBaseDir := exutil.FixturePath("testdata", "opm") correctIndex := filepath.Join(opmBaseDir, "render", "validate", "configs")