all: stop using math/rand.Seed
Fixes #16428. Signed-off-by: Jes Cok <xigua67damn@gmail.com>
This commit is contained in:
parent
cfbb60d8af
commit
52748f60f3
@ -18,7 +18,6 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestIntervalTreeInsert tests interval tree insertion.
|
// TestIntervalTreeInsert tests interval tree insertion.
|
||||||
@ -360,7 +359,6 @@ func TestIntervalTreeRandom(t *testing.T) {
|
|||||||
ivs := make(map[xy]struct{})
|
ivs := make(map[xy]struct{})
|
||||||
ivt := NewIntervalTree()
|
ivt := NewIntervalTree()
|
||||||
maxv := 128
|
maxv := 128
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
|
|
||||||
for i := rand.Intn(maxv) + 1; i != 0; i-- {
|
for i := rand.Intn(maxv) + 1; i != 0; i-- {
|
||||||
x, y := int64(rand.Intn(maxv)), int64(rand.Intn(maxv))
|
x, y := int64(rand.Intn(maxv)), int64(rand.Intn(maxv))
|
||||||
|
@ -806,7 +806,6 @@ func computeLatency(lat, rv time.Duration) time.Duration {
|
|||||||
rv = lat / 10
|
rv = lat / 10
|
||||||
}
|
}
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
mrand.Seed(int64(now.Nanosecond()))
|
|
||||||
sign := 1
|
sign := 1
|
||||||
if now.Second()%2 == 0 {
|
if now.Second()%2 == 0 {
|
||||||
sign = -1
|
sign = -1
|
||||||
|
@ -628,7 +628,6 @@ func testServerHTTP(t *testing.T, secure, delayTx bool) {
|
|||||||
|
|
||||||
func newUnixAddr() string {
|
func newUnixAddr() string {
|
||||||
now := time.Now().UnixNano()
|
now := time.Now().UnixNano()
|
||||||
rand.Seed(now)
|
|
||||||
addr := fmt.Sprintf("%X%X.unix-conn", now, rand.Intn(35000))
|
addr := fmt.Sprintf("%X%X.unix-conn", now, rand.Intn(35000))
|
||||||
os.RemoveAll(addr)
|
os.RemoveAll(addr)
|
||||||
return addr
|
return addr
|
||||||
|
@ -16,7 +16,6 @@ package stringutil
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// UniqueStrings returns a slice of randomly generated unique strings.
|
// UniqueStrings returns a slice of randomly generated unique strings.
|
||||||
@ -45,7 +44,6 @@ func RandomStrings(slen uint, n int) (ss []string) {
|
|||||||
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
|
|
||||||
func RandString(l uint) string {
|
func RandString(l uint) string {
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
s := make([]byte, l)
|
s := make([]byte, l)
|
||||||
for i := 0; i < int(l); i++ {
|
for i := 0; i < int(l); i++ {
|
||||||
s[i] = chars[rand.Intn(len(chars))]
|
s[i] = chars[rand.Intn(len(chars))]
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"expvar"
|
"expvar"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"math/rand"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -120,8 +119,6 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
|
|
||||||
expvar.Publish(
|
expvar.Publish(
|
||||||
"file_descriptor_limit",
|
"file_descriptor_limit",
|
||||||
expvar.Func(
|
expvar.Func(
|
||||||
|
@ -37,10 +37,6 @@ func BenchmarkLessorRenew100000(b *testing.B) { benchmarkLessorRenew(100000, b)
|
|||||||
func BenchmarkLessorFindExpired10000(b *testing.B) { benchmarkLessorFindExpired(10000, b) }
|
func BenchmarkLessorFindExpired10000(b *testing.B) { benchmarkLessorFindExpired(10000, b) }
|
||||||
func BenchmarkLessorFindExpired100000(b *testing.B) { benchmarkLessorFindExpired(100000, b) }
|
func BenchmarkLessorFindExpired100000(b *testing.B) { benchmarkLessorFindExpired(100000, b) }
|
||||||
|
|
||||||
func init() {
|
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// minTTL keep lease will not auto expire in benchmark
|
// minTTL keep lease will not auto expire in benchmark
|
||||||
minTTL = 1000
|
minTTL = 1000
|
||||||
|
@ -130,7 +130,6 @@ func createSnapshotFile(t *testing.T, cfg *embed.Config, kvs []kv) (version stri
|
|||||||
func newEmbedURLs(n int) (urls []url.URL) {
|
func newEmbedURLs(n int) (urls []url.URL) {
|
||||||
urls = make([]url.URL, n)
|
urls = make([]url.URL, n)
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
rand.Seed(int64(time.Now().Nanosecond()))
|
|
||||||
u, _ := url.Parse(fmt.Sprintf("unix://localhost:%d", rand.Intn(45000)))
|
u, _ := url.Parse(fmt.Sprintf("unix://localhost:%d", rand.Intn(45000)))
|
||||||
urls[i] = *u
|
urls[i] = *u
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user