Skip to content

Commit 7decf42

Browse files
Neilhamzaopenshift-cherrypick-robot
authored andcommitted
adjust olm test to pass on a degraded run
Signed-off-by: nhamza <nhamza@redhat.com>
1 parent 543318f commit 7decf42

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

test/extended/olm/olm.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const (
2525
var _ = g.Describe("[sig-operator] OLM should", func() {
2626
defer g.GinkgoRecover()
2727

28-
var oc = exutil.NewCLIWithoutNamespace("default")
28+
oc := exutil.NewCLIWithoutNamespace("default")
2929

3030
providedAPIs := []struct {
3131
fromAPIService bool
@@ -137,13 +137,12 @@ var _ = g.Describe("[sig-operator] OLM should", func() {
137137
var _ = g.Describe("[sig-arch] ocp payload should be based on existing source", func() {
138138
defer g.GinkgoRecover()
139139

140-
var oc = exutil.NewCLIWithoutNamespace("default")
140+
oc := exutil.NewCLIWithoutNamespace("default")
141141

142142
// TODO: This test should be more generic and across components
143143
// OCP-20981, [BZ 1626434]The olm/catalog binary should output the exact version info
144144
// author: jiazha@redhat.com
145145
g.It("OLM version should contain the source commit id", func() {
146-
147146
oc := oc
148147
namespace := "openshift-operator-lifecycle-manager"
149148

@@ -158,9 +157,15 @@ var _ = g.Describe("[sig-arch] ocp payload should be based on existing source",
158157
subPods := []string{"catalog-operator", "olm-operator", "packageserver"}
159158

160159
for _, v := range subPods {
161-
podName, err := oc.AsAdmin().Run("get").Args("-n", namespace, "pods", "-l", fmt.Sprintf("app=%s", v), "-o=jsonpath={.items[0].metadata.name}").Output()
160+
podName, err := oc.AsAdmin().Run("get").Args(
161+
"-n", namespace, "pods", "-l", fmt.Sprintf("app=%s", v),
162+
"-o", `go-template={{range .items}}{{if and (eq .status.phase "Running") (not .metadata.deletionTimestamp)}}{{.metadata.name}}{{"\n"}}{{end}}{{end}}`,
163+
).Output()
162164
o.Expect(err).NotTo(o.HaveOccurred())
163165

166+
podName = strings.TrimSpace(strings.Split(podName, "\n")[0])
167+
o.Expect(podName).NotTo(o.BeEmpty(), "no Running pod found for app=%s in %s", v, namespace)
168+
164169
g.By(fmt.Sprintf("get olm version from pod %s", podName))
165170
oc.SetNamespace("openshift-operator-lifecycle-manager")
166171
olmVersion, err := oc.AsAdmin().Run("exec").Args("-n", namespace, podName, "-c", v, "--", "olm", "--version").Output()
@@ -174,7 +179,6 @@ var _ = g.Describe("[sig-arch] ocp payload should be based on existing source",
174179

175180
if sameCommit == "" {
176181
sameCommit = gitCommitID
177-
178182
} else if gitCommitID != sameCommit {
179183
e2e.Failf("commitIDs of components within OLM do not match, possible build anomalies")
180184
}
@@ -345,7 +349,6 @@ var _ = g.Describe("[sig-operator] an end user can use OLM", func() {
345349
e2e.Logf("Failed to check %s, error: %v, try next round", current, err)
346350
}
347351
return output
348-
349352
}, 5*time.Minute, time.Second).ShouldNot(o.BeEmpty())
350353
})
351354

@@ -361,6 +364,5 @@ var _ = g.Describe("[sig-operator] an end user can use OLM", func() {
361364
o.Expect(err).NotTo(o.HaveOccurred())
362365
o.Expect(msg).To(o.ContainSubstring("Upgradeable True"))
363366
}
364-
365367
})
366368
})

0 commit comments

Comments
 (0)