update TestOnlyLocalNodePorts to make sure only add local RS

This commit is contained in:
Hong Zhiguo 2018-07-12 11:29:23 +08:00
parent c6990f973f
commit 8bb6a5fa9c

View File

@ -1001,18 +1001,32 @@ func TestOnlyLocalNodePorts(t *testing.T) {
) )
epIP := "10.180.0.1" epIP := "10.180.0.1"
epIP1 := "10.180.1.1"
thisHostname := testHostname
otherHostname := "other-hostname"
makeEndpointsMap(fp, makeEndpointsMap(fp,
makeTestEndpoints(svcPortName.Namespace, svcPortName.Name, func(ept *api.Endpoints) { makeTestEndpoints(svcPortName.Namespace, svcPortName.Name, func(ept *api.Endpoints) {
ept.Subsets = []api.EndpointSubset{{ ept.Subsets = []api.EndpointSubset{
Addresses: []api.EndpointAddress{{ { // **local** endpoint address, should be added as RS
IP: epIP, Addresses: []api.EndpointAddress{{
NodeName: nil, IP: epIP,
}}, NodeName: &thisHostname,
Ports: []api.EndpointPort{{ }},
Name: svcPortName.Port, Ports: []api.EndpointPort{{
Port: int32(svcPort), Name: svcPortName.Port,
}}, Port: int32(svcPort),
}} }}},
{ // **remote** endpoint address, should not be added as RS
Addresses: []api.EndpointAddress{{
IP: epIP1,
NodeName: &otherHostname,
}},
Ports: []api.EndpointPort{{
Name: svcPortName.Port,
Port: int32(svcPort),
}},
}}
}), }),
) )