From 8db22cef968b1d8afda5e45a9f45d2ea89a6689a Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Fri, 13 Nov 2020 20:22:58 +0530 Subject: [PATCH] Test Datasource/Bug: Fixes division by zero in csv metric values scenario (#29029) (#29068) Closes #8705 (cherry picked from commit 9659c98d616814ed2f194d86f12976fee95cc8db) Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com> --- pkg/tsdb/testdatasource/scenarios.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/tsdb/testdatasource/scenarios.go b/pkg/tsdb/testdatasource/scenarios.go index 81da5217259..dc5852b0327 100644 --- a/pkg/tsdb/testdatasource/scenarios.go +++ b/pkg/tsdb/testdatasource/scenarios.go @@ -237,7 +237,10 @@ func init() { series := newSeriesForQuery(query, 0) startTime := context.TimeRange.GetFromAsMsEpoch() endTime := context.TimeRange.GetToAsMsEpoch() - step := (endTime - startTime) / int64(len(values)-1) + var step int64 = 0 + if len(values) > 1 { + step = (endTime - startTime) / int64(len(values)-1) + } for _, val := range values { series.Points = append(series.Points, tsdb.TimePoint{val, null.FloatFrom(float64(startTime))})