From ebac6de547f031f800cfc68d60b3bc95b4d58af2 Mon Sep 17 00:00:00 2001 From: Piotr Szczesniak Date: Wed, 14 Oct 2015 11:11:03 +0200 Subject: [PATCH] Fixed Initial Resources e2e test to not depend on other tests --- test/e2e/initial_resources.go | 11 ++++++++++- test/e2e/monitoring.go | 35 ++++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/test/e2e/initial_resources.go b/test/e2e/initial_resources.go index e3850705b5e..558a688975c 100644 --- a/test/e2e/initial_resources.go +++ b/test/e2e/initial_resources.go @@ -20,6 +20,7 @@ import ( "fmt" "time" + influxdb "github.com/influxdb/influxdb/client" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "k8s.io/kubernetes/pkg/api" @@ -28,7 +29,15 @@ import ( var _ = Describe("Initial Resources", func() { f := NewFramework("initial-resources") - It("[Skipped] should set initial resources based on historical data", func() { + It("[Skipped][Autoscaling Suite] should set initial resources based on historical data", func() { + // Cleanup data in InfluxDB that left from previous tests. + influxdbClient, err := getInfluxdbClient(f.Client) + expectNoError(err, "failed to create influxdb client") + _, err = influxdbClient.Query("drop series autoscaling.cpu.usage.2m", influxdb.Second) + expectNoError(err) + _, err = influxdbClient.Query("drop series autoscaling.memory.usage.2m", influxdb.Second) + expectNoError(err) + cpu := 100 mem := 200 for i := 0; i < 10; i++ { diff --git a/test/e2e/monitoring.go b/test/e2e/monitoring.go index 84e33a77374..812045bc048 100644 --- a/test/e2e/monitoring.go +++ b/test/e2e/monitoring.go @@ -132,6 +132,24 @@ func getAllNodesInCluster(c *client.Client) ([]string, error) { return result, nil } +func getInfluxdbClient(c *client.Client) (*influxdb.Client, error) { + kubeMasterHttpClient, ok := c.Client.(*http.Client) + if !ok { + Failf("failed to get master http client") + } + proxyUrl := fmt.Sprintf("%s/api/v1/proxy/namespaces/%s/services/%s:api/", getMasterHost(), api.NamespaceSystem, influxdbService) + config := &influxdb.ClientConfig{ + Host: proxyUrl, + // TODO(vishh): Infer username and pw from the Pod spec. + Username: influxdbUser, + Password: influxdbPW, + Database: influxdbDatabaseName, + HttpClient: kubeMasterHttpClient, + IsSecure: true, + } + return influxdb.NewClient(config) +} + func getInfluxdbData(c *influxdb.Client, query string) (map[string]bool, error) { series, err := c.Query(query, influxdb.Second) if err != nil { @@ -204,21 +222,8 @@ func testMonitoringUsingHeapsterInfluxdb(c *client.Client) { expectNoError(err) expectNoError(expectedServicesExist(c)) // TODO: Wait for all pods and services to be running. - kubeMasterHttpClient, ok := c.Client.(*http.Client) - if !ok { - Failf("failed to get master http client") - } - proxyUrl := fmt.Sprintf("%s/api/v1/proxy/namespaces/%s/services/%s:api/", getMasterHost(), api.NamespaceSystem, influxdbService) - config := &influxdb.ClientConfig{ - Host: proxyUrl, - // TODO(vishh): Infer username and pw from the Pod spec. - Username: influxdbUser, - Password: influxdbPW, - Database: influxdbDatabaseName, - HttpClient: kubeMasterHttpClient, - IsSecure: true, - } - influxdbClient, err := influxdb.NewClient(config) + + influxdbClient, err := getInfluxdbClient(c) expectNoError(err, "failed to create influxdb client") expectedNodes, err := getAllNodesInCluster(c)