9d1d0e72c2
- add new feature flag to support enabling the dispatcher sync timer on the alertmanager - this attempts to synchronize the flushes across HA nodes to decrease amount of duplicate notifications --------- Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
37 lines
937 B
Go
37 lines
937 B
Go
package notifier
|
|
|
|
import (
|
|
"testing"
|
|
|
|
alertingNotify "github.com/grafana/alerting/notify"
|
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGetDispatchTimer(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
featureFlagValue bool
|
|
expected alertingNotify.DispatchTimer
|
|
}{
|
|
{
|
|
name: "feature flag enabled returns sync timer",
|
|
featureFlagValue: true,
|
|
expected: alertingNotify.DispatchTimerSync,
|
|
},
|
|
{
|
|
name: "feature flag disabled returns default timer",
|
|
featureFlagValue: false,
|
|
expected: alertingNotify.DispatchTimerDefault,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
features := featuremgmt.WithFeatures(featuremgmt.FlagAlertingSyncDispatchTimer, tt.featureFlagValue)
|
|
result := GetDispatchTimer(features)
|
|
require.Equal(t, tt.expected, result)
|
|
})
|
|
}
|
|
}
|