From f5c2f519649e0f6fd34277001bcad42f7c2c4c72 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Fri, 11 Oct 2019 20:17:12 +0000 Subject: [PATCH] Use a different seed for random numbers each run Without this, each run gets the same random numbers so all nodes are racing to remove the deleted node. --- prog/kube-utils/main.go | 1 + prog/kube-utils/peerlist_test.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/prog/kube-utils/main.go b/prog/kube-utils/main.go index 0743d360..c81156e6 100644 --- a/prog/kube-utils/main.go +++ b/prog/kube-utils/main.go @@ -354,6 +354,7 @@ func main() { ch := make(chan os.Signal) signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) stopCh := make(chan struct{}) + rand.Seed(time.Now().UnixNano()) registerForNodeUpdates(c, stopCh, nodeName, peerName) <-ch close(stopCh) diff --git a/prog/kube-utils/peerlist_test.go b/prog/kube-utils/peerlist_test.go index 093c575b..c5e47fee 100644 --- a/prog/kube-utils/peerlist_test.go +++ b/prog/kube-utils/peerlist_test.go @@ -5,6 +5,7 @@ import ( "math/rand" "sync" "testing" + "time" "github.com/stretchr/testify/require" ) @@ -71,6 +72,7 @@ func doConcurrentIterations(iterations, concurrency int, f func(int)) { } func TestPeerListFuzz(t *testing.T) { + rand.Seed(time.Now().UnixNano()) const ( testIters = 1000 maxNodes = 100