From cd7859901c66736028cec9f673025b1a98c6d2a0 Mon Sep 17 00:00:00 2001 From: YuikoTakada Date: Fri, 22 Nov 2019 02:27:13 +0000 Subject: [PATCH] Fix func VerifyLatencyWithinThreshold() to local --- test/e2e/framework/metrics/latencies.go | 16 ---------------- test/e2e_node/density_test.go | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/test/e2e/framework/metrics/latencies.go b/test/e2e/framework/metrics/latencies.go index ffb39d4e611..a6d733fe795 100644 --- a/test/e2e/framework/metrics/latencies.go +++ b/test/e2e/framework/metrics/latencies.go @@ -17,7 +17,6 @@ limitations under the License. package metrics import ( - "fmt" "math" "time" @@ -31,21 +30,6 @@ const ( SingleCallTimeout = 5 * time.Minute ) -// VerifyLatencyWithinThreshold verifies whether 50, 90 and 99th percentiles of a latency metric are -// within the expected threshold. -func VerifyLatencyWithinThreshold(threshold, actual LatencyMetric, metricName string) error { - if actual.Perc50 > threshold.Perc50 { - return fmt.Errorf("too high %v latency 50th percentile: %v", metricName, actual.Perc50) - } - if actual.Perc90 > threshold.Perc90 { - return fmt.Errorf("too high %v latency 90th percentile: %v", metricName, actual.Perc90) - } - if actual.Perc99 > threshold.Perc99 { - return fmt.Errorf("too high %v latency 99th percentile: %v", metricName, actual.Perc99) - } - return nil -} - // PodLatencyData encapsulates pod startup latency information. type PodLatencyData struct { // Name of the pod diff --git a/test/e2e_node/density_test.go b/test/e2e_node/density_test.go index a33f0bc47e3..6a2a093df20 100644 --- a/test/e2e_node/density_test.go +++ b/test/e2e_node/density_test.go @@ -533,6 +533,21 @@ func createBatchPodSequential(f *framework.Framework, pods []*v1.Pod) (time.Dura return batchLag, e2eLags } +// verifyLatencyWithinThreshold verifies whether 50, 90 and 99th percentiles of a latency metric are +// within the expected threshold. +func verifyLatencyWithinThreshold(threshold, actual e2emetrics.LatencyMetric, metricName string) error { + if actual.Perc50 > threshold.Perc50 { + return fmt.Errorf("too high %v latency 50th percentile: %v", metricName, actual.Perc50) + } + if actual.Perc90 > threshold.Perc90 { + return fmt.Errorf("too high %v latency 90th percentile: %v", metricName, actual.Perc90) + } + if actual.Perc99 > threshold.Perc99 { + return fmt.Errorf("too high %v latency 99th percentile: %v", metricName, actual.Perc99) + } + return nil +} + // logAndVerifyLatency verifies that whether pod creation latency satisfies the limit. func logAndVerifyLatency(batchLag time.Duration, e2eLags []e2emetrics.PodLatencyData, podStartupLimits e2emetrics.LatencyMetric, podBatchStartupLimit time.Duration, testInfo map[string]string, isVerify bool) { @@ -549,7 +564,7 @@ func logAndVerifyLatency(batchLag time.Duration, e2eLags []e2emetrics.PodLatency if isVerify { // check whether e2e pod startup time is acceptable. - framework.ExpectNoError(e2emetrics.VerifyLatencyWithinThreshold(podStartupLimits, podStartupLatency, "pod startup")) + framework.ExpectNoError(verifyLatencyWithinThreshold(podStartupLimits, podStartupLatency, "pod startup")) // check bactch pod creation latency if podBatchStartupLimit > 0 {