@@ -24,15 +24,15 @@ import (
2424
2525 pb "github.com/prometheus/alertmanager/nflog/nflogpb"
2626
27- "github.com/benbjohnson/clock "
27+ "github.com/coder/quartz "
2828 "github.com/prometheus/client_golang/prometheus"
2929 "github.com/prometheus/client_golang/prometheus/testutil"
3030 "github.com/stretchr/testify/require"
3131 "go.uber.org/atomic"
3232)
3333
3434func TestLogGC (t * testing.T ) {
35- mockClock := clock .NewMock ()
35+ mockClock := quartz .NewMock (t )
3636 now := mockClock .Now ()
3737 // We only care about key names and expiration timestamps.
3838 newEntry := func (ts time.Time ) * pb.MeshEntry {
@@ -62,7 +62,7 @@ func TestLogGC(t *testing.T) {
6262
6363func TestLogSnapshot (t * testing.T ) {
6464 // Check whether storing and loading the snapshot is symmetric.
65- mockClock := clock .NewMock ()
65+ mockClock := quartz .NewMock (t )
6666 now := mockClock .Now ().UTC ()
6767
6868 cases := []struct {
@@ -142,7 +142,7 @@ func TestWithMaintenance_SupportsCustomCallback(t *testing.T) {
142142 }
143143
144144 l , err := New (opts )
145- clock := clock .NewMock ()
145+ clock := quartz .NewMock (t )
146146 l .clock = clock
147147 require .NoError (t , err )
148148
@@ -160,12 +160,12 @@ func TestWithMaintenance_SupportsCustomCallback(t *testing.T) {
160160 gosched ()
161161
162162 // Before the first tick, no maintenance executed.
163- clock .Add (99 * time .Millisecond )
163+ clock .Advance (99 * time .Millisecond )
164164 require .EqualValues (t , 0 , calls .Load ())
165165
166166 // Tick once.
167- clock .Add (1 * time .Millisecond )
168- require .EqualValues (t , 1 , calls .Load ())
167+ clock .Advance (1 * time .Millisecond )
168+ require .Eventually (t , func () bool { return calls .Load () == 1 }, 5 * time . Second , time . Second )
169169
170170 // Stop the maintenance loop. We should get exactly one more execution of the maintenance func.
171171 close (stopc )
@@ -212,7 +212,7 @@ func TestReplaceFile(t *testing.T) {
212212}
213213
214214func TestStateMerge (t * testing.T ) {
215- mockClock := clock .NewMock ()
215+ mockClock := quartz .NewMock (t )
216216 now := mockClock .Now ()
217217
218218 // We only care about key names and timestamps for the
@@ -274,7 +274,7 @@ func TestStateMerge(t *testing.T) {
274274
275275func TestStateDataCoding (t * testing.T ) {
276276 // Check whether encoding and decoding the data is symmetric.
277- mockClock := clock .NewMock ()
277+ mockClock := quartz .NewMock (t )
278278 now := mockClock .Now ().UTC ()
279279
280280 cases := []struct {
0 commit comments