Inline a Service jig helper into a test

jig.GetEndpointNodesWithIP was only used by one test, and that test
didn't even want the data in the form jig.GetEndpointNodesWithIP
provided it in. So just inline the code and generate the data
correctly the first time, and remove GetEndpointNodesWithIP (along
with GetEndpointNodes, which was already unused).
This commit is contained in:
Dan Winship
2026-02-19 11:45:21 -05:00
parent dfbe79674a
commit 6302e3a94f
2 changed files with 6 additions and 25 deletions

View File

@@ -361,26 +361,6 @@ func (j *TestJig) CreateLoadBalancerService(ctx context.Context, timeout time.Du
return j.WaitForLoadBalancer(ctx, timeout)
}
// GetEndpointNodes returns a map of nodenames:external-ip on which the
// endpoints of the Service are running.
func (j *TestJig) GetEndpointNodes(ctx context.Context) (map[string][]string, error) {
return j.GetEndpointNodesWithIP(ctx, v1.NodeExternalIP)
}
// GetEndpointNodesWithIP returns a map of nodenames:<ip of given type> on which the
// endpoints of the Service are running.
func (j *TestJig) GetEndpointNodesWithIP(ctx context.Context, addressType v1.NodeAddressType) (map[string][]string, error) {
nodes, err := j.ListNodesWithEndpoint(ctx)
if err != nil {
return nil, err
}
nodeMap := map[string][]string{}
for _, node := range nodes {
nodeMap[node.Name] = e2enode.GetAddresses(&node, addressType)
}
return nodeMap, nil
}
// ListNodesWithEndpoint returns a list of nodes on which the
// endpoints of the given Service are running.
func (j *TestJig) ListNodesWithEndpoint(ctx context.Context) ([]v1.Node, error) {

View File

@@ -698,16 +698,17 @@ func waitForAPIServerUp(ctx context.Context, c clientset.Interface) error {
// getEndpointNodesWithInternalIP returns a map of nodenames:internal-ip on which the
// endpoints of the Service are running.
func getEndpointNodesWithInternalIP(ctx context.Context, jig *e2eservice.TestJig) (map[string]string, error) {
nodesWithIPs, err := jig.GetEndpointNodesWithIP(ctx, v1.NodeInternalIP)
nodes, err := jig.ListNodesWithEndpoint(ctx)
if err != nil {
return nil, err
}
endpointsNodeMap := make(map[string]string, len(nodesWithIPs))
for nodeName, internalIPs := range nodesWithIPs {
endpointsNodeMap := make(map[string]string, len(nodes))
for _, node := range nodes {
internalIPs := e2enode.GetAddresses(&node, v1.NodeInternalIP)
if len(internalIPs) < 1 {
return nil, fmt.Errorf("no internal ip found for node %s", nodeName)
return nil, fmt.Errorf("no internal ip found for node %s", node.Name)
}
endpointsNodeMap[nodeName] = internalIPs[0]
endpointsNodeMap[node.Name] = internalIPs[0]
}
return endpointsNodeMap, nil
}