Merge pull request #132740 from adrianmoisey/e2e-test-single-ip

Loop over all IP address from each node in e2e test
This commit is contained in:
Kubernetes Prow Robot
2025-07-09 05:05:27 -07:00
committed by GitHub

View File

@@ -1103,7 +1103,20 @@ var _ = common.SIGDescribe("LoadBalancers ExternalTrafficPolicy: Local", feature
framework.Failf("Service HealthCheck NodePort was not allocated")
}
ips := e2enode.CollectAddresses(nodes, v1.NodeInternalIP)
// Collect InternalIP addresses for each node.
nodeInternalIPs := make(map[string]sets.Set[string], len(nodes.Items))
for i := range nodes.Items {
node := &nodes.Items[i]
internalIPs := sets.New[string]()
for _, addr := range node.Status.Addresses {
if addr.Type == v1.NodeInternalIP && addr.Address != "" {
internalIPs.Insert(addr.Address)
}
}
if internalIPs.Len() > 0 {
nodeInternalIPs[node.Name] = internalIPs
}
}
ingressIP := e2eservice.GetIngressPoint(&svc.Status.LoadBalancer.Ingress[0])
svcTCPPort := int(svc.Spec.Ports[0].Port)
@@ -1128,22 +1141,24 @@ var _ = common.SIGDescribe("LoadBalancers ExternalTrafficPolicy: Local", feature
// HealthCheck should pass only on the node where num(endpoints) > 0
// All other nodes should fail the healthcheck on the service healthCheckNodePort
for n, internalIP := range ips {
// Make sure the loadbalancer picked up the health check change.
// Confirm traffic can reach backend through LB before checking healthcheck nodeport.
e2eservice.TestReachableHTTP(ctx, ingressIP, svcTCPPort, e2eservice.KubeProxyLagTimeout)
expectedSuccess := nodes.Items[n].Name == endpointNodeName
port := strconv.Itoa(healthCheckNodePort)
ipPort := net.JoinHostPort(internalIP, port)
framework.Logf("Health checking %s, http://%s/healthz, expectedSuccess %v", nodes.Items[n].Name, ipPort, expectedSuccess)
err := testHTTPHealthCheckNodePortFromTestContainer(ctx,
config,
internalIP,
healthCheckNodePort,
e2eservice.KubeProxyEndpointLagTimeout,
expectedSuccess,
threshold)
framework.ExpectNoError(err)
for n, internalIPs := range nodeInternalIPs {
for ip := range internalIPs {
// Make sure the loadbalancer picked up the health check change.
// Confirm traffic can reach backend through LB before checking healthcheck nodeport.
e2eservice.TestReachableHTTP(ctx, ingressIP, svcTCPPort, e2eservice.KubeProxyLagTimeout)
expectedSuccess := n == endpointNodeName
port := strconv.Itoa(healthCheckNodePort)
ipPort := net.JoinHostPort(ip, port)
framework.Logf("Health checking %s, http://%s/healthz, expectedSuccess %v", n, ipPort, expectedSuccess)
err := testHTTPHealthCheckNodePortFromTestContainer(ctx,
config,
ip,
healthCheckNodePort,
e2eservice.KubeProxyEndpointLagTimeout,
expectedSuccess,
threshold)
framework.ExpectNoError(err)
}
}
err = f.ClientSet.AppsV1().Deployments(namespace).Delete(ctx, serviceName, metav1.DeleteOptions{})