From 2417f953081c81e9d2f1ff58d69e1c44761e31b4 Mon Sep 17 00:00:00 2001 From: Guoliang Wang Date: Sat, 9 Jun 2018 09:26:19 +0800 Subject: [PATCH] fix integer divide by zero panic --- test/integration/scheduler_perf/scheduler_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/integration/scheduler_perf/scheduler_test.go b/test/integration/scheduler_perf/scheduler_test.go index b7134d6953d..c6ecc2e751c 100644 --- a/test/integration/scheduler_perf/scheduler_test.go +++ b/test/integration/scheduler_perf/scheduler_test.go @@ -162,8 +162,12 @@ func schedulePods(config *testConfig) int32 { // return the worst-case-scenario interval that was seen during this time. // Note this should never be low due to cold-start, so allow bake in sched time if necessary. if len(scheduled) >= config.numPods { + consumed := int(time.Since(start) / time.Second) + if consumed <= 0 { + consumed = 1 + } fmt.Printf("Scheduled %v Pods in %v seconds (%v per second on average). min QPS was %v\n", - config.numPods, int(time.Since(start)/time.Second), config.numPods/int(time.Since(start)/time.Second), minQps) + config.numPods, consumed, config.numPods/consumed, minQps) return minQps }