Skip to content

Commit

Permalink
some fixes in e2e
Browse files Browse the repository at this point in the history
1. reduce possiblilty of the same name suffix;
2. fix e2e logging.
  • Loading branch information
zhangzujian committed Jul 30, 2023
1 parent 8821874 commit 0fbbc5b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/e2e/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (

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

func RandomCIDR(family string) string {
Expand Down
22 changes: 16 additions & 6 deletions test/e2e/kube-ovn/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,12 @@ var _ = framework.Describe("[group:service]", func() {
}
f.SkipVersionPriorTo(1, 11, "This case is support in v1.11")
ginkgo.By("Creating service " + serviceName)
port := 8000 + rand.Int31n(1000)
ports := []corev1.ServicePort{{
Name: "tcp",
Protocol: corev1.ProtocolTCP,
Port: 80,
TargetPort: intstr.FromInt(80),
Port: port,
TargetPort: intstr.FromInt(int(port)),
}}

selector := map[string]string{"app": "svc-dual"}
Expand All @@ -142,18 +143,27 @@ var _ = framework.Describe("[group:service]", func() {
v6ClusterIp := service.Spec.ClusterIPs[1]
originService := service.DeepCopy()

ginkgo.By("Creating pod " + podName)
podBackend := framework.MakePod(namespaceName, podName, selector, nil, framework.PauseImage, nil, nil)
_ = podClient.CreateSync(podBackend)

checkContainsClusterIP := func(v6ClusterIp string, isContain bool) {
execCmd := "kubectl ko nbctl --format=csv --data=bare --no-heading --columns=vips find Load_Balancer name=cluster-tcp-loadbalancer"
framework.WaitUntil(2*time.Second, 30*time.Second, func(_ context.Context) (bool, error) {
output, err := exec.Command("bash", "-c", execCmd).CombinedOutput()
framework.Logf("output is %s ", output)
framework.Logf("v6ClusterIp is %s ", v6ClusterIp)
framework.ExpectNoError(err)
if (isContain && strings.Contains(string(output), v6ClusterIp)) ||
(!isContain && !strings.Contains(string(output), v6ClusterIp)) {
framework.Logf("output is %q", output)
framework.Logf("v6ClusterIp is %q", v6ClusterIp)
vips := strings.Fields(string(output))
prefix := util.JoinHostPort(v6ClusterIp, port) + ":"
var found bool
for _, vip := range vips {
if strings.HasPrefix(vip, prefix) {
found = true
break
}
}
if found == isContain {
return true, nil
}
return false, nil
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/kube-ovn/subnet/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,6 @@ var _ = framework.Describe("[group:subnet]", func() {
util.LogicalSwitchAnnotation: subnetName,
}

podName = "pod-" + framework.RandomSuffix()
pod := framework.MakePod(namespaceName, podName, nil, annotations, framework.AgnhostImage, nil, nil)
_ = podClient.CreateSync(pod)

Expand All @@ -1099,7 +1098,7 @@ var _ = framework.Describe("[group:subnet]", func() {
{
Match: apiv1.NatOutGoingPolicyMatch{
SrcIPs: "1.1.1.1",
DstIPs: "169.254.0.0/16",
DstIPs: "199.255.0.0/16",
},
Action: util.NatPolicyRuleActionNat,
},
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/kube-ovn/underlay/underlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ var _ = framework.SerialDescribe("[group:underlay]", func() {
}

itFn = func(exchangeLinkName bool) {
ginkgo.By("Creating provider network")
ginkgo.By("Creating provider network " + providerNetworkName)
pn := makeProviderNetwork(providerNetworkName, exchangeLinkName, linkMap)
pn = providerNetworkClient.CreateSync(pn)

Expand Down Expand Up @@ -313,7 +313,7 @@ var _ = framework.SerialDescribe("[group:underlay]", func() {
ginkgo.By("Deleting vlan " + vlanName)
vlanClient.Delete(vlanName, metav1.DeleteOptions{})

ginkgo.By("Deleting provider network")
ginkgo.By("Deleting provider network " + providerNetworkName)
providerNetworkClient.DeleteSync(providerNetworkName)

ginkgo.By("Getting nodes")
Expand Down Expand Up @@ -345,7 +345,7 @@ var _ = framework.SerialDescribe("[group:underlay]", func() {
})

framework.ConformanceIt("should keep pod mtu the same with node interface", func() {
ginkgo.By("Creating provider network")
ginkgo.By("Creating provider network " + providerNetworkName)
pn := makeProviderNetwork(providerNetworkName, false, linkMap)
_ = providerNetworkClient.CreateSync(pn)

Expand Down Expand Up @@ -406,7 +406,7 @@ var _ = framework.SerialDescribe("[group:underlay]", func() {
}
f.SkipVersionPriorTo(1, 9, "Address conflict detection was introduced in v1.9")

ginkgo.By("Creating provider network")
ginkgo.By("Creating provider network " + providerNetworkName)
pn := makeProviderNetwork(providerNetworkName, false, linkMap)
_ = providerNetworkClient.CreateSync(pn)

Expand Down Expand Up @@ -469,7 +469,7 @@ var _ = framework.SerialDescribe("[group:underlay]", func() {
framework.ConformanceIt("should support underlay to overlay subnet interconnection", func() {
f.SkipVersionPriorTo(1, 9, "This feature was introduced in v1.9")

ginkgo.By("Creating provider network")
ginkgo.By("Creating provider network " + providerNetworkName)
pn := makeProviderNetwork(providerNetworkName, false, linkMap)
_ = providerNetworkClient.CreateSync(pn)

Expand Down Expand Up @@ -782,7 +782,7 @@ func checkU2OItems(f *framework.Framework, subnet *apiv1.Subnet, underlayPod, ov
}
}

asName := strings.Replace(fmt.Sprintf("%s.u2o_exclude_ip.%s", subnet.Name, protocolStr), "-", ".", -1)
asName := strings.ReplaceAll(fmt.Sprintf(util.U2OExcludeIPAg, subnet.Name, protocolStr), "-", ".")
if !isU2OCustomVpc {
ginkgo.By(fmt.Sprintf("checking underlay subnet's policy1 route %s", protocolStr))
hitPolicyStr := fmt.Sprintf("%d %s.dst == %s && %s.dst != $%s allow", util.SubnetRouterPolicyPriority, protocolStr, cidr, protocolStr, asName)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/ovn-vpc-nat-gw/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ var _ = framework.Describe("[group:ovn-vpc-nat-gw]", func() {
}

itFn = func(exchangeLinkName bool) {
ginkgo.By("Creating provider network")
ginkgo.By("Creating provider network " + providerNetworkName)
pn := makeProviderNetwork(providerNetworkName, exchangeLinkName, linkMap)
pn = providerNetworkClient.CreateSync(pn)

Expand Down Expand Up @@ -293,7 +293,7 @@ var _ = framework.Describe("[group:ovn-vpc-nat-gw]", func() {
ginkgo.By("Deleting vlan " + vlanName)
vlanClient.Delete(vlanName, metav1.DeleteOptions{})

ginkgo.By("Deleting provider network")
ginkgo.By("Deleting provider network " + providerNetworkName)
providerNetworkClient.DeleteSync(providerNetworkName)

ginkgo.By("Getting nodes")
Expand Down

0 comments on commit 0fbbc5b

Please sign in to comment.