mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Fix expected result in Custom Metrics - Stackdriver Adapter e2e test
This commit is contained in:
parent
1d4e1d2dc2
commit
d75fd82159
@ -121,11 +121,22 @@ func testAdapter(f *framework.Framework, kubeClient clientset.Interface, customM
|
||||
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 != "pods/"+CustomMetricName && resource.Name != "pods/"+UnusedMetricName {
|
||||
if resource.Name == "pods/"+CustomMetricName {
|
||||
gotCustomMetric = true
|
||||
} else if resource.Name == "pods/"+UnusedMetricName {
|
||||
gotUnusedMetric = true
|
||||
} else {
|
||||
framework.Failf("Unexpected metric %s. Only metric %s should be supported", resource.Name, CustomMetricName)
|
||||
}
|
||||
}
|
||||
if !gotCustomMetric {
|
||||
framework.Failf("Metric '%s' expected but not received", CustomMetricName)
|
||||
}
|
||||
if !gotUnusedMetric {
|
||||
framework.Failf("Metric '%s' expected but not received", UnusedMetricName)
|
||||
}
|
||||
value, err := customMetricsClient.NamespacedMetrics(f.Namespace.Name).GetForObject(schema.GroupKind{Group: "", Kind: "Pod"}, stackdriverExporterPod1, CustomMetricName)
|
||||
if err != nil {
|
||||
framework.Failf("Failed query: %s", err)
|
||||
@ -141,14 +152,11 @@ func testAdapter(f *framework.Framework, kubeClient clientset.Interface, customM
|
||||
if err != nil {
|
||||
framework.Failf("Failed query: %s", err)
|
||||
}
|
||||
if len(values.Items) != 2 {
|
||||
framework.Failf("Expected results for exactly 2 pods, but %v results received", len(values.Items))
|
||||
if len(values.Items) != 1 {
|
||||
framework.Failf("Expected results for exactly 1 pod, but %v results received", len(values.Items))
|
||||
}
|
||||
for _, value := range values.Items {
|
||||
if (value.DescribedObject.Name == stackdriverExporterPod1 && value.Value.Value() != CustomMetricValue) ||
|
||||
(value.DescribedObject.Name == stackdriverExporterPod2 && value.Value.Value() != UnusedMetricValue) {
|
||||
framework.Failf("Unexpected metric value for metric %s and pod %s: %v", CustomMetricName, value.DescribedObject.Name, value.Value.Value())
|
||||
}
|
||||
if values.Items[0].DescribedObject.Name != stackdriverExporterPod1 || values.Items[0].Value.Value() != CustomMetricValue {
|
||||
framework.Failf("Unexpected metric value for metric %s and pod %s: %v", CustomMetricName, values.Items[0].DescribedObject.Name, values.Items[0].Value.Value())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user