mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Allow for system metrics discovery in Custom Metrics - Stackdriver Adapter test
This commit is contained in:
parent
5686fcfcf8
commit
63e6496c61
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user