mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #45094 from aleksandra-malinowska/stackdriver-monitoring-test-debug
Automatic merge from submit-queue Stackdriver test fix Extend timeout & add logging missing metrics
This commit is contained in:
commit
c6f0939a87
@ -48,7 +48,7 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
pollFrequency = time.Second * 5
|
pollFrequency = time.Second * 5
|
||||||
pollTimeout = time.Minute * 7
|
pollTimeout = time.Minute * 20
|
||||||
|
|
||||||
rcName = "resource-consumer"
|
rcName = "resource-consumer"
|
||||||
replicas = 1
|
replicas = 1
|
||||||
@ -79,22 +79,34 @@ var _ = framework.KubeDescribe("Stackdriver Monitoring", func() {
|
|||||||
|
|
||||||
rc.WaitForReplicas(replicas)
|
rc.WaitForReplicas(replicas)
|
||||||
|
|
||||||
pollingFunction := checkForMetrics(projectId, gcmService, time.Now())
|
metricsMap := map[string]bool{}
|
||||||
framework.ExpectNoError(wait.Poll(pollFrequency, pollTimeout, pollingFunction))
|
pollingFunction := checkForMetrics(projectId, gcmService, time.Now(), metricsMap)
|
||||||
|
err = wait.Poll(pollFrequency, pollTimeout, pollingFunction)
|
||||||
|
if err != nil {
|
||||||
|
framework.Logf("Missing metrics: %+v\n", metricsMap)
|
||||||
|
}
|
||||||
|
framework.ExpectNoError(err)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
func checkForMetrics(projectId string, gcmService *gcm.Service, start time.Time) func() (bool, error) {
|
func checkForMetrics(projectId string, gcmService *gcm.Service, start time.Time, metricsMap map[string]bool) func() (bool, error) {
|
||||||
return func() (bool, error) {
|
return func() (bool, error) {
|
||||||
// TODO: list which metrics are missing in case of failure
|
// TODO: list which metrics are missing in case of failure
|
||||||
counter := 0
|
counter := 0
|
||||||
correctUtilization := false
|
correctUtilization := false
|
||||||
|
for _, metric := range stackdriverMetrics {
|
||||||
|
metricsMap[metric] = false
|
||||||
|
}
|
||||||
for _, metric := range stackdriverMetrics {
|
for _, metric := range stackdriverMetrics {
|
||||||
// TODO: check only for metrics from this cluster
|
// TODO: check only for metrics from this cluster
|
||||||
ts, err := fetchTimeSeries(projectId, gcmService, metric, start, time.Now())
|
ts, err := fetchTimeSeries(projectId, gcmService, metric, start, time.Now())
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
if len(ts) > 0 {
|
if len(ts) > 0 {
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
|
metricsMap[metric] = true
|
||||||
|
framework.Logf("Received %v timeseries for metric %v\n", len(ts), metric)
|
||||||
|
} else {
|
||||||
|
framework.Logf("No timeseries for metric %v\n", metric)
|
||||||
}
|
}
|
||||||
|
|
||||||
var sum float64 = 0
|
var sum float64 = 0
|
||||||
@ -111,7 +123,10 @@ func checkForMetrics(projectId string, gcmService *gcm.Service, start time.Time)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sum = sum + *max.Value.DoubleValue
|
sum = sum + *max.Value.DoubleValue
|
||||||
|
framework.Logf("Received %v points for metric %v\n",
|
||||||
|
len(t.Points), metric)
|
||||||
}
|
}
|
||||||
|
framework.Logf("Most recent cpu/utilization sum: %v\n", sum)
|
||||||
if math.Abs(sum*float64(cpuLimit)-float64(cpuUsed)) > tolerance*float64(cpuUsed) {
|
if math.Abs(sum*float64(cpuLimit)-float64(cpuUsed)) > tolerance*float64(cpuUsed) {
|
||||||
return false, nil
|
return false, nil
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user