Skip to content

Commit 4d4accf

Browse files
removed the file not related to fix
1 parent e2165bf commit 4d4accf

1 file changed

Lines changed: 22 additions & 29 deletions

File tree

test/extended/cli/debug.go

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cli
33
import (
44
"context"
55
"fmt"
6-
"strings"
76
"time"
87

98
g "github.com/onsi/ginkgo/v2"
@@ -16,6 +15,7 @@ import (
1615
"k8s.io/klog/v2"
1716
admissionapi "k8s.io/pod-security-admission/api"
1817

18+
configv1 "github.com/openshift/api/config/v1"
1919
exutil "github.com/openshift/origin/test/extended/util"
2020
)
2121

@@ -33,6 +33,7 @@ var _ = g.Describe("[sig-cli] oc debug", func() {
3333
testDeployment := exutil.FixturePath("testdata", "test-deployment.yaml")
3434
testReplicationController := exutil.FixturePath("testdata", "test-replication-controller.yaml")
3535
helloPod := exutil.FixturePath("..", "..", "examples", "hello-openshift", "hello-pod.json")
36+
imageStreamsCentos := exutil.FixturePath("..", "..", "examples", "image-streams", "image-streams-centos7.json")
3637

3738
g.It("deployment from a build [apigroup:image.openshift.io]", func() {
3839
projectName, err := oc.Run("project").Args("-q").Output()
@@ -251,41 +252,33 @@ spec:
251252
})
252253

253254
g.It("ensure it works with image streams [apigroup:image.openshift.io]", func() {
254-
ctx := context.Background()
255-
const (
256-
targetIS = "cli"
257-
targetNS = "openshift"
258-
containerImage = `{.spec.containers[0].image}`
259-
digestPullMatch = `^.+@sha256:[a-f0-9]{64}$`
260-
)
261-
262-
g.By("waiting for the internal ImageStreamTag to be available")
263-
err := wait.PollUntilContextTimeout(ctx, cliInterval, cliTimeout, true, func(ctx context.Context) (bool, error) {
264-
if err := oc.AsAdmin().Run("get").Args("istag", targetIS+":latest", "-n", targetNS).Execute(); err != nil {
265-
return false, nil
266-
}
267-
return true, nil
255+
hasImageRegistry, err := exutil.IsCapabilityEnabled(oc, configv1.ClusterVersionCapabilityImageRegistry)
256+
o.Expect(err).NotTo(o.HaveOccurred())
257+
258+
err = oc.Run("create").Args("-f", imageStreamsCentos).Execute()
259+
o.Expect(err).NotTo(o.HaveOccurred())
260+
err = wait.Poll(cliInterval, cliTimeout, func() (bool, error) {
261+
err := oc.Run("get").Args("imagestreamtags", "wildfly:latest").Execute()
262+
return err == nil, nil
268263
})
269-
if err != nil {
270-
g.Skip(fmt.Sprintf("openshift/%s:latest not observed within %s: %v", targetIS, cliTimeout, err))
264+
o.Expect(err).NotTo(o.HaveOccurred())
265+
266+
var out string
267+
var resolvedImageMatcher = o.MatchRegexp("image:.*oc-debug-.*/wildfly@sha256")
268+
if !hasImageRegistry {
269+
resolvedImageMatcher = o.ContainSubstring("image: quay.io/wildfly/wildfly-centos7")
271270
}
272271

273-
g.By("verifying oc debug works with istag")
274-
img, err := oc.AsAdmin().Run("debug").Args(
275-
fmt.Sprintf("istag/%s:latest", targetIS), "-n", targetNS, "-o", "jsonpath="+containerImage,
276-
).Output()
272+
out, err = oc.Run("debug").Args("istag/wildfly:latest", "-o", "yaml").Output()
277273
o.Expect(err).NotTo(o.HaveOccurred())
278-
o.Expect(strings.TrimSpace(img)).To(o.MatchRegexp(digestPullMatch), "debug pod should reference the ImageStreamTag by digest (any registry host)")
274+
o.Expect(out).To(resolvedImageMatcher)
279275

280-
g.By("verifying oc debug works with isimage (SHA-based lookup)")
281-
sha, err := oc.AsAdmin().Run("get").Args("istag", targetIS+":latest", "-n", targetNS, "--template", "{{ .image.metadata.name }}").Output()
276+
var sha string
277+
sha, err = oc.Run("get").Args("istag/wildfly:latest", "--template", "{{ .image.metadata.name }}").Output()
282278
o.Expect(err).NotTo(o.HaveOccurred())
283-
284-
img, err = oc.AsAdmin().Run("debug").Args(
285-
fmt.Sprintf("isimage/%s@%s", targetIS, strings.TrimSpace(sha)), "-n", targetNS, "-o", "jsonpath="+containerImage,
286-
).Output()
279+
out, err = oc.Run("debug").Args(fmt.Sprintf("isimage/wildfly@%s", sha), "-o", "yaml").Output()
287280
o.Expect(err).NotTo(o.HaveOccurred())
288-
o.Expect(strings.TrimSpace(img)).To(o.MatchRegexp(digestPullMatch), "debug pod should reference the ImageStreamImage by digest (any registry host)")
281+
o.Expect(out).To(o.ContainSubstring("image: quay.io/wildfly/wildfly-centos7"))
289282
})
290283

291284
g.It("ensure that the label is set for node debug", func() {

0 commit comments

Comments
 (0)