Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions tests-extension/test/qe/specs/olmv0_opm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bandrade it is first time to be added into OTE, so should no g.Label("original-name:

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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bandrade is it still use 4.6? or change it to 4.21?

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"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bandrade the content could be possible so big, and it will be error message once fails for your code. it is so big error message.

so

		o.Expect(string(content)).To(o.ContainSubstring("schema: olm.bundle"))
		o.Expect(string(content)).To(o.ContainSubstring("schema: olm.package"))

to

         o.Expect(strings.Contains(content,"schema: olm.bundle")).To(o.BeTrue(), )
         o.Expect(strings.Contains(content,"schema: olm.package")).To(o.BeTrue())

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")
Expand Down