@@ -664,7 +664,51 @@ var _ = SIGDescribe("ResourceQuota", func() {
664
664
err = waitForResourceQuota (f .ClientSet , f .Namespace .Name , resourceQuotaNotBestEffort .Name , usedResources )
665
665
Expect (err ).NotTo (HaveOccurred ())
666
666
})
667
+ It ("Should be able to update and delete ResourceQuota." , func () {
668
+ client := f .ClientSet
669
+ ns := f .Namespace .Name
667
670
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
+ })
668
712
})
669
713
670
714
var _ = SIGDescribe ("ResourceQuota [Feature:ScopeSelectors]" , func () {
0 commit comments