11package images
22
33import (
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
1316var _ = 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})
0 commit comments