cleanup: delete rand.Seed(time.Now().UnixNano()) and using global number generator.

see https://tip.golang.org/doc/go1.20

Signed-off-by: Lan Liang <gcslyp@gmail.com>
This commit is contained in:
Lan Liang 2024-03-18 08:10:12 +00:00
parent 656cb1028e
commit dc992adad3
9 changed files with 0 additions and 24 deletions

View File

@ -34,7 +34,6 @@ import (
func TestIsUnixDomainSocketPipe(t *testing.T) {
generatePipeName := func(suffixLen int) string {
rand.Seed(time.Now().UnixNano())
letter := []rune("abcdef0123456789")
b := make([]rune, suffixLen)
for i := range b {

View File

@ -17,13 +17,10 @@ limitations under the License.
package cache
import (
"math/rand"
"os"
"testing"
"time"
)
func TestMain(m *testing.M) {
rand.Seed(time.Now().UnixNano())
os.Exit(m.Run())
}

View File

@ -17,13 +17,10 @@ limitations under the License.
package record
import (
"math/rand"
"os"
"testing"
"time"
)
func TestMain(m *testing.M) {
rand.Seed(time.Now().UnixNano())
os.Exit(m.Run())
}

View File

@ -17,13 +17,10 @@ limitations under the License.
package workqueue
import (
"math/rand"
"os"
"testing"
"time"
)
func TestMain(m *testing.M) {
rand.Seed(time.Now().UnixNano())
os.Exit(m.Run())
}

View File

@ -18,9 +18,7 @@ package cli
import (
"fmt"
"math/rand"
"os"
"time"
"github.com/spf13/cobra"
@ -86,7 +84,6 @@ func RunNoErrOutput(cmd *cobra.Command) error {
}
func run(cmd *cobra.Command) (logsInitialized bool, err error) {
rand.Seed(time.Now().UnixNano())
defer logs.FlushLogs()
cmd.SetGlobalNormalizationFunc(cliflag.WordSepNormalizeFunc)

View File

@ -19,11 +19,9 @@ package e2e
import (
"flag"
"fmt"
"math/rand"
"os"
"path/filepath"
"testing"
"time"
"github.com/onsi/ginkgo/v2"
"gopkg.in/yaml.v2"
@ -142,7 +140,6 @@ func TestMain(m *testing.M) {
testfiles.AddFileSource(testfiles.RootFileSource{Root: framework.TestContext.RepoRoot})
}
rand.Seed(time.Now().UnixNano())
os.Exit(m.Run())
}

View File

@ -28,7 +28,6 @@ import (
"flag"
"fmt"
"math/rand"
"os"
"os/exec"
"syscall"
@ -133,7 +132,6 @@ func TestMain(m *testing.M) {
// into TestContext.
// TODO(pohly): remove RegisterNodeFlags from test_context.go enable Viper config support here?
rand.Seed(time.Now().UnixNano())
pflag.Parse()
if pflag.CommandLine.NArg() > 0 {
fmt.Fprintf(os.Stderr, "unknown additional command line arguments: %s", pflag.CommandLine.Args())

View File

@ -20,13 +20,11 @@ import (
"flag"
"fmt"
"log"
"math/rand"
"os"
"os/exec"
"os/signal"
"strings"
"sync"
"time"
"k8s.io/klog/v2"
)
@ -77,7 +75,6 @@ func RunRemoteTestSuite(testSuite TestSuite) {
os.Exit(1)
}()
rand.Seed(time.Now().UnixNano())
if *buildOnly {
// Build the archive and exit
CreateTestArchive(testSuite,

View File

@ -17,14 +17,11 @@ 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)
}