Skip to content

Commit

Permalink
e2e: fix random conflict in parallel processes (#2410)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Mar 1, 2023
1 parent cedcbbc commit 8fbc5dd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/e2e/framework/util.go
Expand Up @@ -9,6 +9,8 @@ import (
"strings"
"time"

"github.com/onsi/ginkgo/v2"

"github.com/kubeovn/kube-ovn/pkg/util"
)

Expand All @@ -19,15 +21,16 @@ const (

// RandomSuffix provides a random sequence to append to resources.
func RandomSuffix() string {
return fmt.Sprintf("%04d", rand.Intn(10000))
return fmt.Sprintf("%d%04d", ginkgo.GinkgoParallelProcess(), rand.Intn(10000))
}

func RandomCIDR(family string) string {
fnIPv4 := func() string {
cidr := net.IPNet{
IP: net.ParseIP("10.99.0.0").To4(),
IP: net.ParseIP("10.0.0.0").To4(),
Mask: net.CIDRMask(24, 32),
}
cidr.IP[1] = 0xf0 | byte(ginkgo.GinkgoParallelProcess())
cidr.IP[2] = byte(rand.Intn(0xff + 1))
return cidr.String()
}
Expand All @@ -37,6 +40,7 @@ func RandomCIDR(family string) string {
IP: net.ParseIP("fc00:10:ff::").To16(),
Mask: net.CIDRMask(96, 128),
}
cidr.IP[9] = byte(ginkgo.GinkgoParallelProcess())
cidr.IP[10] = byte(rand.Intn(0xff + 1))
cidr.IP[11] = byte(rand.Intn(0xff + 1))
return cidr.String()
Expand Down

0 comments on commit 8fbc5dd

Please sign in to comment.