diff --git a/silence/silence.go b/silence/silence.go index 37f2a634..6acf6268 100644 --- a/silence/silence.go +++ b/silence/silence.go @@ -354,10 +354,6 @@ func (s *Silences) nowUTC() time.Time { return s.clock.Now().UTC() } -func (s *Silences) ticker(d time.Duration) *clock.Ticker { - return s.clock.Ticker(d) -} - // Maintenance garbage collects the silence state at the given interval. If the snapshot // file is set, a snapshot is written to it afterwards. // Terminates on receiving from stopc. diff --git a/silence/silence_test.go b/silence/silence_test.go index 4f32816f..dd519bd2 100644 --- a/silence/silence_test.go +++ b/silence/silence_test.go @@ -20,7 +20,6 @@ import ( "os" "runtime" "sort" - "sync/atomic" "testing" "time" @@ -30,6 +29,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" "github.com/stretchr/testify/require" + "go.uber.org/atomic" pb "github.com/prometheus/alertmanager/silence/silencepb" "github.com/prometheus/alertmanager/types" @@ -211,9 +211,9 @@ func TestSilences_Maintenance_SupportsCustomCallback(t *testing.T) { s := &Silences{st: state{}, logger: log.NewNopLogger(), clock: clock, metrics: newMetrics(nil, nil)} stopc := make(chan struct{}) - var calls int32 = 0 + calls := atomic.NewInt32(0) go s.Maintenance(100*time.Millisecond, f.Name(), stopc, func() (int64, error) { - atomic.AddInt32(&calls, 1) + calls.Add(1) return 0, nil }) runtime.Gosched() @@ -224,7 +224,7 @@ func TestSilences_Maintenance_SupportsCustomCallback(t *testing.T) { close(stopc) require.Eventually(t, func() bool { - return atomic.LoadInt32(&calls) == 2 + return calls.Load() == 2 }, 1*time.Millisecond, 50*time.Microsecond) }