INNER CODE UNIT · Go
TestKillTimesInRangeOddsForMtbfLongerThanADay
asobti/kube-monkey · internal/pkg/calendar/calendar_test.go:120
func TestKillTimesInRangeOddsForMtbfLongerThanADay(t *testing.T) {
loc := time.UTC
now := time.Date(2024, 3, 12, 8, 0, 0, 0, loc)
r := testRand()
for mtbf, expected := range map[time.Duration]float64{
48 * time.Hour: 0.5,
72 * time.Hour: 1.0 / 3.0,
240 * time.Hour: 0.1,
} {
const days = 20000
kills := 0
for day := 0; day < days; day++ {
kills += len(killTimesInRange(now, r, mtbf, 10, 16, loc))
}
assert.InDelta(t, expected, float64(kills)/days, 0.02, mtbf.String())
}