Fixed Initial Resources e2e test to not depend on other tests

This commit is contained in:
Piotr Szczesniak 2015-10-14 11:11:03 +02:00
parent 4008c65323
commit ebac6de547
2 changed files with 30 additions and 16 deletions

View File

@ -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++ {

View File

@ -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)