From 265d3da7012791e42e28f6c2d79c81aa2793348c Mon Sep 17 00:00:00 2001 From: Piotr Szczesniak Date: Wed, 19 Aug 2015 15:05:13 +0200 Subject: [PATCH] Enabled Autoscaling test that uses mem utilization metric --- test/e2e/autoscaling.go | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/test/e2e/autoscaling.go b/test/e2e/autoscaling.go index b9afa298cba..d934f79d918 100644 --- a/test/e2e/autoscaling.go +++ b/test/e2e/autoscaling.go @@ -34,6 +34,7 @@ var _ = Describe("Autoscaling", func() { f := NewFramework("autoscaling") var nodeCount int var coresPerNode int + var memCapacityMb int BeforeEach(func() { SkipUnlessProviderIs("gce") @@ -42,8 +43,10 @@ var _ = Describe("Autoscaling", func() { expectNoError(err) nodeCount = len(nodes.Items) Expect(nodeCount).NotTo(BeZero()) - res := nodes.Items[0].Status.Capacity[api.ResourceCPU] - coresPerNode = int((&res).MilliValue() / 1000) + cpu := nodes.Items[0].Status.Capacity[api.ResourceCPU] + mem := nodes.Items[0].Status.Capacity[api.ResourceMemory] + coresPerNode = int((&cpu).MilliValue() / 1000) + memCapacityMb = int((&mem).Value() / 1024 / 1024) }) AfterEach(func() { @@ -70,14 +73,16 @@ var _ = Describe("Autoscaling", func() { expectNoError(waitForClusterSize(f.Client, 1, 20*time.Minute)) }) - It("[Skipped] should scale cluster size based on memory utilization", func() { - setUpAutoscaler("memory/node_utilization", 0.5, 1, 10) + It("[Autoscaling] should scale cluster size based on memory utilization", func() { + setUpAutoscaler("memory/node_utilization", 0.5, nodeCount, nodeCount+1) - ConsumeMemory(f, "memory-utilization", 2) - expectNoError(waitForClusterSize(f.Client, 2, 20*time.Minute)) + // Consume 60% of total memory capacity in 256MB chunks. + chunks := memCapacityMb * nodeCount * 6 / 10 / 256 + ConsumeMemory(f, "memory-utilization", chunks) + expectNoError(waitForClusterSize(f.Client, nodeCount+1, 20*time.Minute)) StopConsuming(f, "memory-utilization") - expectNoError(waitForClusterSize(f.Client, 1, 20*time.Minute)) + expectNoError(waitForClusterSize(f.Client, nodeCount, 20*time.Minute)) }) It("[Skipped] should scale cluster size based on memory reservation", func() { @@ -152,8 +157,10 @@ func ConsumeCpu(f *Framework, id string, cores int) { expectNoError(RunRC(*config)) } -func ConsumeMemory(f *Framework, id string, gigabytes int) { - By(fmt.Sprintf("Running RC which consumes %v GB of memory", gigabytes)) +// Consume chunks of size 256MB. +func ConsumeMemory(f *Framework, id string, chunks int) { + CreateService(f, id) + By(fmt.Sprintf("Running RC which consumes %v MB of memory in 256MB chunks", chunks*256)) config := &RCConfig{ Client: f.Client, Name: id, @@ -161,7 +168,7 @@ func ConsumeMemory(f *Framework, id string, gigabytes int) { Timeout: 10 * time.Minute, Image: "jess/stress", Command: []string{"stress", "-m", "1"}, - Replicas: 4 * gigabytes, + Replicas: chunks, } expectNoError(RunRC(*config)) }