Merge pull request #14100 from socaa/rc-limit

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot 2015-09-17 07:44:28 -07:00
commit 8071a73c6b
2 changed files with 21 additions and 19 deletions

View File

@ -60,9 +60,11 @@ type ResourceConsumer struct {
NewResourceConsumer creates new ResourceConsumer NewResourceConsumer creates new ResourceConsumer
initCPU argument is in millicores initCPU argument is in millicores
initMemory argument is in megabytes initMemory argument is in megabytes
memLimit argument is in megabytes, memLimit is a maximum amount of memory that can be consumed by a single pod
cpuLimit argument is in millicores, cpuLimit is a maximum amount of cpu that can be consumed by a single pod
*/ */
func NewResourceConsumer(name string, replicas, initCPU, initMemory int, framework *Framework) *ResourceConsumer { func NewResourceConsumer(name string, replicas, initCPU, initMemory int, cpuLimit, memLimit int64, framework *Framework) *ResourceConsumer {
runServiceAndRCForResourceConsumer(framework.Client, framework.Namespace.Name, name, replicas) runServiceAndRCForResourceConsumer(framework.Client, framework.Namespace.Name, name, replicas, cpuLimit, memLimit)
rc := &ResourceConsumer{ rc := &ResourceConsumer{
name: name, name: name,
framework: framework, framework: framework,
@ -204,7 +206,7 @@ func (rc *ResourceConsumer) CleanUp() {
expectNoError(rc.framework.Client.Experimental().HorizontalPodAutoscalers(rc.framework.Namespace.Name).Delete(rc.name, api.NewDeleteOptions(0))) expectNoError(rc.framework.Client.Experimental().HorizontalPodAutoscalers(rc.framework.Namespace.Name).Delete(rc.name, api.NewDeleteOptions(0)))
} }
func runServiceAndRCForResourceConsumer(c *client.Client, ns, name string, replicas int) { func runServiceAndRCForResourceConsumer(c *client.Client, ns, name string, replicas int, cpuLimitMillis, memLimitMb int64) {
_, err := c.Services(ns).Create(&api.Service{ _, err := c.Services(ns).Create(&api.Service{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: name, Name: name,
@ -228,7 +230,8 @@ func runServiceAndRCForResourceConsumer(c *client.Client, ns, name string, repli
Namespace: ns, Namespace: ns,
Timeout: timeoutRC, Timeout: timeoutRC,
Replicas: replicas, Replicas: replicas,
CpuLimit: cpuLimitMillis,
MemLimit: memLimitMb * 1024 * 1024, // MemLimit is in bytes
} }
expectNoError(RunRC(config)) expectNoError(RunRC(config))
} }

View File

@ -42,28 +42,28 @@ var _ = Describe("Horizontal pod autoscaling", func() {
// CPU tests // CPU tests
It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods (scale resource: CPU)", func() { It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods (scale resource: CPU)", func() {
rc = NewResourceConsumer("rc", 1, 700, 0, f) rc = NewResourceConsumer("rc", 1, 700, 0, 800, 100, f)
createCPUHorizontalPodAutoscaler(rc, "0.3") createCPUHorizontalPodAutoscaler(rc, "0.3")
rc.WaitForReplicas(3) rc.WaitForReplicas(3)
rc.CleanUp() rc.CleanUp()
}) })
It("[Skipped][Horizontal pod autoscaling Suite] should scale from 3 pods to 1 pod (scale resource: CPU)", func() { It("[Skipped][Horizontal pod autoscaling Suite] should scale from 3 pods to 1 pod (scale resource: CPU)", func() {
rc = NewResourceConsumer("rc", 3, 0, 0, f) rc = NewResourceConsumer("rc", 3, 0, 0, 100, 100, f)
createCPUHorizontalPodAutoscaler(rc, "0.7") createCPUHorizontalPodAutoscaler(rc, "0.7")
rc.WaitForReplicas(1) rc.WaitForReplicas(1)
rc.CleanUp() rc.CleanUp()
}) })
It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to maximum 5 pods (scale resource: CPU)", func() { It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to maximum 5 pods (scale resource: CPU)", func() {
rc = NewResourceConsumer("rc", 1, 700, 0, f) rc = NewResourceConsumer("rc", 1, 700, 0, 800, 100, f)
createCPUHorizontalPodAutoscaler(rc, "0.1") createCPUHorizontalPodAutoscaler(rc, "0.1")
rc.WaitForReplicas(5) rc.WaitForReplicas(5)
rc.CleanUp() rc.CleanUp()
}) })
It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods and from 3 to 1 (scale resource: CPU)", func() { It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods and from 3 to 1 (scale resource: CPU)", func() {
rc = NewResourceConsumer("rc", 1, 700, 0, f) rc = NewResourceConsumer("rc", 1, 700, 0, 800, 100, f)
createCPUHorizontalPodAutoscaler(rc, "0.3") createCPUHorizontalPodAutoscaler(rc, "0.3")
rc.WaitForReplicas(3) rc.WaitForReplicas(3)
rc.ConsumeCPU(300) rc.ConsumeCPU(300)
@ -72,7 +72,7 @@ var _ = Describe("Horizontal pod autoscaling", func() {
}) })
It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods and from 3 to 5 (scale resource: CPU)", func() { It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods and from 3 to 5 (scale resource: CPU)", func() {
rc = NewResourceConsumer("rc", 1, 300, 0, f) rc = NewResourceConsumer("rc", 1, 300, 0, 400, 100, f)
createCPUHorizontalPodAutoscaler(rc, "0.1") createCPUHorizontalPodAutoscaler(rc, "0.1")
rc.WaitForReplicas(3) rc.WaitForReplicas(3)
rc.ConsumeCPU(700) rc.ConsumeCPU(700)
@ -81,7 +81,7 @@ var _ = Describe("Horizontal pod autoscaling", func() {
}) })
It("[Skipped][Horizontal pod autoscaling Suite] should scale from 3 pods to 1 pod and from 1 to 3 (scale resource: CPU)", func() { It("[Skipped][Horizontal pod autoscaling Suite] should scale from 3 pods to 1 pod and from 1 to 3 (scale resource: CPU)", func() {
rc = NewResourceConsumer("rc", 3, 0, 0, f) rc = NewResourceConsumer("rc", 3, 0, 0, 800, 100, f)
createCPUHorizontalPodAutoscaler(rc, "0.3") createCPUHorizontalPodAutoscaler(rc, "0.3")
rc.WaitForReplicas(1) rc.WaitForReplicas(1)
rc.ConsumeCPU(700) rc.ConsumeCPU(700)
@ -90,7 +90,7 @@ var _ = Describe("Horizontal pod autoscaling", func() {
}) })
It("[Skipped][Horizontal pod autoscaling Suite] should scale from 5 pods to 3 pods and from 3 to 1 (scale resource: CPU)", func() { It("[Skipped][Horizontal pod autoscaling Suite] should scale from 5 pods to 3 pods and from 3 to 1 (scale resource: CPU)", func() {
rc = NewResourceConsumer("rc", 5, 700, 0, f) rc = NewResourceConsumer("rc", 5, 700, 0, 200, 100, f)
createCPUHorizontalPodAutoscaler(rc, "0.3") createCPUHorizontalPodAutoscaler(rc, "0.3")
rc.WaitForReplicas(3) rc.WaitForReplicas(3)
rc.ConsumeCPU(100) rc.ConsumeCPU(100)
@ -100,28 +100,28 @@ var _ = Describe("Horizontal pod autoscaling", func() {
// Memory tests // Memory tests
It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods (scale resource: Memory)", func() { It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods (scale resource: Memory)", func() {
rc = NewResourceConsumer("rc", 1, 0, 800, f) rc = NewResourceConsumer("rc", 1, 0, 800, 100, 900, f)
createMemoryHorizontalPodAutoscaler(rc, "300") createMemoryHorizontalPodAutoscaler(rc, "300")
rc.WaitForReplicas(3) rc.WaitForReplicas(3)
rc.CleanUp() rc.CleanUp()
}) })
It("[Skipped][Horizontal pod autoscaling Suite] should scale from 3 pods to 1 pod (scale resource: Memory)", func() { It("[Skipped][Horizontal pod autoscaling Suite] should scale from 3 pods to 1 pod (scale resource: Memory)", func() {
rc = NewResourceConsumer("rc", 3, 0, 0, f) rc = NewResourceConsumer("rc", 3, 0, 0, 100, 100, f)
createMemoryHorizontalPodAutoscaler(rc, "700") createMemoryHorizontalPodAutoscaler(rc, "700")
rc.WaitForReplicas(1) rc.WaitForReplicas(1)
rc.CleanUp() rc.CleanUp()
}) })
It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to maximum 5 pods (scale resource: Memory)", func() { It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to maximum 5 pods (scale resource: Memory)", func() {
rc = NewResourceConsumer("rc", 1, 0, 700, f) rc = NewResourceConsumer("rc", 1, 0, 700, 100, 800, f)
createMemoryHorizontalPodAutoscaler(rc, "100") createMemoryHorizontalPodAutoscaler(rc, "100")
rc.WaitForReplicas(5) rc.WaitForReplicas(5)
rc.CleanUp() rc.CleanUp()
}) })
It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods and from 3 to 1 (scale resource: Memory)", func() { It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods and from 3 to 1 (scale resource: Memory)", func() {
rc = NewResourceConsumer("rc", 1, 0, 700, f) rc = NewResourceConsumer("rc", 1, 0, 700, 100, 800, f)
createMemoryHorizontalPodAutoscaler(rc, "300") createMemoryHorizontalPodAutoscaler(rc, "300")
rc.WaitForReplicas(3) rc.WaitForReplicas(3)
rc.ConsumeMem(100) rc.ConsumeMem(100)
@ -130,7 +130,7 @@ var _ = Describe("Horizontal pod autoscaling", func() {
}) })
It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods and from 3 to 5 (scale resource: Memory)", func() { It("[Skipped][Horizontal pod autoscaling Suite] should scale from 1 pod to 3 pods and from 3 to 5 (scale resource: Memory)", func() {
rc = NewResourceConsumer("rc", 1, 0, 500, f) rc = NewResourceConsumer("rc", 1, 0, 500, 100, 1100, f)
createMemoryHorizontalPodAutoscaler(rc, "200") createMemoryHorizontalPodAutoscaler(rc, "200")
rc.WaitForReplicas(3) rc.WaitForReplicas(3)
rc.ConsumeMem(1000) rc.ConsumeMem(1000)
@ -139,16 +139,15 @@ var _ = Describe("Horizontal pod autoscaling", func() {
}) })
It("[Skipped][Horizontal pod autoscaling Suite] should scale from 3 pods to 1 pod and from 1 to 3 (scale resource: Memory)", func() { It("[Skipped][Horizontal pod autoscaling Suite] should scale from 3 pods to 1 pod and from 1 to 3 (scale resource: Memory)", func() {
rc = NewResourceConsumer("rc", 3, 0, 0, f) rc = NewResourceConsumer("rc", 3, 0, 0, 100, 800, f)
createMemoryHorizontalPodAutoscaler(rc, "300") createMemoryHorizontalPodAutoscaler(rc, "300")
rc.WaitForReplicas(1) rc.WaitForReplicas(1)
rc.ConsumeMem(700) rc.ConsumeMem(700)
rc.WaitForReplicas(3) rc.WaitForReplicas(3)
rc.CleanUp() rc.CleanUp()
}) })
It("[Skipped][Horizontal pod autoscaling Suite] should scale from 5 pods to 3 pods and from 3 to 1 (scale resource: Memory)", func() { It("[Skipped][Horizontal pod autoscaling Suite] should scale from 5 pods to 3 pods and from 3 to 1 (scale resource: Memory)", func() {
rc = NewResourceConsumer("rc", 5, 0, 700, f) rc = NewResourceConsumer("rc", 5, 0, 700, 100, 800, f)
createMemoryHorizontalPodAutoscaler(rc, "300") createMemoryHorizontalPodAutoscaler(rc, "300")
rc.WaitForReplicas(3) rc.WaitForReplicas(3)
rc.ConsumeMem(100) rc.ConsumeMem(100)