This is an automated email from the ASF dual-hosted git repository.
binbin pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 00492490 Replace the random char seed to global rand to avoid
collision (#1729)
00492490 is described below
commit 004924901369c6a6908ea2dd32af4741811ed912
Author: hulk <[email protected]>
AuthorDate: Sun Sep 3 17:15:48 2023 +0800
Replace the random char seed to global rand to avoid collision (#1729)
#1727 changed the random string causing namespaces test fails.
This fixes #1728
---
tests/gocase/util/random.go | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tests/gocase/util/random.go b/tests/gocase/util/random.go
index 098e9df3..15acc4b8 100644
--- a/tests/gocase/util/random.go
+++ b/tests/gocase/util/random.go
@@ -23,7 +23,6 @@ import (
"fmt"
"math/rand"
"strings"
- "time"
)
func RandPath[T any](f ...func() T) T {
@@ -58,7 +57,7 @@ const (
)
func RandString(min, max int, typ RandStringType) string {
- return RandStringWithSeed(min, max, typ, time.Now().UnixNano())
+ return RandStringWithSeed(min, max, typ, rand.Int63())
}
func RandStringWithSeed(min, max int, typ RandStringType, seed int64) string {
@@ -75,7 +74,7 @@ func RandStringWithSeed(min, max int, typ RandStringType,
seed int64) string {
var sb strings.Builder
for ; length > 0; length-- {
- s := fmt.Sprintf("%c",
minVal+int(r.Int31n(int32(maxVal-minVal+1))))
+ s := fmt.Sprintf("%c", minVal+r.Intn(maxVal-minVal+1))
sb.WriteString(s)
}
return sb.String()