Skip to content

Commit 9abbe66

Browse files
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
1 parent 52025dc commit 9abbe66

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

internal/trigger/gaussian/gaussian_rate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func CalculateGaussianRate(volume, jitter float64, repeat, frequency, peak, stdd
124124
if s == "" {
125125
continue
126126
}
127-
weight, err := strconv.ParseFloat(s, 10)
127+
weight, err := strconv.ParseFloat(s, 64)
128128
if err != nil {
129129
return nil, fmt.Errorf("unable to parse weights")
130130
}

internal/trigger/gaussian/gaussian_rate_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,19 @@ func TestTotalVolumes(t *testing.T) {
151151
volume: 100000,
152152
repeat: 2 * time.Hour,
153153
},
154+
{
155+
peak: 5 * time.Minute,
156+
stddev: 75 * time.Second,
157+
frequency: 1 * time.Second,
158+
volume: 23499,
159+
repeat: 1 * time.Hour,
160+
},
154161
} {
155162
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) {
156-
c := NewGaussianRateCalculator(test.peak, test.stddev, test.frequency, test.weights, test.volume, 24*time.Hour)
163+
c := NewGaussianRateCalculator(test.peak, test.stddev, test.frequency, test.weights, test.volume, test.repeat)
157164
total := 0.0
158-
current := time.Now().Truncate(24 * time.Hour)
159-
end := current.Add(24 * time.Hour)
165+
current := time.Now().Truncate(test.repeat)
166+
end := current.Add(test.repeat)
160167

161168
calculate := api.WithJitter(c.For, test.jitter)
162169
var rates []float64

0 commit comments

Comments
 (0)