Skip to content

Commit

Permalink
fix ipv6
Browse files Browse the repository at this point in the history
  • Loading branch information
bobz965 committed Jul 17, 2023
1 parent a85a537 commit 254abf9
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions test/e2e/kube-ovn/switch_lb_rule/switch_lb_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,24 @@ func generateSubnetName(name string) string {
return "subnet-" + name
}

func netcat(f *framework.Framework, clientPodName, endpoint string) string {
for i := 0; i < 3; i++ {
cmd := fmt.Sprintf("nc -vz %s", endpoint)
stdOutput, errOutput, err := framework.ExecShellInPod(context.Background(), f, clientPodName, cmd)
if err == nil {
framework.Logf("tcp netcat to svc %s successfully", endpoint)
framework.Logf("output:\n%s", stdOutput)
return ""
} else {
err = fmt.Errorf("failed to tcp netcat svc %s ", endpoint)
framework.Logf("output:\n%s", stdOutput)
framework.Logf("errOutput:\n%s", errOutput)
if i == 2 {
framework.Logf("exec %s failed err: %v, errOutput: %s, stdOutput: %s, retried %d times.", cmd, err, errOutput, stdOutput, i)
framework.ExpectNoError(errors.New("tcp netcat to svc %s failed"))
}
time.Sleep(6 * time.Second)
}
func netcat(f *framework.Framework, clientPodName, endpoint string) {
cmd := fmt.Sprintf("nc -nvz %s", endpoint)
if f.ClusterIpFamily == "IPv6" {
cmd = fmt.Sprintf("nc -6nvz %s", endpoint)
}
framework.Logf("testing %s", cmd)
stdOutput, errOutput, err := framework.ExecShellInPod(context.Background(), f, clientPodName, cmd)
if err == nil {
framework.Logf("tcp netcat to svc %s successfully", endpoint)
framework.Logf("output:\n%s", stdOutput)
} else {
err = fmt.Errorf("failed to tcp netcat svc %s ", endpoint)
framework.Logf("output:\n%s", stdOutput)
framework.Logf("errOutput:\n%s", errOutput)
framework.Logf("exec %s failed err: %v, errOutput: %s, stdOutput: %s, retried %d times.", cmd, err, errOutput, stdOutput)
framework.ExpectNoError(errors.New("tcp netcat to svc %s failed"), endpoint)
time.Sleep(600 * time.Second)
}
return ""
}

var _ = framework.Describe("[group:slr]", func() {
Expand All @@ -75,7 +73,7 @@ var _ = framework.Describe("[group:slr]", func() {
stsName, stsSvcName string
selSlrName, selSvcName string
epSlrName, epSvcName string
overlaySubnetV4Cidr, overlaySubnetV4Gw string
overlaySubnetV4Cidr string

frontPort, selSlrFrontPort, epSlrFrontPort, backendPort int32
)
Expand Down Expand Up @@ -107,9 +105,7 @@ var _ = framework.Describe("[group:slr]", func() {
selSlrFrontPort = 8091
epSlrFrontPort = 8092
backendPort = 80
overlaySubnetV4Cidr = "10.0.0.0/24"
overlaySubnetV4Gw = "10.0.0.1"

overlaySubnetV4Cidr = framework.RandomCIDR(f.ClusterIpFamily)
var (
clientPod *corev1.Pod
command []string
Expand All @@ -124,7 +120,7 @@ var _ = framework.Describe("[group:slr]", func() {
vpc := framework.MakeVpc(vpcName, "", false, false, []string{namespaceName})
_ = vpcClient.CreateSync(vpc)
ginkgo.By("Creating custom overlay subnet")
overlaySubnet := framework.MakeSubnet(subnetName, "", overlaySubnetV4Cidr, overlaySubnetV4Gw, vpcName, "", nil, nil, nil)
overlaySubnet := framework.MakeSubnet(subnetName, "", overlaySubnetV4Cidr, "", vpcName, "", nil, nil, nil)
_ = subnetClient.CreateSync(overlaySubnet)
labels = map[string]string{"app": "client"}
annotations := map[string]string{
Expand Down Expand Up @@ -169,6 +165,9 @@ var _ = framework.Describe("[group:slr]", func() {
sts := framework.MakeStatefulSet(stsName, stsSvcName, int32(replicas), labels, podImg)
sts.Spec.Template.Annotations = map[string]string{util.LogicalSwitchAnnotation: subnetName}
command := []string{"sh", "-c", "cd /tmp && python3 -m http.server 80"}
if f.ClusterIpFamily == "IPv6" {
command = []string{"sh", "-c", "cd /tmp && python3 -m http.server 80 --bind ::"}
}
sts.Spec.Template.Spec.Containers[0].Command = command
_ = stsClient.CreateSync(sts)

Expand Down

0 comments on commit 254abf9

Please sign in to comment.