mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
e2e loadbalancer test connectivity within cluster first
Change-Id: Iaced995e5e0433c9095cb522aa3e1de2105c931e
This commit is contained in:
parent
f77dc4e6be
commit
2b0372f873
@ -156,8 +156,8 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
|
|||||||
ns1 := f.Namespace.Name // LB1 in ns1 on TCP
|
ns1 := f.Namespace.Name // LB1 in ns1 on TCP
|
||||||
framework.Logf("namespace for TCP test: %s", ns1)
|
framework.Logf("namespace for TCP test: %s", ns1)
|
||||||
|
|
||||||
nodeIP, err := e2enode.PickIP(cs) // for later
|
nodeIP, err := getRandomNodeIP(cs)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err, "Could not obtain a valid Node IP")
|
||||||
|
|
||||||
ginkgo.By("creating a TCP service " + serviceName + " with type=ClusterIP in namespace " + ns1)
|
ginkgo.By("creating a TCP service " + serviceName + " with type=ClusterIP in namespace " + ns1)
|
||||||
tcpJig := e2eservice.NewTestJig(cs, ns1, serviceName)
|
tcpJig := e2eservice.NewTestJig(cs, ns1, serviceName)
|
||||||
@ -171,6 +171,10 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
|
|||||||
_, err = tcpJig.Run(nil)
|
_, err = tcpJig.Run(nil)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
|
execPod := e2epod.CreateExecPodOrFail(cs, ns1, "execpod", nil)
|
||||||
|
err = tcpJig.CheckServiceReachability(tcpService, execPod)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
// Change the services to NodePort.
|
// Change the services to NodePort.
|
||||||
|
|
||||||
ginkgo.By("changing the TCP service to type=NodePort")
|
ginkgo.By("changing the TCP service to type=NodePort")
|
||||||
@ -181,6 +185,9 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
|
|||||||
tcpNodePort := int(tcpService.Spec.Ports[0].NodePort)
|
tcpNodePort := int(tcpService.Spec.Ports[0].NodePort)
|
||||||
framework.Logf("TCP node port: %d", tcpNodePort)
|
framework.Logf("TCP node port: %d", tcpNodePort)
|
||||||
|
|
||||||
|
err = tcpJig.CheckServiceReachability(tcpService, execPod)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
ginkgo.By("hitting the TCP service's NodePort")
|
ginkgo.By("hitting the TCP service's NodePort")
|
||||||
e2eservice.TestReachableHTTP(nodeIP, tcpNodePort, e2eservice.KubeProxyLagTimeout)
|
e2eservice.TestReachableHTTP(nodeIP, tcpNodePort, e2eservice.KubeProxyLagTimeout)
|
||||||
|
|
||||||
@ -251,6 +258,9 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = tcpJig.CheckServiceReachability(tcpService, execPod)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
ginkgo.By("hitting the TCP service's NodePort")
|
ginkgo.By("hitting the TCP service's NodePort")
|
||||||
e2eservice.TestReachableHTTP(nodeIP, tcpNodePort, e2eservice.KubeProxyLagTimeout)
|
e2eservice.TestReachableHTTP(nodeIP, tcpNodePort, e2eservice.KubeProxyLagTimeout)
|
||||||
|
|
||||||
@ -363,8 +373,8 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
|
|||||||
ns2 := f.Namespace.Name // LB1 in ns2 on TCP
|
ns2 := f.Namespace.Name // LB1 in ns2 on TCP
|
||||||
framework.Logf("namespace for TCP test: %s", ns2)
|
framework.Logf("namespace for TCP test: %s", ns2)
|
||||||
|
|
||||||
nodeIP, err := e2enode.PickIP(cs) // for later
|
nodeIP, err := getRandomNodeIP(cs)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err, "Could not obtain a valid Node IP")
|
||||||
|
|
||||||
ginkgo.By("creating a UDP service " + serviceName + " with type=ClusterIP in namespace " + ns2)
|
ginkgo.By("creating a UDP service " + serviceName + " with type=ClusterIP in namespace " + ns2)
|
||||||
udpJig := e2eservice.NewTestJig(cs, ns2, serviceName)
|
udpJig := e2eservice.NewTestJig(cs, ns2, serviceName)
|
||||||
@ -378,6 +388,10 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
|
|||||||
_, err = udpJig.Run(nil)
|
_, err = udpJig.Run(nil)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
|
execPod := e2epod.CreateExecPodOrFail(cs, ns2, "execpod", nil)
|
||||||
|
err = udpJig.CheckServiceReachability(udpService, execPod)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
// Change the services to NodePort.
|
// Change the services to NodePort.
|
||||||
|
|
||||||
ginkgo.By("changing the UDP service to type=NodePort")
|
ginkgo.By("changing the UDP service to type=NodePort")
|
||||||
@ -388,6 +402,9 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
|
|||||||
udpNodePort := int(udpService.Spec.Ports[0].NodePort)
|
udpNodePort := int(udpService.Spec.Ports[0].NodePort)
|
||||||
framework.Logf("UDP node port: %d", udpNodePort)
|
framework.Logf("UDP node port: %d", udpNodePort)
|
||||||
|
|
||||||
|
err = udpJig.CheckServiceReachability(udpService, execPod)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
ginkgo.By("hitting the UDP service's NodePort")
|
ginkgo.By("hitting the UDP service's NodePort")
|
||||||
testReachableUDP(nodeIP, udpNodePort, e2eservice.KubeProxyLagTimeout)
|
testReachableUDP(nodeIP, udpNodePort, e2eservice.KubeProxyLagTimeout)
|
||||||
|
|
||||||
@ -451,6 +468,9 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
|
|||||||
udpIngressIP = e2eservice.GetIngressPoint(&udpService.Status.LoadBalancer.Ingress[0])
|
udpIngressIP = e2eservice.GetIngressPoint(&udpService.Status.LoadBalancer.Ingress[0])
|
||||||
framework.Logf("UDP load balancer: %s", udpIngressIP)
|
framework.Logf("UDP load balancer: %s", udpIngressIP)
|
||||||
|
|
||||||
|
err = udpJig.CheckServiceReachability(udpService, execPod)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
ginkgo.By("hitting the UDP service's NodePort")
|
ginkgo.By("hitting the UDP service's NodePort")
|
||||||
testReachableUDP(nodeIP, udpNodePort, e2eservice.KubeProxyLagTimeout)
|
testReachableUDP(nodeIP, udpNodePort, e2eservice.KubeProxyLagTimeout)
|
||||||
|
|
||||||
@ -1919,3 +1939,28 @@ func testRollingUpdateLBConnectivityDisruption(f *framework.Framework, externalT
|
|||||||
// assert that the load balancer address is still reachable after the rolling updates are finished
|
// assert that the load balancer address is still reachable after the rolling updates are finished
|
||||||
e2eservice.TestReachableHTTP(lbNameOrAddress, svcPort, timeout)
|
e2eservice.TestReachableHTTP(lbNameOrAddress, svcPort, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getRandomNodeIP gets an IP address from a random worker node.
|
||||||
|
// These tests exercise traffic coming from outside the traffic,
|
||||||
|
// so it prefers ExternalIPs over InternalIPs.
|
||||||
|
func getRandomNodeIP(cs clientset.Interface) (string, error) {
|
||||||
|
family := v1.IPv4Protocol
|
||||||
|
if framework.TestContext.ClusterIsIPv6() {
|
||||||
|
family = v1.IPv6Protocol
|
||||||
|
}
|
||||||
|
|
||||||
|
node, err := e2enode.GetRandomReadySchedulableNode(cs)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
ips := e2enode.GetAddressesByTypeAndFamily(node, v1.NodeExternalIP, family)
|
||||||
|
if len(ips) > 0 {
|
||||||
|
return ips[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ips = e2enode.GetAddressesByTypeAndFamily(node, v1.NodeInternalIP, family)
|
||||||
|
if len(ips) > 0 {
|
||||||
|
return ips[0], nil
|
||||||
|
}
|
||||||
|
return "", fmt.Errorf("node %v does not contain any valid IP", node)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user