From 9abbe66d0e572aca55aa940662692648aa0a0ada Mon Sep 17 00:00:00 2001 From: Carl St-Laurent <110201340+carl-stlaurent-form3@users.noreply.github.com> Date: Wed, 4 Oct 2023 15:26:30 -0400 Subject: [PATCH] Fix gaussian test to properly test and graph non default repeat (#137) Gaussian test now properly uses repeat parameter to run and graph output data. Fix lint issue --- internal/trigger/gaussian/gaussian_rate.go | 2 +- internal/trigger/gaussian/gaussian_rate_test.go | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/internal/trigger/gaussian/gaussian_rate.go b/internal/trigger/gaussian/gaussian_rate.go index b0dcd34a..515111a9 100644 --- a/internal/trigger/gaussian/gaussian_rate.go +++ b/internal/trigger/gaussian/gaussian_rate.go @@ -124,7 +124,7 @@ func CalculateGaussianRate(volume, jitter float64, repeat, frequency, peak, stdd if s == "" { continue } - weight, err := strconv.ParseFloat(s, 10) + weight, err := strconv.ParseFloat(s, 64) if err != nil { return nil, fmt.Errorf("unable to parse weights") } diff --git a/internal/trigger/gaussian/gaussian_rate_test.go b/internal/trigger/gaussian/gaussian_rate_test.go index 6e24ec6e..f98a75b4 100644 --- a/internal/trigger/gaussian/gaussian_rate_test.go +++ b/internal/trigger/gaussian/gaussian_rate_test.go @@ -151,12 +151,19 @@ func TestTotalVolumes(t *testing.T) { volume: 100000, repeat: 2 * time.Hour, }, + { + peak: 5 * time.Minute, + stddev: 75 * time.Second, + frequency: 1 * time.Second, + volume: 23499, + repeat: 1 * time.Hour, + }, } { t.Run(fmt.Sprintf("%d: %f every %s, stddev: %s, peak: %s, jitter %f", i, test.volume, test.frequency.String(), test.stddev, test.peak, test.jitter), func(t *testing.T) { - c := NewGaussianRateCalculator(test.peak, test.stddev, test.frequency, test.weights, test.volume, 24*time.Hour) + c := NewGaussianRateCalculator(test.peak, test.stddev, test.frequency, test.weights, test.volume, test.repeat) total := 0.0 - current := time.Now().Truncate(24 * time.Hour) - end := current.Add(24 * time.Hour) + current := time.Now().Truncate(test.repeat) + end := current.Add(test.repeat) calculate := api.WithJitter(c.For, test.jitter) var rates []float64