mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
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"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TestIntervalTreeInsert tests interval tree insertion.
|
||||
@ -360,7 +359,6 @@ func TestIntervalTreeRandom(t *testing.T) {
|
||||
ivs := make(map[xy]struct{})
|
||||
ivt := NewIntervalTree()
|
||||
maxv := 128
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
for i := rand.Intn(maxv) + 1; i != 0; i-- {
|
||||
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
|
||||
}
|
||||
now := time.Now()
|
||||
mrand.Seed(int64(now.Nanosecond()))
|
||||
sign := 1
|
||||
if now.Second()%2 == 0 {
|
||||
sign = -1
|
||||
|
@ -628,7 +628,6 @@ func testServerHTTP(t *testing.T, secure, delayTx bool) {
|
||||
|
||||
func newUnixAddr() string {
|
||||
now := time.Now().UnixNano()
|
||||
rand.Seed(now)
|
||||
addr := fmt.Sprintf("%X%X.unix-conn", now, rand.Intn(35000))
|
||||
os.RemoveAll(addr)
|
||||
return addr
|
||||
|
@ -16,7 +16,6 @@ package stringutil
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UniqueStrings returns a slice of randomly generated unique strings.
|
||||
@ -45,7 +44,6 @@ func RandomStrings(slen uint, n int) (ss []string) {
|
||||
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
|
||||
func RandString(l uint) string {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
s := make([]byte, l)
|
||||
for i := 0; i < int(l); i++ {
|
||||
s[i] = chars[rand.Intn(len(chars))]
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
"expvar"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"path"
|
||||
"regexp"
|
||||
@ -120,8 +119,6 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
expvar.Publish(
|
||||
"file_descriptor_limit",
|
||||
expvar.Func(
|
||||
|
@ -37,10 +37,6 @@ func BenchmarkLessorRenew100000(b *testing.B) { benchmarkLessorRenew(100000, b)
|
||||
func BenchmarkLessorFindExpired10000(b *testing.B) { benchmarkLessorFindExpired(10000, b) }
|
||||
func BenchmarkLessorFindExpired100000(b *testing.B) { benchmarkLessorFindExpired(100000, b) }
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
}
|
||||
|
||||
const (
|
||||
// minTTL keep lease will not auto expire in benchmark
|
||||
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) {
|
||||
urls = make([]url.URL, n)
|
||||
for i := 0; i < n; i++ {
|
||||
rand.Seed(int64(time.Now().Nanosecond()))
|
||||
u, _ := url.Parse(fmt.Sprintf("unix://localhost:%d", rand.Intn(45000)))
|
||||
urls[i] = *u
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user