diff --git a/hack/jenkins/e2e.sh b/hack/jenkins/e2e.sh index 94e65a9f84a..a38db38fb0f 100755 --- a/hack/jenkins/e2e.sh +++ b/hack/jenkins/e2e.sh @@ -102,6 +102,7 @@ GCE_FLAKY_TESTS=( # Tests which are not able to be run in parallel. GCE_PARALLEL_SKIP_TESTS=( ${GCE_DEFAULT_SKIP_TESTS[@]:+${GCE_DEFAULT_SKIP_TESTS[@]}} + "Autoscaling" "Etcd" "NetworkingNew" "Nodes\sNetwork" @@ -127,6 +128,7 @@ GCE_PARALLEL_FLAKY_TESTS=( # Tests that should not run on soak cluster. GCE_SOAK_CONTINUOUS_SKIP_TESTS=( + "Autoscaling" "Density.*30\spods" "Elasticsearch" "Etcd.*SIGKILL" @@ -141,6 +143,10 @@ GCE_SOAK_CONTINUOUS_SKIP_TESTS=( "Skipped" ) +GCE_RELEASE_SKIP_TESTS=( + "Autoscaling" + ) + # Define environment variables based on the Jenkins project name. case ${JOB_NAME} in # Runs all non-flaky tests on GCE, sequentially. @@ -283,6 +289,7 @@ case ${JOB_NAME} in : ${E2E_NETWORK:="e2e-gce-release"} : ${GINKGO_TEST_ARGS:="--ginkgo.skip=$(join_regex_allow_empty \ ${GCE_DEFAULT_SKIP_TESTS[@]:+${GCE_DEFAULT_SKIP_TESTS[@]}} \ + ${GCE_RELEASE_SKIP_TESTS[@]:+${GCE_RELEASE_SKIP_TESTS[@]}} \ ${GCE_FLAKY_TESTS[@]:+${GCE_FLAKY_TESTS[@]}} \ )"} : ${KUBE_GCE_INSTANCE_PREFIX="e2e-gce"} diff --git a/test/e2e/autoscaling.go b/test/e2e/autoscaling.go index cfb37f7085c..88ed3ac0bc4 100644 --- a/test/e2e/autoscaling.go +++ b/test/e2e/autoscaling.go @@ -21,29 +21,43 @@ import ( "os/exec" "time" + "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/fields" + "k8s.io/kubernetes/pkg/labels" + "k8s.io/kubernetes/pkg/util" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" ) var _ = Describe("Autoscaling", func() { f := NewFramework("autoscaling") + var nodeCount int + var coresPerNode int BeforeEach(func() { - // Ensure cluster size is equal to 1. - expectNoError(waitForClusterSize(f.Client, 1)) + SkipUnlessProviderIs("gce") + + nodes, err := f.Client.Nodes().List(labels.Everything(), fields.Everything()) + expectNoError(err) + nodeCount = len(nodes.Items) + Expect(nodeCount).NotTo(BeZero()) + res := nodes.Items[0].Status.Capacity[api.ResourceCPU] + coresPerNode = int((&res).MilliValue() / 1000) }) AfterEach(func() { cleanUpAutoscaler() }) - It("[Skipped] [Autoscaling] should scale cluster size based on cpu utilization", func() { - setUpAutoscaler("cpu/node_utilization", 0.8, 1, 10) + It("[Autoscaling] should scale cluster size based on cpu utilization", func() { + setUpAutoscaler("cpu/node_utilization", 0.7, nodeCount, nodeCount+1) - ConsumeCpu(f, "cpu-utilization", 1) - expectNoError(waitForClusterSize(f.Client, 2)) + ConsumeCpu(f, "cpu-utilization", nodeCount*coresPerNode) + expectNoError(waitForClusterSize(f.Client, nodeCount+1)) StopConsuming(f, "cpu-utilization") - expectNoError(waitForClusterSize(f.Client, 1)) + expectNoError(waitForClusterSize(f.Client, nodeCount)) }) It("[Skipped] [Autoscaling] should scale cluster size based on cpu reservation", func() { @@ -77,7 +91,7 @@ var _ = Describe("Autoscaling", func() { }) }) -func setUpAutoscaler(metric string, target float64, min, max int64) { +func setUpAutoscaler(metric string, target float64, min, max int) { // TODO integrate with kube-up.sh script once it will support autoscaler setup. By("Setting up autoscaler to scale based on " + metric) _, err := exec.Command("gcloud", "preview", "autoscaler", @@ -100,7 +114,28 @@ func cleanUpAutoscaler() { expectNoError(err) } +func CreateService(f *Framework, name string) { + By("Running sevice" + name) + service := &api.Service{ + ObjectMeta: api.ObjectMeta{ + Name: name, + }, + Spec: api.ServiceSpec{ + Selector: map[string]string{ + "name": name, + }, + Ports: []api.ServicePort{{ + Port: 8080, + TargetPort: util.NewIntOrStringFromInt(8080), + }}, + }, + } + _, err := f.Client.Services(f.Namespace.Name).Create(service) + Expect(err).NotTo(HaveOccurred()) +} + func ConsumeCpu(f *Framework, id string, cores int) { + CreateService(f, id) By(fmt.Sprintf("Running RC which consumes %v cores", cores)) config := &RCConfig{ Client: f.Client, @@ -157,6 +192,9 @@ func ReserveMemory(f *Framework, id string, gigabytes int) { } func StopConsuming(f *Framework, id string) { + By("Stopping service " + id) + err := f.Client.Services(f.Namespace.Name).Delete(id) + Expect(err).NotTo(HaveOccurred()) By("Stopping RC " + id) expectNoError(DeleteRC(f.Client, f.Namespace.Name, id)) }