mirror of
https://github.com/containers/podman.git
synced 2025-10-18 11:42:55 +08:00
Fix rand.Seed() deprecation in golang 1.20
Ref: https://pkg.go.dev/math/rand@go1.20#Seed Note: For `runtime_test.go`, this test-case was never actually doing what appears as it's intent . Fixing it to work as intended would be require incredibly libpod-invasive changes. Do the least-worse thing and simply confirm that consecutive generated names are different. Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
@ -430,11 +430,11 @@ func GetPortLock(port string) *lockfile.LockFile {
|
||||
// collisions during parallel tests
|
||||
func GetRandomIPAddress() string {
|
||||
// To avoid IP collisions of initialize random seed for random IP addresses
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
rng := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
// Add GinkgoParallelProcess() on top of the IP address
|
||||
// in case of the same random seed
|
||||
ip3 := strconv.Itoa(rand.Intn(230) + GinkgoParallelProcess())
|
||||
ip4 := strconv.Itoa(rand.Intn(230) + GinkgoParallelProcess())
|
||||
ip3 := strconv.Itoa(rng.Intn(230) + GinkgoParallelProcess())
|
||||
ip4 := strconv.Itoa(rng.Intn(230) + GinkgoParallelProcess())
|
||||
return "10.88." + ip3 + "." + ip4
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user