Skip to content

Commit 076af3d

Browse files
authored
Merge pull request kubernetes#74570 from s-ito-ts/add_resourcequota_test
Adding e2e test for update and delete of resourcequota
2 parents 649f225 + 5752bc3 commit 076af3d

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

test/e2e/apimachinery/resource_quota.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,51 @@ var _ = SIGDescribe("ResourceQuota", func() {
664664
err = waitForResourceQuota(f.ClientSet, f.Namespace.Name, resourceQuotaNotBestEffort.Name, usedResources)
665665
Expect(err).NotTo(HaveOccurred())
666666
})
667+
It("Should be able to update and delete ResourceQuota.", func() {
668+
client := f.ClientSet
669+
ns := f.Namespace.Name
667670

671+
By("Creating a ResourceQuota")
672+
quotaName := "test-quota"
673+
resourceQuota := &v1.ResourceQuota{
674+
Spec: v1.ResourceQuotaSpec{
675+
Hard: v1.ResourceList{},
676+
},
677+
}
678+
resourceQuota.ObjectMeta.Name = quotaName
679+
resourceQuota.Spec.Hard[v1.ResourceCPU] = resource.MustParse("1")
680+
resourceQuota.Spec.Hard[v1.ResourceMemory] = resource.MustParse("500Mi")
681+
_, err := createResourceQuota(client, ns, resourceQuota)
682+
Expect(err).NotTo(HaveOccurred())
683+
684+
By("Getting a ResourceQuota")
685+
resourceQuotaResult, err := client.CoreV1().ResourceQuotas(ns).Get(quotaName, metav1.GetOptions{})
686+
Expect(err).NotTo(HaveOccurred())
687+
Expect(resourceQuotaResult.Spec.Hard[v1.ResourceCPU]).To(Equal(resource.MustParse("1")))
688+
Expect(resourceQuotaResult.Spec.Hard[v1.ResourceMemory]).To(Equal(resource.MustParse("500Mi")))
689+
690+
By("Updating a ResourceQuota")
691+
resourceQuota.Spec.Hard[v1.ResourceCPU] = resource.MustParse("2")
692+
resourceQuota.Spec.Hard[v1.ResourceMemory] = resource.MustParse("1Gi")
693+
resourceQuotaResult, err = client.CoreV1().ResourceQuotas(ns).Update(resourceQuota)
694+
Expect(err).NotTo(HaveOccurred())
695+
Expect(resourceQuotaResult.Spec.Hard[v1.ResourceCPU]).To(Equal(resource.MustParse("2")))
696+
Expect(resourceQuotaResult.Spec.Hard[v1.ResourceMemory]).To(Equal(resource.MustParse("1Gi")))
697+
698+
By("Verifying a ResourceQuota was modified")
699+
resourceQuotaResult, err = client.CoreV1().ResourceQuotas(ns).Get(quotaName, metav1.GetOptions{})
700+
Expect(err).NotTo(HaveOccurred())
701+
Expect(resourceQuotaResult.Spec.Hard[v1.ResourceCPU]).To(Equal(resource.MustParse("2")))
702+
Expect(resourceQuotaResult.Spec.Hard[v1.ResourceMemory]).To(Equal(resource.MustParse("1Gi")))
703+
704+
By("Deleting a ResourceQuota")
705+
err = deleteResourceQuota(client, ns, quotaName)
706+
Expect(err).NotTo(HaveOccurred())
707+
708+
By("Verifying the deleted ResourceQuota")
709+
_, err = client.CoreV1().ResourceQuotas(ns).Get(quotaName, metav1.GetOptions{})
710+
Expect(errors.IsNotFound(err)).To(Equal(true))
711+
})
668712
})
669713

670714
var _ = SIGDescribe("ResourceQuota [Feature:ScopeSelectors]", func() {

0 commit comments

Comments
 (0)