mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
ResourceQuota e2e should not assume 1 secret by default
This commit is contained in:
parent
c9e4c846e6
commit
cb1f1d373e
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package e2e
|
package e2e
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
@ -87,15 +88,23 @@ var _ = Describe("ResourceQuota", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("should create a ResourceQuota and capture the life of a secret.", func() {
|
It("should create a ResourceQuota and capture the life of a secret.", func() {
|
||||||
|
By("Discovering how many secrets are in namespace by default")
|
||||||
|
secrets, err := f.Client.Secrets(f.Namespace.Name).List(api.ListOptions{})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
defaultSecrets := fmt.Sprintf("%d", len(secrets.Items))
|
||||||
|
hardSecrets := fmt.Sprintf("%d", len(secrets.Items)+1)
|
||||||
|
|
||||||
By("Creating a ResourceQuota")
|
By("Creating a ResourceQuota")
|
||||||
quotaName := "test-quota"
|
quotaName := "test-quota"
|
||||||
resourceQuota := newTestResourceQuota(quotaName)
|
resourceQuota := newTestResourceQuota(quotaName)
|
||||||
resourceQuota, err := createResourceQuota(f.Client, f.Namespace.Name, resourceQuota)
|
resourceQuota.Spec.Hard[api.ResourceSecrets] = resource.MustParse(hardSecrets)
|
||||||
|
resourceQuota, err = createResourceQuota(f.Client, f.Namespace.Name, resourceQuota)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
By("Ensuring resource quota status is calculated")
|
By("Ensuring resource quota status is calculated")
|
||||||
usedResources := api.ResourceList{}
|
usedResources := api.ResourceList{}
|
||||||
usedResources[api.ResourceQuotas] = resource.MustParse("1")
|
usedResources[api.ResourceQuotas] = resource.MustParse("1")
|
||||||
|
usedResources[api.ResourceSecrets] = resource.MustParse(defaultSecrets)
|
||||||
err = waitForResourceQuota(f.Client, f.Namespace.Name, quotaName, usedResources)
|
err = waitForResourceQuota(f.Client, f.Namespace.Name, quotaName, usedResources)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
@ -106,8 +115,7 @@ var _ = Describe("ResourceQuota", func() {
|
|||||||
|
|
||||||
By("Ensuring resource quota status captures secret creation")
|
By("Ensuring resource quota status captures secret creation")
|
||||||
usedResources = api.ResourceList{}
|
usedResources = api.ResourceList{}
|
||||||
usedResources[api.ResourceQuotas] = resource.MustParse("1")
|
usedResources[api.ResourceSecrets] = resource.MustParse(hardSecrets)
|
||||||
usedResources[api.ResourceSecrets] = resource.MustParse("2")
|
|
||||||
// we expect there to be two secrets because each namespace will receive
|
// we expect there to be two secrets because each namespace will receive
|
||||||
// a service account token secret by default
|
// a service account token secret by default
|
||||||
err = waitForResourceQuota(f.Client, f.Namespace.Name, quotaName, usedResources)
|
err = waitForResourceQuota(f.Client, f.Namespace.Name, quotaName, usedResources)
|
||||||
@ -118,7 +126,7 @@ var _ = Describe("ResourceQuota", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
By("Ensuring resource quota status released usage")
|
By("Ensuring resource quota status released usage")
|
||||||
usedResources[api.ResourceSecrets] = resource.MustParse("1")
|
usedResources[api.ResourceSecrets] = resource.MustParse(defaultSecrets)
|
||||||
err = waitForResourceQuota(f.Client, f.Namespace.Name, quotaName, usedResources)
|
err = waitForResourceQuota(f.Client, f.Namespace.Name, quotaName, usedResources)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
})
|
})
|
||||||
@ -379,7 +387,6 @@ func newTestResourceQuota(name string) *api.ResourceQuota {
|
|||||||
hard[api.ResourceQuotas] = resource.MustParse("1")
|
hard[api.ResourceQuotas] = resource.MustParse("1")
|
||||||
hard[api.ResourceCPU] = resource.MustParse("1")
|
hard[api.ResourceCPU] = resource.MustParse("1")
|
||||||
hard[api.ResourceMemory] = resource.MustParse("500Mi")
|
hard[api.ResourceMemory] = resource.MustParse("500Mi")
|
||||||
hard[api.ResourceSecrets] = resource.MustParse("2")
|
|
||||||
return &api.ResourceQuota{
|
return &api.ResourceQuota{
|
||||||
ObjectMeta: api.ObjectMeta{Name: name},
|
ObjectMeta: api.ObjectMeta{Name: name},
|
||||||
Spec: api.ResourceQuotaSpec{Hard: hard},
|
Spec: api.ResourceQuotaSpec{Hard: hard},
|
||||||
|
Loading…
Reference in New Issue
Block a user