mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 04:52:08 +00:00
Merge pull request #123969 from liangyuanpeng/cleanup_rand
cleanup: delete rand.Seed(time.Now().UnixNano()) and using global number generator.
This commit is contained in:
commit
7f67cb5960
@ -34,7 +34,6 @@ import (
|
|||||||
|
|
||||||
func TestIsUnixDomainSocketPipe(t *testing.T) {
|
func TestIsUnixDomainSocketPipe(t *testing.T) {
|
||||||
generatePipeName := func(suffixLen int) string {
|
generatePipeName := func(suffixLen int) string {
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
letter := []rune("abcdef0123456789")
|
letter := []rune("abcdef0123456789")
|
||||||
b := make([]rune, suffixLen)
|
b := make([]rune, suffixLen)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
|
@ -17,13 +17,10 @@ limitations under the License.
|
|||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
os.Exit(m.Run())
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,10 @@ limitations under the License.
|
|||||||
package record
|
package record
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
os.Exit(m.Run())
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,10 @@ limitations under the License.
|
|||||||
package workqueue
|
package workqueue
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
os.Exit(m.Run())
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,7 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
@ -86,7 +84,6 @@ func RunNoErrOutput(cmd *cobra.Command) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func run(cmd *cobra.Command) (logsInitialized bool, err error) {
|
func run(cmd *cobra.Command) (logsInitialized bool, err error) {
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
defer logs.FlushLogs()
|
defer logs.FlushLogs()
|
||||||
|
|
||||||
cmd.SetGlobalNormalizationFunc(cliflag.WordSepNormalizeFunc)
|
cmd.SetGlobalNormalizationFunc(cliflag.WordSepNormalizeFunc)
|
||||||
|
@ -19,11 +19,9 @@ package e2e
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/onsi/ginkgo/v2"
|
"github.com/onsi/ginkgo/v2"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
@ -142,7 +140,6 @@ func TestMain(m *testing.M) {
|
|||||||
testfiles.AddFileSource(testfiles.RootFileSource{Root: framework.TestContext.RepoRoot})
|
testfiles.AddFileSource(testfiles.RootFileSource{Root: framework.TestContext.RepoRoot})
|
||||||
}
|
}
|
||||||
|
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
os.Exit(m.Run())
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"syscall"
|
"syscall"
|
||||||
@ -133,7 +132,6 @@ func TestMain(m *testing.M) {
|
|||||||
// into TestContext.
|
// into TestContext.
|
||||||
// TODO(pohly): remove RegisterNodeFlags from test_context.go enable Viper config support here?
|
// TODO(pohly): remove RegisterNodeFlags from test_context.go enable Viper config support here?
|
||||||
|
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
pflag.Parse()
|
pflag.Parse()
|
||||||
if pflag.CommandLine.NArg() > 0 {
|
if pflag.CommandLine.NArg() > 0 {
|
||||||
fmt.Fprintf(os.Stderr, "unknown additional command line arguments: %s", pflag.CommandLine.Args())
|
fmt.Fprintf(os.Stderr, "unknown additional command line arguments: %s", pflag.CommandLine.Args())
|
||||||
|
@ -20,13 +20,11 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
)
|
)
|
||||||
@ -77,7 +75,6 @@ func RunRemoteTestSuite(testSuite TestSuite) {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
if *buildOnly {
|
if *buildOnly {
|
||||||
// Build the archive and exit
|
// Build the archive and exit
|
||||||
CreateTestArchive(testSuite,
|
CreateTestArchive(testSuite,
|
||||||
|
@ -17,14 +17,11 @@ limitations under the License.
|
|||||||
package volume
|
package volume
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"k8s.io/kubernetes/test/integration/framework"
|
"k8s.io/kubernetes/test/integration/framework"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
framework.EtcdMain(m.Run)
|
framework.EtcdMain(m.Run)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user