Merge pull request #1387 from lucas-clemente/init-random-in-integrationtests

properly initialise the random number generator in the integration tests
This commit is contained in:
Marten Seemann
2018-06-05 12:33:41 +02:00
committed by GitHub
3 changed files with 9 additions and 6 deletions

View File

@@ -2,7 +2,7 @@ package gquic_test
import ( import (
"fmt" "fmt"
mrand "math/rand" "math/rand"
"path/filepath" "path/filepath"
"runtime" "runtime"
@@ -26,7 +26,7 @@ func TestIntegration(t *testing.T) {
} }
var _ = BeforeSuite(func() { var _ = BeforeSuite(func() {
mrand.Seed(GinkgoRandomSeed()) rand.Seed(GinkgoRandomSeed())
}) })
var _ = JustBeforeEach(func() { var _ = JustBeforeEach(func() {

View File

@@ -24,7 +24,6 @@ func getRandomDuration(min, max time.Duration) time.Duration {
} }
var _ = Describe("Random Duration Generator", func() { var _ = Describe("Random Duration Generator", func() {
rand.Seed(time.Now().UnixNano())
It("gets a random RTT", func() { It("gets a random RTT", func() {
var min time.Duration = time.Hour var min time.Duration = time.Hour
var max time.Duration var max time.Duration
@@ -54,7 +53,6 @@ var _ = Describe("Random RTT", func() {
var proxy *quicproxy.QuicProxy var proxy *quicproxy.QuicProxy
runRTTTest := func(minRtt, maxRtt time.Duration, version protocol.VersionNumber) { runRTTTest := func(minRtt, maxRtt time.Duration, version protocol.VersionNumber) {
rand.Seed(time.Now().UnixNano())
var err error var err error
proxy, err = quicproxy.NewQuicProxy("localhost:", version, &quicproxy.Opts{ proxy, err = quicproxy.NewQuicProxy("localhost:", version, &quicproxy.Opts{
RemoteAddr: "localhost:" + testserver.Port(), RemoteAddr: "localhost:" + testserver.Port(),

View File

@@ -1,15 +1,20 @@
package self_test package self_test
import ( import (
"math/rand"
"testing"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
_ "github.com/lucas-clemente/quic-go/integrationtests/tools/testlog" _ "github.com/lucas-clemente/quic-go/integrationtests/tools/testlog"
"testing"
) )
func TestSelf(t *testing.T) { func TestSelf(t *testing.T) {
RegisterFailHandler(Fail) RegisterFailHandler(Fail)
RunSpecs(t, "Self integration tests") RunSpecs(t, "Self integration tests")
} }
var _ = BeforeSuite(func() {
rand.Seed(GinkgoRandomSeed())
})