Skip to content

Commit 43086d8

Browse files
Merge pull request #30432 from openshift-cherrypick-robot/cherry-pick-30389-to-release-4.19
[release-4.19] OCPBUGS-63637: Add imagestream update dryrun test
2 parents 281bcd1 + 588af27 commit 43086d8

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

test/extended/images/dryrun.go

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package images
22

33
import (
4+
"context"
5+
"time"
6+
47
g "github.com/onsi/ginkgo/v2"
58
o "github.com/onsi/gomega"
69

10+
"k8s.io/apimachinery/pkg/util/wait"
711
admissionapi "k8s.io/pod-security-admission/api"
812

913
exutil "github.com/openshift/origin/test/extended/util"
10-
"github.com/openshift/origin/test/extended/util/image"
1114
)
1215

1316
var _ = g.Describe("[sig-imageregistry] Image --dry-run", func() {
@@ -19,7 +22,7 @@ var _ = g.Describe("[sig-imageregistry] Image --dry-run", func() {
1922

2023
g.It("should not delete resources [apigroup:image.openshift.io]", func() {
2124
g.By("preparing the image stream where the test image will be pushed")
22-
err := oc.Run("tag").Args("--source=docker", image.ShellImage(), "test:latest").Execute()
25+
err := oc.Run("tag").Args("openshift/cli:latest", "test:latest").Execute()
2326
o.Expect(err).NotTo(o.HaveOccurred())
2427

2528
err = exutil.WaitForAnImageStreamTag(oc, oc.Namespace(), "test", "latest")
@@ -41,4 +44,36 @@ var _ = g.Describe("[sig-imageregistry] Image --dry-run", func() {
4144
_, err = oc.Run("get").Args("imagestream", "test", "-o", "jsonpath={.image.metadata.name}").Output()
4245
o.Expect(err).NotTo(o.HaveOccurred())
4346
})
47+
48+
g.It("should not update resources [apigroup:image.openshift.io]", func() {
49+
50+
g.By("actually creating imagestream for update dry-run test")
51+
err := oc.Run("create").Args("imagestream", "dryrun-test").Execute()
52+
o.Expect(err).NotTo(o.HaveOccurred())
53+
54+
defer func() {
55+
g.By("cleaning up imagestream")
56+
err := oc.Run("delete").Args("imagestream/dryrun-test", "--ignore-not-found=true").Execute()
57+
o.Expect(err).NotTo(o.HaveOccurred())
58+
}()
59+
60+
g.By("verifying the imagestream was actually created")
61+
err = wait.PollUntilContextTimeout(context.Background(), 1*time.Second, 30*time.Second, true, func(ctx context.Context) (bool, error) {
62+
_, err := oc.Run("get").Args("imagestream", "dryrun-test", "-o", "jsonpath={.metadata.name}").Output()
63+
if err != nil {
64+
return false, nil // Continue polling
65+
}
66+
return true, nil // Success
67+
})
68+
o.Expect(err).NotTo(o.HaveOccurred())
69+
70+
g.By("triggering imagestream annotation update with --dry-run=server")
71+
err = oc.Run("annotate").Args("imagestream/dryrun-test", "test-annotation=value1", "--dry-run=server").Execute()
72+
o.Expect(err).NotTo(o.HaveOccurred())
73+
74+
g.By("verifying the annotation was not persisted")
75+
output, err := oc.Run("get").Args("imagestream", "dryrun-test", "-o", "jsonpath={.metadata.annotations.test-annotation}").Output()
76+
o.Expect(err).NotTo(o.HaveOccurred())
77+
o.Expect(output).To(o.BeEmpty())
78+
})
4479
})

test/extended/util/annotate/generated/zz_generated.annotations.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)