Skip to content

Commit

Permalink
Merge pull request kubesphere#3733 from zhu733756/master
Browse files Browse the repository at this point in the history
fix bug that edge metrcis test run failed
  • Loading branch information
ks-ci-bot authored Apr 15, 2021
2 parents 0f55e46 + c3cf47a commit e587887
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions pkg/simple/client/monitoring/metricsserver/metricsserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func TestGetNamedMetrics(t *testing.T) {
PodName: tt.podName,
NamespaceName: tt.namespaceName,
})
if diff := cmp.Diff(result, expected); diff != "" {
if diff := cmp.Diff(sortedResults(result), expected); diff != "" {
t.Fatalf("%T differ (-got, +want): %s", expected, diff)
}
})
Expand Down Expand Up @@ -506,7 +506,7 @@ func TestGetNamedMetricsOverTime(t *testing.T) {
PodName: tt.podName,
NamespaceName: tt.namespaceName,
})
if diff := cmp.Diff(result, expected); diff != "" {
if diff := cmp.Diff(sortedResults(result), expected); diff != "" {
t.Fatalf("%T differ (-got, +want): %s", expected, diff)
}
})
Expand All @@ -525,3 +525,22 @@ func jsonFromFile(expectedFile string, expectedJsonPtr interface{}) error {

return nil
}

func sortedResults(result []monitoring.Metric) []monitoring.Metric {

for _, mr := range result {
metricValues := mr.MetricData.MetricValues
length := len(metricValues)
for i, mv := range metricValues {
podName, _ := mv.Metadata["pod"]
if i == 0 && podName == "pod2" && length >= 2 {
metricValues[0], metricValues[1] = metricValues[1], metricValues[0]
}
break

}
}

return result

}

0 comments on commit e587887

Please sign in to comment.