mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #53978 from kawych/master
Automatic merge from submit-queue (batch tested with PRs 53978, 54008, 53037). 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>. Fix expected result in Custom Metrics - Stackdriver Adapter e2e test **What this PR does / why we need it**: This PR fixes a bug in e2e tests for Custom Metrics - Stackdriver Adapter **Release note**: ```release-note NONE ```
This commit is contained in:
commit
1bb9e6ad13
@ -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