mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-25 19:43:22 +00:00
Merge pull request #15610 from piosz/enable-ir-e2e
Fixed Initial Resources e2e test to not depend on other tests
This commit is contained in:
commit
4264aac1e9
@ -20,6 +20,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
influxdb "github.com/influxdb/influxdb/client"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
@ -28,7 +29,15 @@ import (
|
|||||||
var _ = Describe("Initial Resources", func() {
|
var _ = Describe("Initial Resources", func() {
|
||||||
f := NewFramework("initial-resources")
|
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
|
cpu := 100
|
||||||
mem := 200
|
mem := 200
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
|
@ -132,6 +132,24 @@ func getAllNodesInCluster(c *client.Client) ([]string, error) {
|
|||||||
return result, nil
|
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) {
|
func getInfluxdbData(c *influxdb.Client, query string) (map[string]bool, error) {
|
||||||
series, err := c.Query(query, influxdb.Second)
|
series, err := c.Query(query, influxdb.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -204,21 +222,8 @@ func testMonitoringUsingHeapsterInfluxdb(c *client.Client) {
|
|||||||
expectNoError(err)
|
expectNoError(err)
|
||||||
expectNoError(expectedServicesExist(c))
|
expectNoError(expectedServicesExist(c))
|
||||||
// TODO: Wait for all pods and services to be running.
|
// TODO: Wait for all pods and services to be running.
|
||||||
kubeMasterHttpClient, ok := c.Client.(*http.Client)
|
|
||||||
if !ok {
|
influxdbClient, err := getInfluxdbClient(c)
|
||||||
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)
|
|
||||||
expectNoError(err, "failed to create influxdb client")
|
expectNoError(err, "failed to create influxdb client")
|
||||||
|
|
||||||
expectedNodes, err := getAllNodesInCluster(c)
|
expectedNodes, err := getAllNodesInCluster(c)
|
||||||
|
Loading…
Reference in New Issue
Block a user