Merge pull request #63978 from kawych/master

Automatic merge from submit-queue (batch tested with PRs 63969, 63902, 63689, 63973, 63978). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Allow for system metrics discovery in Custom Metrics - Stackdriver Adapter test

**What this PR does / why we need it**:
Allow for system metrics discovery in Custom Metrics - Stackdriver Adapter test

**Release note**:
```release-note
NONE
```
pull/8/head
Kubernetes Submit Queue 2018-05-18 15:59:25 -07:00 committed by GitHub
commit 1e689a8b8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 12 deletions

View File

@ -175,20 +175,10 @@ func verifyResponsesFromCustomMetricsAPI(f *framework.Framework, customMetricsCl
if err != nil {
framework.Failf("Failed to retrieve a list of supported metrics: %s", err)
}
gotCustomMetric, gotUnusedMetric := false, false
for _, resource := range resources.APIResources {
if resource.Name == "*/"+CustomMetricName {
gotCustomMetric = true
} else if resource.Name == "*/"+UnusedMetricName {
gotUnusedMetric = true
} else {
framework.Failf("Unexpected metric %s. Only metric %s should be supported", resource.Name, CustomMetricName)
}
}
if !gotCustomMetric {
if !containsResource(resources.APIResources, "*/custom.googleapis.com|"+CustomMetricName) {
framework.Failf("Metric '%s' expected but not received", CustomMetricName)
}
if !gotUnusedMetric {
if !containsResource(resources.APIResources, "*/custom.googleapis.com|"+UnusedMetricName) {
framework.Failf("Metric '%s' expected but not received", UnusedMetricName)
}
value, err := customMetricsClient.NamespacedMetrics(f.Namespace.Name).GetForObject(schema.GroupKind{Group: "", Kind: "Pod"}, stackdriverExporterPod1, CustomMetricName)
@ -214,6 +204,15 @@ func verifyResponsesFromCustomMetricsAPI(f *framework.Framework, customMetricsCl
}
}
func containsResource(resourcesList []metav1.APIResource, resourceName string) bool {
for _, resource := range resourcesList {
if resource.Name == resourceName {
return true
}
}
return false
}
func verifyResponseFromExternalMetricsAPI(f *framework.Framework, externalMetricsClient externalclient.ExternalMetricsClient, pod *v1.Pod) {
req1, _ := labels.NewRequirement("resource.type", selection.Equals, []string{"gke_container"})
// It's important to filter out only metrics from the right namespace, since multiple e2e tests