コード例 #1
0
// waitForResourceQuotaSync waits until a usage of a quota reaches given limit with a short timeout
func waitForResourceQuotaSync(oc *exutil.CLI, name string, expectedResources kapi.ResourceList) (kapi.ResourceList, error) {
	g.By(fmt.Sprintf("waiting for resource quota %s to get updated", name))
	used, err := exutil.WaitForResourceQuotaSync(
		oc.KubeClient().Core().ResourceQuotas(oc.Namespace()),
		quotaName,
		expectedResources,
		false,
		waitTimeout,
	)
	if err != nil {
		return nil, err
	}
	return used, nil
}
コード例 #2
0
		o.Expect(err).NotTo(o.HaveOccurred())
		used, err = waitForResourceQuotaSync(oc, quotaName, quota)
		o.Expect(err).NotTo(o.HaveOccurred())
		o.Expect(assertQuotasEqual(used, quota)).NotTo(o.HaveOccurred())

		g.By(fmt.Sprintf("trying to push image exceeding quota %v", quota))
		_, err = imagesutil.BuildAndPushImageOfSizeWithDocker(oc, dClient, "third", "refused", imageSize, 1, outSink, false)
		o.Expect(err).NotTo(o.HaveOccurred())

		g.By("deleting first image stream")
		err = oc.Client().ImageStreams(oc.Namespace()).Delete("first")
		o.Expect(err).NotTo(o.HaveOccurred())
		used, err = exutil.WaitForResourceQuotaSync(
			oc.KubeClient().Core().ResourceQuotas(oc.Namespace()),
			quotaName,
			kapi.ResourceList{imageapi.ResourceImageStreams: resource.MustParse("1")},
			true,
			waitTimeout,
		)
		o.Expect(err).NotTo(o.HaveOccurred())
		o.Expect(assertQuotasEqual(used, kapi.ResourceList{imageapi.ResourceImageStreams: resource.MustParse("1")})).NotTo(o.HaveOccurred())

		g.By(fmt.Sprintf("trying to push image below quota %v", quota))
		_, err = imagesutil.BuildAndPushImageOfSizeWithDocker(oc, dClient, "third", "tag", imageSize, 1, outSink, true)
		o.Expect(err).NotTo(o.HaveOccurred())
		used, err = waitForResourceQuotaSync(oc, quotaName, quota)
		o.Expect(err).NotTo(o.HaveOccurred())
		o.Expect(assertQuotasEqual(used, quota)).NotTo(o.HaveOccurred())
	})
})
コード例 #3
0
ファイル: quota_admission.go プロジェクト: RomainVabre/origin
		o.Expect(err).NotTo(o.HaveOccurred())
		o.Expect(assertQuotasEqual(used, rq.Spec.Hard)).NotTo(o.HaveOccurred())

		g.By(fmt.Sprintf("trying to push image exceeding %s=%d quota", imageapi.ResourceImages, 2))
		buildAndPushImage(oc, oc.Namespace(), "other", "refused", true)

		g.By(fmt.Sprintf("trying to push image exceeding %s=%d quota to a new repository", imageapi.ResourceImages, 2))
		buildAndPushImage(oc, oc.Namespace(), "new", "refused", true)

		g.By("removing image sized:first")
		err = oc.REST().ImageStreamTags(oc.Namespace()).Delete("sized", "first")
		o.Expect(err).NotTo(o.HaveOccurred())
		// expect usage decrement
		used, err = exutil.WaitForResourceQuotaSync(
			oc.KubeREST().ResourceQuotas(oc.Namespace()),
			quotaName,
			kapi.ResourceList{imageapi.ResourceImages: resource.MustParse("1")},
			true,
			time.Second*5)
		o.Expect(err).NotTo(o.HaveOccurred())

		g.By(fmt.Sprintf("trying to push image below %s=%d quota", imageapi.ResourceImages, 2))
		buildAndPushImage(oc, oc.Namespace(), "sized", "foo", false)
		used, err = waitForResourceQuotaSync(oc, quotaName, rq.Spec.Hard)
		o.Expect(assertQuotasEqual(used, rq.Spec.Hard)).NotTo(o.HaveOccurred())
	})

	g.It("should deny a tagging of an image exceeding quota", func() {
		oc.SetOutputDir(exutil.TestContext.OutputDir)

		projectName := oc.Namespace()
		sharedProjectName := projectName + "-shared"