Skip to content
133 changes: 133 additions & 0 deletions tatus
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
diff --git a/test/extended/quota/resourcequota.go b/test/extended/quota/resourcequota.go
index 179f1ffe5c..2f42505f09 100644
--- a/test/extended/quota/resourcequota.go
+++ b/test/extended/quota/resourcequota.go
@@ -15,10 +15,16 @@ import (
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/apimachinery/pkg/util/wait"
utilwait "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
)

+// defaultIntegratedRegistryService is the in-cluster Service DNS for the default OpenShift image
+// registry. Use this for import-image --from so importer traffic stays on the pod network instead
+// of following an external route that InternalRegistryHostname may advertise.
+const defaultIntegratedRegistryService = "image-registry.openshift-image-registry.svc:5000"
+
var _ = g.Describe("[sig-api-machinery][Feature:ResourceQuota]", func() {
defer g.GinkgoRecover()
oc := exutil.NewCLI("object-count-rq")
@@ -165,7 +171,8 @@ var _ = g.Describe("[sig-api-machinery][Feature:ResourceQuota]", func() {
o.Expect(err).NotTo(o.HaveOccurred())
})

- g.It("check the quota after import-image with --all option [Skipped:Disconnected]", func() {
+ g.It("check the quota after import-image with --all option", func() {
+ ctx := context.Background()
testProject := oc.SetupProject()
testResourceQuotaName := "my-imagestream-quota-" + testProject
clusterAdminKubeClient := oc.AdminKubeClient()
@@ -194,11 +201,89 @@ var _ = g.Describe("[sig-api-machinery][Feature:ResourceQuota]", func() {
})
o.Expect(err).NotTo(o.HaveOccurred())

- g.By("trying to tag a container image")
- err = oc.AsAdmin().WithoutNamespace().Run("import-image").Args("centos", "--from=quay.io/openshifttest/alpine", "--confirm=true", "--all=true", "-n", testProject).Execute()
+ g.By("waiting until the integrated registry is published (readiness for import-image)")
+ _, err = exutil.WaitForInternalRegistryHostname(oc)
+ o.Expect(err).NotTo(o.HaveOccurred())
+
+ // Build a multi-tag ImageStream in this namespace by referencing openshift/cli:latest only
+ // (disconnected-safe). The integrated registry exposes it as one repository with several tags.
+ sourceISName := "rq-local-multi-src"
+ sourceTags := []string{"alpha", "beta", "gamma"}
+ for _, tag := range sourceTags {
+ err = oc.AsAdmin().WithoutNamespace().Run("tag").Args(
+ "openshift/cli:latest",
+ fmt.Sprintf("%s:%s", sourceISName, tag),
+ "-n", testProject,
+ ).Execute()
+ o.Expect(err).NotTo(o.HaveOccurred())
+ err = exutil.WaitForAnImageStreamTag(oc, testProject, sourceISName, tag)
+ o.Expect(err).NotTo(o.HaveOccurred())
+ }
+
+ g.By("checking quota after creating one local ImageStream with multiple tags")
+ err = waitForResourceQuotaStatus(clusterAdminKubeClient, testResourceQuotaName, testProject, func(actualResourceQuota *corev1.ResourceQuota) error {
+ expectedUsedStatus := corev1.ResourceList{
+ "openshift.io/imagestreams": resource.MustParse("1"),
+ }
+ if !equality.Semantic.DeepEqual(actualResourceQuota.Status.Used, expectedUsedStatus) {
+ return fmt.Errorf("unexpected current total usage: actual: %#v, expected: %#v", actualResourceQuota.Status.Used, expectedUsedStatus)
+ }
+ return nil
+ })
+ o.Expect(err).NotTo(o.HaveOccurred())
+
+ sourceIS, err := oc.AdminImageClient().ImageV1().ImageStreams(testProject).Get(ctx, sourceISName, metav1.GetOptions{})
+ o.Expect(err).NotTo(o.HaveOccurred())
+ o.Expect(len(sourceIS.Spec.Tags)).To(o.Equal(len(sourceTags)))
+
+ bulkISName := "rq-bulk-import-is"
+ internalSource := fmt.Sprintf("%s/%s/%s", defaultIntegratedRegistryService, testProject, sourceISName)
+
+ g.By("importing all tags from the local repository into one new ImageStream (bulk import adds exactly one ImageStream)")
+ err = oc.AsAdmin().WithoutNamespace().Run("import-image").Args(
+ bulkISName,
+ "--from="+internalSource,
+ "--confirm=true",
+ "--all=true",
+ "--request-timeout=5m",
+ "-n", testProject,
+ ).Execute()
+ o.Expect(err).NotTo(o.HaveOccurred())
+
+ var imported *imagev1.ImageStream
+ // wait.PollUntilContextTimeout replaces PollImmediate
+ // Parameters: ctx, interval, timeout, immediate (true = PollImmediate behavior), condition
+ err = wait.PollUntilContextTimeout(ctx, 1*time.Second, 1*time.Minute, true, func(ctx context.Context) (bool, error) {
+ var getErr error
+ imported, getErr = oc.AdminImageClient().ImageV1().ImageStreams(testProject).Get(ctx, bulkISName, metav1.GetOptions{})
+ if getErr != nil {
+ // Return false, nil to keep retrying if the IS isn't found yet
+ return false, nil
+ }
+ // Return true only when the tags are actually there
+ return len(imported.Spec.Tags) >= 2, nil
+ })
+
+ o.Expect(err).NotTo(o.HaveOccurred(),
+ "import-image --all should copy multiple tags onto a single ImageStream (timed out waiting for tags to populate)")
Comment thread
YamunadeviShanmugam marked this conversation as resolved.
Outdated
+ g.By("checking that bulk import increased ImageStream quota by exactly one")
+ err = waitForResourceQuotaStatus(clusterAdminKubeClient, testResourceQuotaName, testProject, func(actualResourceQuota *corev1.ResourceQuota) error {
+ expectedUsedStatus := corev1.ResourceList{
+ "openshift.io/imagestreams": resource.MustParse("2"),
+ }
+ if !equality.Semantic.DeepEqual(actualResourceQuota.Status.Used, expectedUsedStatus) {
+ return fmt.Errorf("unexpected current total usage: actual: %#v, expected: %#v", actualResourceQuota.Status.Used, expectedUsedStatus)
+ }
+ return nil
+ })
o.Expect(err).NotTo(o.HaveOccurred())

- err = oc.AsAdmin().WithoutNamespace().Run("tag").Args("quay.io/openshifttest/base-alpine@sha256:3126e4eed4a3ebd8bf972b2453fa838200988ee07c01b2251e3ea47e4b1f245c", "--source=docker", "mystream:latest", "-n", testProject).Execute()
+ g.By("tagging another ImageStream from an in-cluster ImageStreamTag")
+ err = oc.AsAdmin().WithoutNamespace().Run("tag").Args(
+ "openshift/cli:latest",
+ "mystream:latest",
+ "-n", testProject,
+ ).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

err = exutil.WaitForAnImageStreamTag(oc, testProject, "mystream", "latest")
@@ -207,7 +292,7 @@ var _ = g.Describe("[sig-api-machinery][Feature:ResourceQuota]", func() {
g.By("checking the imagestream usage again")
err = waitForResourceQuotaStatus(clusterAdminKubeClient, testResourceQuotaName, testProject, func(actualResourceQuota *corev1.ResourceQuota) error {
expectedUsedStatus := corev1.ResourceList{
- "openshift.io/imagestreams": resource.MustParse("2"),
+ "openshift.io/imagestreams": resource.MustParse("3"),
}
if !equality.Semantic.DeepEqual(actualResourceQuota.Status.Used, expectedUsedStatus) {
return fmt.Errorf("unexpected current total usage: actual: %#v, expected: %#v", actualResourceQuota.Status.Used, expectedUsedStatus)
12 changes: 6 additions & 6 deletions test/extended/quota/resourcequota.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ var _ = g.Describe("[sig-api-machinery][Feature:ResourceQuota]", func() {
o.Expect(err).NotTo(o.HaveOccurred())
})

g.It("when exceed openshift.io/image-tags will ban to create new image references in the project [Skipped:Disconnected]", func() {
testProject := oc.Namespace()
g.It("when exceed openshift.io/image-tags will ban to create new image references in the project", func() {
testProject := oc.SetupProject()
testResourceQuotaName := "my-image-tag-quota"
clusterAdminKubeClient := oc.AdminKubeClient()

Expand Down Expand Up @@ -262,22 +262,22 @@ var _ = g.Describe("[sig-api-machinery][Feature:ResourceQuota]", func() {
Tag string
}{
{
Image: "quay.io/openshifttest/hello-openshift@sha256:4200f438cf2e9446f6bcff9d67ceea1f69ed07a2f83363b7fb52529f7ddd8a83",
Image: "openshift/cli:latest",
Tag: "v1",
},
{
Image: "quay.io/openshifttest/base-alpine@sha256:3126e4eed4a3ebd8bf972b2453fa838200988ee07c01b2251e3ea47e4b1f245c",
Image: "openshift/tools:latest",
Tag: "v2",
},
{
Image: "openshift/hello-openshift",
Image: "openshift/must-gather:latest",
Tag: "v3",
},
}

for _, u := range images {
g.By("trying to tag a container image with " + u.Tag)
err = oc.Run("tag").Args(u.Image, "--source=docker", "mystream:"+u.Tag, "-n", testProject).Execute()
err = oc.Run("tag").Args(u.Image, "--source=istag", "mystream:"+u.Tag, "-n", testProject).Execute()
if u.Tag != "v3" {
o.Expect(err).NotTo(o.HaveOccurred())
err = exutil.WaitForAnImageStreamTag(oc, testProject, "mystream", u.Tag)
Expand Down