From 3b034a8293a1b4c3a2b0d183c62f6ec50d8cdbd6 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Tue, 9 Jun 2015 14:19:21 -0700 Subject: [PATCH] Add a test that verifies pods with resource limits schedule. --- test/e2e/pods.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/e2e/pods.go b/test/e2e/pods.go index 62a7151a711..b862eed718b 100644 --- a/test/e2e/pods.go +++ b/test/e2e/pods.go @@ -23,6 +23,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" + "github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" @@ -132,6 +133,7 @@ func testHostIP(c *client.Client, pod *api.Pod) { var _ = Describe("Pods", func() { var c *client.Client + // TODO convert this to use the NewFramework(...) BeforeEach(func() { var err error @@ -155,6 +157,42 @@ var _ = Describe("Pods", func() { }, }) }) + It("should be schedule with cpu and memory limits", func() { + podClient := c.Pods(api.NamespaceDefault) + + By("creating the pod") + name := "pod-update-" + string(util.NewUUID()) + value := strconv.Itoa(time.Now().Nanosecond()) + pod := &api.Pod{ + ObjectMeta: api.ObjectMeta{ + Name: name, + Labels: map[string]string{ + "name": "foo", + "time": value, + }, + }, + Spec: api.PodSpec{ + Containers: []api.Container{ + { + Name: "nginx", + Image: "gcr.io/google_containers/pause", + Resources: api.ResourceRequirements{ + Limits: api.ResourceList{ + api.ResourceCPU: *resource.NewMilliQuantity(100, resource.DecimalSI), + api.ResourceMemory: *resource.NewQuantity(10*1024*1024, resource.DecimalSI), + }, + }, + }, + }, + }, + } + defer podClient.Delete(pod.Name, nil) + _, err := podClient.Create(pod) + if err != nil { + Fail(fmt.Sprintf("Error creating a pod: %v", err)) + } + expectNoError(waitForPodRunning(c, pod.Name)) + }) It("should be submitted and removed", func() { podClient := c.Pods(api.NamespaceDefault)