diff --git a/app/vmalert/manager_test.go b/app/vmalert/manager_test.go index b56dfb67c7..ba1f23dde9 100644 --- a/app/vmalert/manager_test.go +++ b/app/vmalert/manager_test.go @@ -64,17 +64,18 @@ func TestManagerUpdateConcurrent(t *testing.T) { wg := sync.WaitGroup{} wg.Add(workers) for i := 0; i < workers; i++ { - go func() { + go func(n int) { defer wg.Done() + r := rand.New(rand.NewSource(int64(n))) for i := 0; i < iterations; i++ { - rnd := rand.Intn(len(paths)) + rnd := r.Intn(len(paths)) cfg, err := config.Parse([]string{paths[rnd]}, notifier.ValidateTemplates, true) if err != nil { // update can fail and this is expected continue } _ = m.update(context.Background(), cfg, false) } - }() + }(i) } wg.Wait() } diff --git a/app/vmalert/notifier/config_watcher_test.go b/app/vmalert/notifier/config_watcher_test.go index 61550a6266..b51cd3bfa2 100644 --- a/app/vmalert/notifier/config_watcher_test.go +++ b/app/vmalert/notifier/config_watcher_test.go @@ -162,14 +162,15 @@ consul_sd_configs: wg := sync.WaitGroup{} wg.Add(workers) for i := 0; i < workers; i++ { - go func() { + go func(n int) { defer wg.Done() + r := rand.New(rand.NewSource(int64(n))) for i := 0; i < iterations; i++ { - rnd := rand.Intn(len(paths)) + rnd := r.Intn(len(paths)) _ = cw.reload(paths[rnd]) // update can fail and this is expected _ = cw.notifiers() } - }() + }(i) } wg.Wait() } diff --git a/app/vmalert/remotewrite/remotewrite_test.go b/app/vmalert/remotewrite/remotewrite_test.go index 668c422dfe..4ca9812a5d 100644 --- a/app/vmalert/remotewrite/remotewrite_test.go +++ b/app/vmalert/remotewrite/remotewrite_test.go @@ -27,12 +27,13 @@ func TestClient_Push(t *testing.T) { if err != nil { t.Fatalf("failed to create client: %s", err) } + r := rand.New(rand.NewSource(1)) const rowsN = 1e4 var sent int for i := 0; i < rowsN; i++ { s := prompbmarshal.TimeSeries{ Samples: []prompbmarshal.Sample{{ - Value: rand.Float64(), + Value: r.Float64(), Timestamp: time.Now().Unix(), }}, }