From 55bc668f8d8d21294dd2a2ec2b2e7eb514c56576 Mon Sep 17 00:00:00 2001 From: Mikhail Mazurskiy Date: Thu, 11 Oct 2018 21:57:43 +1100 Subject: [PATCH] Seed math/rand in TestMain before tests are executed --- test/e2e_node/e2e_node_suite_test.go | 2 +- test/integration/volume/main_test.go | 3 +++ test/integration/volume/persistent_volumes_test.go | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/e2e_node/e2e_node_suite_test.go b/test/e2e_node/e2e_node_suite_test.go index 7f58413ba5..3dfa15b0a8 100644 --- a/test/e2e_node/e2e_node_suite_test.go +++ b/test/e2e_node/e2e_node_suite_test.go @@ -74,6 +74,7 @@ func init() { } func TestMain(m *testing.M) { + rand.Seed(time.Now().UnixNano()) pflag.Parse() framework.AfterReadingAllFlags(&framework.TestContext) os.Exit(m.Run()) @@ -119,7 +120,6 @@ func TestE2eNode(t *testing.T) { return } // If run-services-mode is not specified, run test. - rand.Seed(time.Now().UnixNano()) RegisterFailHandler(Fail) reporters := []Reporter{} reportDir := framework.TestContext.ReportDir diff --git a/test/integration/volume/main_test.go b/test/integration/volume/main_test.go index f3c945d05c..710261d23c 100644 --- a/test/integration/volume/main_test.go +++ b/test/integration/volume/main_test.go @@ -17,11 +17,14 @@ limitations under the License. package volume import ( + "math/rand" "testing" + "time" "k8s.io/kubernetes/test/integration/framework" ) func TestMain(m *testing.M) { + rand.Seed(time.Now().UnixNano()) framework.EtcdMain(m.Run) } diff --git a/test/integration/volume/persistent_volumes_test.go b/test/integration/volume/persistent_volumes_test.go index 189af2bb50..57a49c75fa 100644 --- a/test/integration/volume/persistent_volumes_test.go +++ b/test/integration/volume/persistent_volumes_test.go @@ -256,7 +256,6 @@ func TestPersistentVolumeBindRace(t *testing.T) { glog.V(2).Infof("TestPersistentVolumeBindRace claims created") // putting a bind manually on a pv should only match the claim it is bound to - rand.Seed(time.Now().Unix()) claim := claims[rand.Intn(maxClaims-1)] claimRef, err := ref.GetReference(legacyscheme.Scheme, claim) if err != nil {