Skip to content
Closed
Show file tree
Hide file tree
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
39 changes: 37 additions & 2 deletions test/extended/images/dryrun.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package images

import (
"context"
"time"

g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"

"k8s.io/apimachinery/pkg/util/wait"
admissionapi "k8s.io/pod-security-admission/api"

exutil "github.com/openshift/origin/test/extended/util"
"github.com/openshift/origin/test/extended/util/image"
)

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

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

err = exutil.WaitForAnImageStreamTag(oc, oc.Namespace(), "test", "latest")
Expand All @@ -41,4 +44,36 @@ var _ = g.Describe("[sig-imageregistry] Image --dry-run", func() {
_, err = oc.Run("get").Args("imagestream", "test", "-o", "jsonpath={.image.metadata.name}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
})

g.It("should not update resources [apigroup:image.openshift.io]", func() {

g.By("actually creating imagestream for update dry-run test")
err := oc.Run("create").Args("imagestream", "dryrun-test").Execute()
o.Expect(err).NotTo(o.HaveOccurred())

defer func() {
g.By("cleaning up imagestream")
err := oc.Run("delete").Args("imagestream/dryrun-test", "--ignore-not-found=true").Execute()
o.Expect(err).NotTo(o.HaveOccurred())
}()

g.By("verifying the imagestream was actually created")
err = wait.PollUntilContextTimeout(context.Background(), 1*time.Second, 30*time.Second, true, func(ctx context.Context) (bool, error) {
_, err := oc.Run("get").Args("imagestream", "dryrun-test", "-o", "jsonpath={.metadata.name}").Output()
if err != nil {
return false, nil // Continue polling
}
return true, nil // Success
})
o.Expect(err).NotTo(o.HaveOccurred())

g.By("triggering imagestream annotation update with --dry-run=server")
err = oc.Run("annotate").Args("imagestream/dryrun-test", "test-annotation=value1", "--dry-run=server").Execute()
o.Expect(err).NotTo(o.HaveOccurred())

g.By("verifying the annotation was not persisted")
output, err := oc.Run("get").Args("imagestream", "dryrun-test", "-o", "jsonpath={.metadata.annotations.test-annotation}").Output()
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(output).To(o.BeEmpty())
})
})
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[
{
"schema": "olm.package",
"name": "operator-2",
"defaultChannel": "beta"
}
},
{
"schema": "olm.channel",
"name": "4.7",
Expand All @@ -15,7 +16,7 @@
]
}
]
}
},
{
"schema": "olm.channel",
"name": "4.8",
Expand All @@ -30,7 +31,7 @@
"replaces": "operator-2.v0.4.0"
}
]
}
},
{
"schema": "olm.channel",
"name": "4.9",
Expand All @@ -41,7 +42,7 @@
"skipRange": ">=0.1.0 <0.6.0"
}
]
}
},
{
"schema": "olm.channel",
"name": "alpha",
Expand All @@ -55,7 +56,7 @@
"replaces": "operator-2.v0.1.1"
}
]
}
},
{
"schema": "olm.bundle",
"name": "operator-2.v0.1.0",
Expand All @@ -78,7 +79,7 @@
}
}
]
}
},
{
"schema": "olm.bundle",
"name": "operator-2.v0.2.0",
Expand All @@ -101,7 +102,7 @@
}
}
]
}
},
{
"schema": "olm.bundle",
"name": "operator-2.v0.3.0",
Expand All @@ -124,7 +125,7 @@
}
}
]
}
},
{
"schema": "olm.bundle",
"name": "operator-2.v0.4.0",
Expand All @@ -147,7 +148,7 @@
}
}
]
}
},
{
"schema": "olm.bundle",
"name": "operator-2.v0.5.0",
Expand All @@ -170,7 +171,7 @@
}
}
]
}
},
{
"schema": "olm.bundle",
"name": "operator-2.v0.6.0",
Expand All @@ -194,3 +195,4 @@
}
]
}
]