From 00cd214afe46e79848e0f807bcdd19c20251cd2f Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Fri, 13 Feb 2015 23:21:16 -0800 Subject: [PATCH] integration-cli: seed rand in makeRandomString Current uses of `makeRandomString` is to create really long strings. In #10794, I used them to create nearly-unique unix paths for the daemon. Although collions are harmless and don't fail the tests, this prevents the same strings from being created consistently in every run by seeding rand.Random. Signed-off-by: Ahmet Alp Balkan --- integration-cli/utils.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration-cli/utils.go b/integration-cli/utils.go index f67ee78ca7..4bd212f63c 100644 --- a/integration-cli/utils.go +++ b/integration-cli/utils.go @@ -235,8 +235,9 @@ func makeRandomString(n int) string { // make a really long string letters := []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") b := make([]byte, n) + r := rand.New(rand.NewSource(time.Now().UTC().UnixNano())) for i := range b { - b[i] = letters[rand.Intn(len(letters))] + b[i] = letters[r.Intn(len(letters))] } return string(b) }