mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Merge pull request #83208 from robscott/endpointslice-proxy-staleconn-perf
Only detecting stale connections for UDP ports in kube-proxy
This commit is contained in:
commit
35d68586db
@ -315,6 +315,7 @@ func (ect *EndpointChangeTracker) endpointsToEndpointsMap(endpoints *v1.Endpoint
|
|||||||
svcPortName := ServicePortName{
|
svcPortName := ServicePortName{
|
||||||
NamespacedName: types.NamespacedName{Namespace: endpoints.Namespace, Name: endpoints.Name},
|
NamespacedName: types.NamespacedName{Namespace: endpoints.Namespace, Name: endpoints.Name},
|
||||||
Port: port.Name,
|
Port: port.Name,
|
||||||
|
Protocol: port.Protocol,
|
||||||
}
|
}
|
||||||
for i := range ss.Addresses {
|
for i := range ss.Addresses {
|
||||||
addr := &ss.Addresses[i]
|
addr := &ss.Addresses[i]
|
||||||
@ -410,6 +411,10 @@ func (em EndpointsMap) getLocalEndpointIPs() map[types.NamespacedName]sets.Strin
|
|||||||
// is used to store stale udp service in order to clear udp conntrack later.
|
// is used to store stale udp service in order to clear udp conntrack later.
|
||||||
func detectStaleConnections(oldEndpointsMap, newEndpointsMap EndpointsMap, staleEndpoints *[]ServiceEndpoint, staleServiceNames *[]ServicePortName) {
|
func detectStaleConnections(oldEndpointsMap, newEndpointsMap EndpointsMap, staleEndpoints *[]ServiceEndpoint, staleServiceNames *[]ServicePortName) {
|
||||||
for svcPortName, epList := range oldEndpointsMap {
|
for svcPortName, epList := range oldEndpointsMap {
|
||||||
|
if svcPortName.Protocol != v1.ProtocolUDP {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
for _, ep := range epList {
|
for _, ep := range epList {
|
||||||
stale := true
|
stale := true
|
||||||
for i := range newEndpointsMap[svcPortName] {
|
for i := range newEndpointsMap[svcPortName] {
|
||||||
@ -426,6 +431,10 @@ func detectStaleConnections(oldEndpointsMap, newEndpointsMap EndpointsMap, stale
|
|||||||
}
|
}
|
||||||
|
|
||||||
for svcPortName, epList := range newEndpointsMap {
|
for svcPortName, epList := range newEndpointsMap {
|
||||||
|
if svcPortName.Protocol != v1.ProtocolUDP {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// For udp service, if its backend changes from 0 to non-0. There may exist a conntrack entry that could blackhole traffic to the service.
|
// For udp service, if its backend changes from 0 to non-0. There may exist a conntrack entry that could blackhole traffic to the service.
|
||||||
if len(epList) > 0 && len(oldEndpointsMap[svcPortName]) == 0 {
|
if len(epList) > 0 && len(oldEndpointsMap[svcPortName]) == 0 {
|
||||||
*staleServiceNames = append(*staleServiceNames, svcPortName)
|
*staleServiceNames = append(*staleServiceNames, svcPortName)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -145,8 +145,11 @@ func (cache *EndpointSliceCache) endpointInfoByServicePort(serviceNN types.Names
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
svcPortName := ServicePortName{NamespacedName: serviceNN}
|
svcPortName := ServicePortName{
|
||||||
svcPortName.Port = *port.Name
|
NamespacedName: serviceNN,
|
||||||
|
Port: *port.Name,
|
||||||
|
Protocol: *port.Protocol,
|
||||||
|
}
|
||||||
|
|
||||||
endpointInfoBySP[svcPortName] = cache.addEndpointsByIP(serviceNN, int(*port.Port), endpointInfoBySP[svcPortName], sliceInfo.Endpoints)
|
endpointInfoBySP[svcPortName] = cache.addEndpointsByIP(serviceNN, int(*port.Port), endpointInfoBySP[svcPortName], sliceInfo.Endpoints)
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"k8s.io/api/core/v1"
|
||||||
discovery "k8s.io/api/discovery/v1alpha1"
|
discovery "k8s.io/api/discovery/v1alpha1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
@ -41,12 +42,12 @@ func TestEndpointsMapFromESC(t *testing.T) {
|
|||||||
generateEndpointSlice("svc1", "ns1", 1, 3, 999, []string{"host1", "host2"}, []*int32{utilpointer.Int32Ptr(80), utilpointer.Int32Ptr(443)}),
|
generateEndpointSlice("svc1", "ns1", 1, 3, 999, []string{"host1", "host2"}, []*int32{utilpointer.Int32Ptr(80), utilpointer.Int32Ptr(443)}),
|
||||||
},
|
},
|
||||||
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "svc1", "port-0"): {
|
makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): {
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.1:80", IsLocal: false},
|
&BaseEndpointInfo{Endpoint: "10.0.1.1:80", IsLocal: false},
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.2:80", IsLocal: true},
|
&BaseEndpointInfo{Endpoint: "10.0.1.2:80", IsLocal: true},
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.3:80", IsLocal: false},
|
&BaseEndpointInfo{Endpoint: "10.0.1.3:80", IsLocal: false},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "svc1", "port-1"): {
|
makeServicePortName("ns1", "svc1", "port-1", v1.ProtocolTCP): {
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.1:443", IsLocal: false},
|
&BaseEndpointInfo{Endpoint: "10.0.1.1:443", IsLocal: false},
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.2:443", IsLocal: true},
|
&BaseEndpointInfo{Endpoint: "10.0.1.2:443", IsLocal: true},
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.3:443", IsLocal: false},
|
&BaseEndpointInfo{Endpoint: "10.0.1.3:443", IsLocal: false},
|
||||||
@ -60,7 +61,7 @@ func TestEndpointsMapFromESC(t *testing.T) {
|
|||||||
generateEndpointSlice("svc1", "ns1", 2, 3, 999, []string{}, []*int32{utilpointer.Int32Ptr(80)}),
|
generateEndpointSlice("svc1", "ns1", 2, 3, 999, []string{}, []*int32{utilpointer.Int32Ptr(80)}),
|
||||||
},
|
},
|
||||||
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "svc1", "port-0"): {
|
makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): {
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.1:80"},
|
&BaseEndpointInfo{Endpoint: "10.0.1.1:80"},
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.2:80"},
|
&BaseEndpointInfo{Endpoint: "10.0.1.2:80"},
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.3:80"},
|
&BaseEndpointInfo{Endpoint: "10.0.1.3:80"},
|
||||||
@ -79,7 +80,7 @@ func TestEndpointsMapFromESC(t *testing.T) {
|
|||||||
generateEndpointSlice("svc1", "ns1", 1, 4, 999, []string{}, []*int32{utilpointer.Int32Ptr(80)}),
|
generateEndpointSlice("svc1", "ns1", 1, 4, 999, []string{}, []*int32{utilpointer.Int32Ptr(80)}),
|
||||||
},
|
},
|
||||||
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "svc1", "port-0"): {
|
makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): {
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.1:80"},
|
&BaseEndpointInfo{Endpoint: "10.0.1.1:80"},
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.2:80"},
|
&BaseEndpointInfo{Endpoint: "10.0.1.2:80"},
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.3:80"},
|
&BaseEndpointInfo{Endpoint: "10.0.1.3:80"},
|
||||||
@ -98,7 +99,7 @@ func TestEndpointsMapFromESC(t *testing.T) {
|
|||||||
generateEndpointSlice("svc1", "ns1", 1, 10, 6, []string{}, []*int32{utilpointer.Int32Ptr(80)}),
|
generateEndpointSlice("svc1", "ns1", 1, 10, 6, []string{}, []*int32{utilpointer.Int32Ptr(80)}),
|
||||||
},
|
},
|
||||||
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "svc1", "port-0"): {
|
makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): {
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.10:80"},
|
&BaseEndpointInfo{Endpoint: "10.0.1.10:80"},
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.1:80"},
|
&BaseEndpointInfo{Endpoint: "10.0.1.1:80"},
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.2:80"},
|
&BaseEndpointInfo{Endpoint: "10.0.1.2:80"},
|
||||||
@ -127,7 +128,7 @@ func TestEndpointsMapFromESC(t *testing.T) {
|
|||||||
generateEndpointSlice("svc1", "ns2", 3, 3, 999, []string{}, []*int32{utilpointer.Int32Ptr(80)}),
|
generateEndpointSlice("svc1", "ns2", 3, 3, 999, []string{}, []*int32{utilpointer.Int32Ptr(80)}),
|
||||||
},
|
},
|
||||||
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "svc1", "port-0"): {
|
makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): {
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.1:80"},
|
&BaseEndpointInfo{Endpoint: "10.0.1.1:80"},
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.2:80"},
|
&BaseEndpointInfo{Endpoint: "10.0.1.2:80"},
|
||||||
&BaseEndpointInfo{Endpoint: "10.0.1.3:80"},
|
&BaseEndpointInfo{Endpoint: "10.0.1.3:80"},
|
||||||
@ -148,13 +149,15 @@ func TestEndpointsMapFromESC(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for name, tc := range testCases {
|
for name, tc := range testCases {
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
esCache := NewEndpointSliceCache(tc.hostname, nil, nil, nil)
|
esCache := NewEndpointSliceCache(tc.hostname, nil, nil, nil)
|
||||||
|
|
||||||
for _, endpointSlice := range tc.endpointSlices {
|
for _, endpointSlice := range tc.endpointSlices {
|
||||||
esCache.Update(endpointSlice)
|
esCache.Update(endpointSlice)
|
||||||
}
|
}
|
||||||
|
|
||||||
compareEndpointsMapsStr(t, name, esCache.EndpointsMap(tc.namespacedName), tc.expectedMap)
|
compareEndpointsMapsStr(t, esCache.EndpointsMap(tc.namespacedName), tc.expectedMap)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +175,7 @@ func TestEndpointInfoByServicePort(t *testing.T) {
|
|||||||
generateEndpointSlice("svc1", "ns1", 1, 3, 999, []string{"host1", "host2"}, []*int32{utilpointer.Int32Ptr(80)}),
|
generateEndpointSlice("svc1", "ns1", 1, 3, 999, []string{"host1", "host2"}, []*int32{utilpointer.Int32Ptr(80)}),
|
||||||
},
|
},
|
||||||
expectedMap: spToEndpointMap{
|
expectedMap: spToEndpointMap{
|
||||||
{NamespacedName: types.NamespacedName{Name: "svc1", Namespace: "ns1"}, Port: "port-0"}: {
|
makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): {
|
||||||
"10.0.1.1": &BaseEndpointInfo{Endpoint: "10.0.1.1:80", IsLocal: false},
|
"10.0.1.1": &BaseEndpointInfo{Endpoint: "10.0.1.1:80", IsLocal: false},
|
||||||
"10.0.1.2": &BaseEndpointInfo{Endpoint: "10.0.1.2:80", IsLocal: true},
|
"10.0.1.2": &BaseEndpointInfo{Endpoint: "10.0.1.2:80", IsLocal: true},
|
||||||
"10.0.1.3": &BaseEndpointInfo{Endpoint: "10.0.1.3:80", IsLocal: false},
|
"10.0.1.3": &BaseEndpointInfo{Endpoint: "10.0.1.3:80", IsLocal: false},
|
||||||
@ -198,6 +201,8 @@ func TestEndpointInfoByServicePort(t *testing.T) {
|
|||||||
|
|
||||||
func generateEndpointSliceWithOffset(serviceName, namespace string, sliceNum, offset, numEndpoints, unreadyMod int, hosts []string, portNums []*int32) *discovery.EndpointSlice {
|
func generateEndpointSliceWithOffset(serviceName, namespace string, sliceNum, offset, numEndpoints, unreadyMod int, hosts []string, portNums []*int32) *discovery.EndpointSlice {
|
||||||
ipAddressType := discovery.AddressTypeIP
|
ipAddressType := discovery.AddressTypeIP
|
||||||
|
tcpProtocol := v1.ProtocolTCP
|
||||||
|
|
||||||
endpointSlice := &discovery.EndpointSlice{
|
endpointSlice := &discovery.EndpointSlice{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: fmt.Sprintf("%s-%d", serviceName, sliceNum),
|
Name: fmt.Sprintf("%s-%d", serviceName, sliceNum),
|
||||||
@ -213,6 +218,7 @@ func generateEndpointSliceWithOffset(serviceName, namespace string, sliceNum, of
|
|||||||
endpointSlice.Ports = append(endpointSlice.Ports, discovery.EndpointPort{
|
endpointSlice.Ports = append(endpointSlice.Ports, discovery.EndpointPort{
|
||||||
Name: utilpointer.StringPtr(fmt.Sprintf("port-%d", i)),
|
Name: utilpointer.StringPtr(fmt.Sprintf("port-%d", i)),
|
||||||
Port: portNum,
|
Port: portNum,
|
||||||
|
Protocol: &tcpProtocol,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,6 +279,7 @@ func TestDeleteEndpointConnections(t *testing.T) {
|
|||||||
svc := proxy.ServicePortName{
|
svc := proxy.ServicePortName{
|
||||||
NamespacedName: types.NamespacedName{Namespace: "ns1", Name: tc.svcName},
|
NamespacedName: types.NamespacedName{Namespace: "ns1", Name: tc.svcName},
|
||||||
Port: "p80",
|
Port: "p80",
|
||||||
|
Protocol: tc.protocol,
|
||||||
}
|
}
|
||||||
input := []proxy.ServiceEndpoint{
|
input := []proxy.ServiceEndpoint{
|
||||||
{
|
{
|
||||||
@ -627,6 +628,7 @@ func TestClusterIPEndpointsJump(t *testing.T) {
|
|||||||
svcPortName := proxy.ServicePortName{
|
svcPortName := proxy.ServicePortName{
|
||||||
NamespacedName: makeNSN("ns1", "svc1"),
|
NamespacedName: makeNSN("ns1", "svc1"),
|
||||||
Port: "p80",
|
Port: "p80",
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}
|
}
|
||||||
|
|
||||||
makeServiceMap(fp,
|
makeServiceMap(fp,
|
||||||
@ -650,6 +652,7 @@ func TestClusterIPEndpointsJump(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: svcPortName.Port,
|
Name: svcPortName.Port,
|
||||||
Port: int32(svcPort),
|
Port: int32(svcPort),
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}),
|
}),
|
||||||
@ -686,6 +689,7 @@ func TestLoadBalancer(t *testing.T) {
|
|||||||
svcPortName := proxy.ServicePortName{
|
svcPortName := proxy.ServicePortName{
|
||||||
NamespacedName: makeNSN("ns1", "svc1"),
|
NamespacedName: makeNSN("ns1", "svc1"),
|
||||||
Port: "p80",
|
Port: "p80",
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}
|
}
|
||||||
|
|
||||||
makeServiceMap(fp,
|
makeServiceMap(fp,
|
||||||
@ -714,6 +718,7 @@ func TestLoadBalancer(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: svcPortName.Port,
|
Name: svcPortName.Port,
|
||||||
Port: int32(svcPort),
|
Port: int32(svcPort),
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}),
|
}),
|
||||||
@ -745,6 +750,7 @@ func TestNodePort(t *testing.T) {
|
|||||||
svcPortName := proxy.ServicePortName{
|
svcPortName := proxy.ServicePortName{
|
||||||
NamespacedName: makeNSN("ns1", "svc1"),
|
NamespacedName: makeNSN("ns1", "svc1"),
|
||||||
Port: "p80",
|
Port: "p80",
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}
|
}
|
||||||
|
|
||||||
makeServiceMap(fp,
|
makeServiceMap(fp,
|
||||||
@ -770,6 +776,7 @@ func TestNodePort(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: svcPortName.Port,
|
Name: svcPortName.Port,
|
||||||
Port: int32(svcPort),
|
Port: int32(svcPort),
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}),
|
}),
|
||||||
@ -890,6 +897,7 @@ func TestOnlyLocalLoadBalancing(t *testing.T) {
|
|||||||
svcPortName := proxy.ServicePortName{
|
svcPortName := proxy.ServicePortName{
|
||||||
NamespacedName: makeNSN("ns1", "svc1"),
|
NamespacedName: makeNSN("ns1", "svc1"),
|
||||||
Port: "p80",
|
Port: "p80",
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}
|
}
|
||||||
svcSessionAffinityTimeout := int32(10800)
|
svcSessionAffinityTimeout := int32(10800)
|
||||||
|
|
||||||
@ -931,6 +939,7 @@ func TestOnlyLocalLoadBalancing(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: svcPortName.Port,
|
Name: svcPortName.Port,
|
||||||
Port: int32(svcPort),
|
Port: int32(svcPort),
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}),
|
}),
|
||||||
@ -991,6 +1000,7 @@ func onlyLocalNodePorts(t *testing.T, fp *Proxier, ipt *iptablestest.FakeIPTable
|
|||||||
svcPortName := proxy.ServicePortName{
|
svcPortName := proxy.ServicePortName{
|
||||||
NamespacedName: makeNSN("ns1", "svc1"),
|
NamespacedName: makeNSN("ns1", "svc1"),
|
||||||
Port: "p80",
|
Port: "p80",
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}
|
}
|
||||||
|
|
||||||
makeServiceMap(fp,
|
makeServiceMap(fp,
|
||||||
@ -1024,6 +1034,7 @@ func onlyLocalNodePorts(t *testing.T, fp *Proxier, ipt *iptablestest.FakeIPTable
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: svcPortName.Port,
|
Name: svcPortName.Port,
|
||||||
Port: int32(svcPort),
|
Port: int32(svcPort),
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}),
|
}),
|
||||||
@ -1363,10 +1374,11 @@ func makeNSN(namespace, name string) types.NamespacedName {
|
|||||||
return types.NamespacedName{Namespace: namespace, Name: name}
|
return types.NamespacedName{Namespace: namespace, Name: name}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeServicePortName(ns, name, port string) proxy.ServicePortName {
|
func makeServicePortName(ns, name, port string, protocol v1.Protocol) proxy.ServicePortName {
|
||||||
return proxy.ServicePortName{
|
return proxy.ServicePortName{
|
||||||
NamespacedName: makeNSN(ns, name),
|
NamespacedName: makeNSN(ns, name),
|
||||||
Port: port,
|
Port: port,
|
||||||
|
Protocol: protocol,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1418,6 +1430,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
}},
|
}},
|
||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1429,6 +1442,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
}},
|
}},
|
||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1441,6 +1455,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1452,6 +1467,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1463,6 +1479,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11-2",
|
Name: "p11-2",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1474,6 +1491,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 22,
|
Port: 22,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1488,9 +1506,11 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}, {
|
}, {
|
||||||
Name: "p12",
|
Name: "p12",
|
||||||
Port: 12,
|
Port: 12,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1502,6 +1522,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -1510,6 +1531,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p12",
|
Name: "p12",
|
||||||
Port: 12,
|
Port: 12,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1521,6 +1543,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -1530,6 +1553,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p12",
|
Name: "p12",
|
||||||
Port: 12,
|
Port: 12,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1542,9 +1566,11 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}, {
|
}, {
|
||||||
Name: "p12",
|
Name: "p12",
|
||||||
Port: 12,
|
Port: 12,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -1553,6 +1579,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p13",
|
Name: "p13",
|
||||||
Port: 13,
|
Port: 13,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1567,9 +1594,11 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}, {
|
}, {
|
||||||
Name: "p12",
|
Name: "p12",
|
||||||
Port: 12,
|
Port: 12,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -1581,9 +1610,11 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p13",
|
Name: "p13",
|
||||||
Port: 13,
|
Port: 13,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}, {
|
}, {
|
||||||
Name: "p14",
|
Name: "p14",
|
||||||
Port: 14,
|
Port: 14,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1598,9 +1629,11 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p21",
|
Name: "p21",
|
||||||
Port: 21,
|
Port: 21,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}, {
|
}, {
|
||||||
Name: "p22",
|
Name: "p22",
|
||||||
Port: 22,
|
Port: 22,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1612,6 +1645,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1627,6 +1661,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p22",
|
Name: "p22",
|
||||||
Port: 22,
|
Port: 22,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -1636,6 +1671,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p23",
|
Name: "p23",
|
||||||
Port: 23,
|
Port: 23,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1651,6 +1687,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p44",
|
Name: "p44",
|
||||||
Port: 44,
|
Port: 44,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -1660,6 +1697,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p45",
|
Name: "p45",
|
||||||
Port: 45,
|
Port: 45,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1673,6 +1711,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -1681,9 +1720,11 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p12",
|
Name: "p12",
|
||||||
Port: 12,
|
Port: 12,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}, {
|
}, {
|
||||||
Name: "p122",
|
Name: "p122",
|
||||||
Port: 122,
|
Port: 122,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1695,6 +1736,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p33",
|
Name: "p33",
|
||||||
Port: 33,
|
Port: 33,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1707,6 +1749,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p44",
|
Name: "p44",
|
||||||
Port: 44,
|
Port: 44,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1738,12 +1781,12 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", unnamedPort),
|
makeTestEndpoints("ns1", "ep1", unnamedPort),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", ""): {
|
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", ""): {
|
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1759,12 +1802,12 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", namedPortLocal),
|
makeTestEndpoints("ns1", "ep1", namedPortLocal),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1782,18 +1825,18 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", multipleSubsets),
|
makeTestEndpoints("ns1", "ep1", multipleSubsets),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1809,24 +1852,24 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", multipleSubsetsMultiplePortsLocal),
|
makeTestEndpoints("ns1", "ep1", multipleSubsetsMultiplePortsLocal),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p13"): {
|
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:13", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:13", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p13"): {
|
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:13", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:13", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1846,53 +1889,53 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns2", "ep2", multipleSubsetsIPsPorts2),
|
makeTestEndpoints("ns2", "ep2", multipleSubsetsIPsPorts2),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:11", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:11", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p13"): {
|
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:13", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:13", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.4:13", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.4:13", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p14"): {
|
makeServicePortName("ns1", "ep1", "p14", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:14", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:14", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.4:14", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.4:14", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns2", "ep2", "p21"): {
|
makeServicePortName("ns2", "ep2", "p21", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.1:21", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.1:21", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:21", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:21", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns2", "ep2", "p22"): {
|
makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.1:22", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.1:22", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:22", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:22", IsLocal: true}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:11", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:11", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p13"): {
|
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:13", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:13", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.4:13", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.4:13", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p14"): {
|
makeServicePortName("ns1", "ep1", "p14", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:14", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:14", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.4:14", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.4:14", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns2", "ep2", "p21"): {
|
makeServicePortName("ns2", "ep2", "p21", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.1:21", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.1:21", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:21", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:21", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns2", "ep2", "p22"): {
|
makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.1:22", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.1:22", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:22", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:22", IsLocal: true}},
|
||||||
},
|
},
|
||||||
@ -1913,13 +1956,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{},
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", ""): {
|
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||||
makeServicePortName("ns1", "ep1", ""): true,
|
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): true,
|
||||||
},
|
},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{
|
expectedHealthchecks: map[types.NamespacedName]int{
|
||||||
makeNSN("ns1", "ep1"): 1,
|
makeNSN("ns1", "ep1"): 1,
|
||||||
@ -1933,14 +1976,14 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", ""): {
|
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{},
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||||
Endpoint: "1.1.1.1:11",
|
Endpoint: "1.1.1.1:11",
|
||||||
ServicePortName: makeServicePortName("ns1", "ep1", ""),
|
ServicePortName: makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP),
|
||||||
}},
|
}},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||||
@ -1953,23 +1996,23 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", namedPortsLocalNoLocal),
|
makeTestEndpoints("ns1", "ep1", namedPortsLocalNoLocal),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:11", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:11", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||||
makeServicePortName("ns1", "ep1", "p12"): true,
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): true,
|
||||||
},
|
},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{
|
expectedHealthchecks: map[types.NamespacedName]int{
|
||||||
makeNSN("ns1", "ep1"): 1,
|
makeNSN("ns1", "ep1"): 1,
|
||||||
@ -1983,29 +2026,29 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", namedPort),
|
makeTestEndpoints("ns1", "ep1", namedPort),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:11", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:11", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||||
Endpoint: "1.1.1.2:11",
|
Endpoint: "1.1.1.2:11",
|
||||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11"),
|
ServicePortName: makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP),
|
||||||
}, {
|
}, {
|
||||||
Endpoint: "1.1.1.1:12",
|
Endpoint: "1.1.1.1:12",
|
||||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12"),
|
ServicePortName: makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP),
|
||||||
}, {
|
}, {
|
||||||
Endpoint: "1.1.1.2:12",
|
Endpoint: "1.1.1.2:12",
|
||||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12"),
|
ServicePortName: makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP),
|
||||||
}},
|
}},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||||
@ -2018,21 +2061,21 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", multipleSubsetsWithLocal),
|
makeTestEndpoints("ns1", "ep1", multipleSubsetsWithLocal),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||||
makeServicePortName("ns1", "ep1", "p12"): true,
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): true,
|
||||||
},
|
},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{
|
expectedHealthchecks: map[types.NamespacedName]int{
|
||||||
makeNSN("ns1", "ep1"): 1,
|
makeNSN("ns1", "ep1"): 1,
|
||||||
@ -2046,21 +2089,21 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", namedPort),
|
makeTestEndpoints("ns1", "ep1", namedPort),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||||
Endpoint: "1.1.1.2:12",
|
Endpoint: "1.1.1.2:12",
|
||||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12"),
|
ServicePortName: makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP),
|
||||||
}},
|
}},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||||
@ -2073,21 +2116,21 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", namedPortRenamed),
|
makeTestEndpoints("ns1", "ep1", namedPortRenamed),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11-2"): {
|
makeServicePortName("ns1", "ep1", "p11-2", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||||
Endpoint: "1.1.1.1:11",
|
Endpoint: "1.1.1.1:11",
|
||||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11"),
|
ServicePortName: makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP),
|
||||||
}},
|
}},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||||
makeServicePortName("ns1", "ep1", "p11-2"): true,
|
makeServicePortName("ns1", "ep1", "p11-2", v1.ProtocolUDP): true,
|
||||||
},
|
},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||||
}, {
|
}, {
|
||||||
@ -2099,18 +2142,18 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", namedPortRenumbered),
|
makeTestEndpoints("ns1", "ep1", namedPortRenumbered),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:22", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:22", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||||
Endpoint: "1.1.1.1:11",
|
Endpoint: "1.1.1.1:11",
|
||||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11"),
|
ServicePortName: makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP),
|
||||||
}},
|
}},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||||
@ -2129,62 +2172,62 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns4", "ep4", complexAfter4),
|
makeTestEndpoints("ns4", "ep4", complexAfter4),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns2", "ep2", "p22"): {
|
makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:22", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:22", IsLocal: true}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.22:22", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.22:22", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns2", "ep2", "p23"): {
|
makeServicePortName("ns2", "ep2", "p23", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.3:23", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.3:23", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns4", "ep4", "p44"): {
|
makeServicePortName("ns4", "ep4", "p44", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "4.4.4.4:44", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "4.4.4.4:44", IsLocal: true}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "4.4.4.5:44", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "4.4.4.5:44", IsLocal: true}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns4", "ep4", "p45"): {
|
makeServicePortName("ns4", "ep4", "p45", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "4.4.4.6:45", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "4.4.4.6:45", IsLocal: true}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.11:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.11:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: false}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p122"): {
|
makeServicePortName("ns1", "ep1", "p122", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:122", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:122", IsLocal: false}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns3", "ep3", "p33"): {
|
makeServicePortName("ns3", "ep3", "p33", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "3.3.3.3:33", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "3.3.3.3:33", IsLocal: false}},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns4", "ep4", "p44"): {
|
makeServicePortName("ns4", "ep4", "p44", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "4.4.4.4:44", IsLocal: true}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "4.4.4.4:44", IsLocal: true}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||||
Endpoint: "2.2.2.2:22",
|
Endpoint: "2.2.2.2:22",
|
||||||
ServicePortName: makeServicePortName("ns2", "ep2", "p22"),
|
ServicePortName: makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP),
|
||||||
}, {
|
}, {
|
||||||
Endpoint: "2.2.2.22:22",
|
Endpoint: "2.2.2.22:22",
|
||||||
ServicePortName: makeServicePortName("ns2", "ep2", "p22"),
|
ServicePortName: makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP),
|
||||||
}, {
|
}, {
|
||||||
Endpoint: "2.2.2.3:23",
|
Endpoint: "2.2.2.3:23",
|
||||||
ServicePortName: makeServicePortName("ns2", "ep2", "p23"),
|
ServicePortName: makeServicePortName("ns2", "ep2", "p23", v1.ProtocolUDP),
|
||||||
}, {
|
}, {
|
||||||
Endpoint: "4.4.4.5:44",
|
Endpoint: "4.4.4.5:44",
|
||||||
ServicePortName: makeServicePortName("ns4", "ep4", "p44"),
|
ServicePortName: makeServicePortName("ns4", "ep4", "p44", v1.ProtocolUDP),
|
||||||
}, {
|
}, {
|
||||||
Endpoint: "4.4.4.6:45",
|
Endpoint: "4.4.4.6:45",
|
||||||
ServicePortName: makeServicePortName("ns4", "ep4", "p45"),
|
ServicePortName: makeServicePortName("ns4", "ep4", "p45", v1.ProtocolUDP),
|
||||||
}},
|
}},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||||
makeServicePortName("ns1", "ep1", "p12"): true,
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): true,
|
||||||
makeServicePortName("ns1", "ep1", "p122"): true,
|
makeServicePortName("ns1", "ep1", "p122", v1.ProtocolUDP): true,
|
||||||
makeServicePortName("ns3", "ep3", "p33"): true,
|
makeServicePortName("ns3", "ep3", "p33", v1.ProtocolUDP): true,
|
||||||
},
|
},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{
|
expectedHealthchecks: map[types.NamespacedName]int{
|
||||||
makeNSN("ns4", "ep4"): 1,
|
makeNSN("ns4", "ep4"): 1,
|
||||||
@ -2199,13 +2242,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{},
|
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{},
|
||||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||||
makeServicePortName("ns1", "ep1", ""): {
|
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||||
makeServicePortName("ns1", "ep1", ""): true,
|
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): true,
|
||||||
},
|
},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||||
},
|
},
|
||||||
@ -2285,29 +2328,6 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
// the shared EndpointChangeTracker and EndpointSliceCache. This test ensures that the
|
// the shared EndpointChangeTracker and EndpointSliceCache. This test ensures that the
|
||||||
// iptables proxier supports translating EndpointSlices to iptables output.
|
// iptables proxier supports translating EndpointSlices to iptables output.
|
||||||
func TestEndpointSliceE2E(t *testing.T) {
|
func TestEndpointSliceE2E(t *testing.T) {
|
||||||
expectedIPTablesWithoutSlice := `*filter
|
|
||||||
:KUBE-SERVICES - [0:0]
|
|
||||||
:KUBE-EXTERNAL-SERVICES - [0:0]
|
|
||||||
:KUBE-FORWARD - [0:0]
|
|
||||||
-A KUBE-SERVICES -m comment --comment "ns1/svc1: has no endpoints" -m -p -d 172.20.1.1/32 --dport 0 -j REJECT
|
|
||||||
-A KUBE-FORWARD -m conntrack --ctstate INVALID -j DROP
|
|
||||||
-A KUBE-FORWARD -m comment --comment "kubernetes forwarding rules" -m mark --mark -j ACCEPT
|
|
||||||
-A KUBE-FORWARD -s 10.0.0.0/24 -m comment --comment "kubernetes forwarding conntrack pod source rule" -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
|
|
||||||
-A KUBE-FORWARD -m comment --comment "kubernetes forwarding conntrack pod destination rule" -d 10.0.0.0/24 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
|
|
||||||
COMMIT
|
|
||||||
*nat
|
|
||||||
:KUBE-SERVICES - [0:0]
|
|
||||||
:KUBE-NODEPORTS - [0:0]
|
|
||||||
:KUBE-POSTROUTING - [0:0]
|
|
||||||
:KUBE-MARK-MASQ - [0:0]
|
|
||||||
:KUBE-SVC-3WUAALNGPYZZAWAD - [0:0]
|
|
||||||
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -m mark --mark -j MASQUERADE
|
|
||||||
-A KUBE-MARK-MASQ -j MARK --set-xmark
|
|
||||||
-X KUBE-SVC-3WUAALNGPYZZAWAD
|
|
||||||
-A KUBE-SERVICES -m comment --comment "kubernetes service nodeports; NOTE: this must be the last rule in this chain" -m addrtype --dst-type LOCAL -j KUBE-NODEPORTS
|
|
||||||
COMMIT
|
|
||||||
`
|
|
||||||
|
|
||||||
expectedIPTablesWithSlice := `*filter
|
expectedIPTablesWithSlice := `*filter
|
||||||
:KUBE-SERVICES - [0:0]
|
:KUBE-SERVICES - [0:0]
|
||||||
:KUBE-EXTERNAL-SERVICES - [0:0]
|
:KUBE-EXTERNAL-SERVICES - [0:0]
|
||||||
@ -2322,23 +2342,23 @@ COMMIT
|
|||||||
:KUBE-NODEPORTS - [0:0]
|
:KUBE-NODEPORTS - [0:0]
|
||||||
:KUBE-POSTROUTING - [0:0]
|
:KUBE-POSTROUTING - [0:0]
|
||||||
:KUBE-MARK-MASQ - [0:0]
|
:KUBE-MARK-MASQ - [0:0]
|
||||||
:KUBE-SVC-3WUAALNGPYZZAWAD - [0:0]
|
:KUBE-SVC-AHZNAGK3SCETOS2T - [0:0]
|
||||||
: - [0:0]
|
:KUBE-SEP-PXD6POUVGD2I37UY - [0:0]
|
||||||
: - [0:0]
|
:KUBE-SEP-SOKZUIT7SCEVIP33 - [0:0]
|
||||||
: - [0:0]
|
:KUBE-SEP-WVE3FAB34S7NZGDJ - [0:0]
|
||||||
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -m mark --mark -j MASQUERADE
|
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -m mark --mark -j MASQUERADE
|
||||||
-A KUBE-MARK-MASQ -j MARK --set-xmark
|
-A KUBE-MARK-MASQ -j MARK --set-xmark
|
||||||
-A KUBE-SERVICES -m comment --comment "ns1/svc1: cluster IP" -m -p -d 172.20.1.1/32 --dport 0 ! -s 10.0.0.0/24 -j KUBE-MARK-MASQ
|
-A KUBE-SERVICES -m comment --comment "ns1/svc1: cluster IP" -m tcp -p tcp -d 172.20.1.1/32 --dport 0 ! -s 10.0.0.0/24 -j KUBE-MARK-MASQ
|
||||||
-A KUBE-SERVICES -m comment --comment "ns1/svc1: cluster IP" -m -p -d 172.20.1.1/32 --dport 0 -j KUBE-SVC-3WUAALNGPYZZAWAD
|
-A KUBE-SERVICES -m comment --comment "ns1/svc1: cluster IP" -m tcp -p tcp -d 172.20.1.1/32 --dport 0 -j KUBE-SVC-AHZNAGK3SCETOS2T
|
||||||
-A KUBE-SVC-3WUAALNGPYZZAWAD -m statistic --mode random --probability 0.33333 -j
|
-A KUBE-SVC-AHZNAGK3SCETOS2T -m statistic --mode random --probability 0.33333 -j KUBE-SEP-PXD6POUVGD2I37UY
|
||||||
-A -s 10.0.1.1/32 -j KUBE-MARK-MASQ
|
-A KUBE-SEP-PXD6POUVGD2I37UY -s 10.0.1.1/32 -j KUBE-MARK-MASQ
|
||||||
-A -m -p -j DNAT --to-destination 10.0.1.1:80
|
-A KUBE-SEP-PXD6POUVGD2I37UY -m tcp -p tcp -j DNAT --to-destination 10.0.1.1:80
|
||||||
-A KUBE-SVC-3WUAALNGPYZZAWAD -m statistic --mode random --probability 0.50000 -j
|
-A KUBE-SVC-AHZNAGK3SCETOS2T -m statistic --mode random --probability 0.50000 -j KUBE-SEP-SOKZUIT7SCEVIP33
|
||||||
-A -s 10.0.1.2/32 -j KUBE-MARK-MASQ
|
-A KUBE-SEP-SOKZUIT7SCEVIP33 -s 10.0.1.2/32 -j KUBE-MARK-MASQ
|
||||||
-A -m -p -j DNAT --to-destination 10.0.1.2:80
|
-A KUBE-SEP-SOKZUIT7SCEVIP33 -m tcp -p tcp -j DNAT --to-destination 10.0.1.2:80
|
||||||
-A KUBE-SVC-3WUAALNGPYZZAWAD -j
|
-A KUBE-SVC-AHZNAGK3SCETOS2T -j KUBE-SEP-WVE3FAB34S7NZGDJ
|
||||||
-A -s 10.0.1.3/32 -j KUBE-MARK-MASQ
|
-A KUBE-SEP-WVE3FAB34S7NZGDJ -s 10.0.1.3/32 -j KUBE-MARK-MASQ
|
||||||
-A -m -p -j DNAT --to-destination 10.0.1.3:80
|
-A KUBE-SEP-WVE3FAB34S7NZGDJ -m tcp -p tcp -j DNAT --to-destination 10.0.1.3:80
|
||||||
-A KUBE-SERVICES -m comment --comment "kubernetes service nodeports; NOTE: this must be the last rule in this chain" -m addrtype --dst-type LOCAL -j KUBE-NODEPORTS
|
-A KUBE-SERVICES -m comment --comment "kubernetes service nodeports; NOTE: this must be the last rule in this chain" -m addrtype --dst-type LOCAL -j KUBE-NODEPORTS
|
||||||
COMMIT
|
COMMIT
|
||||||
`
|
`
|
||||||
@ -2357,11 +2377,12 @@ COMMIT
|
|||||||
Spec: v1.ServiceSpec{
|
Spec: v1.ServiceSpec{
|
||||||
ClusterIP: "172.20.1.1",
|
ClusterIP: "172.20.1.1",
|
||||||
Selector: map[string]string{"foo": "bar"},
|
Selector: map[string]string{"foo": "bar"},
|
||||||
Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt(80)}},
|
Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
ipAddressType := discovery.AddressTypeIP
|
ipAddressType := discovery.AddressTypeIP
|
||||||
|
tcpProtocol := v1.ProtocolTCP
|
||||||
endpointSlice := &discovery.EndpointSlice{
|
endpointSlice := &discovery.EndpointSlice{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: fmt.Sprintf("%s-1", serviceName),
|
Name: fmt.Sprintf("%s-1", serviceName),
|
||||||
@ -2371,6 +2392,7 @@ COMMIT
|
|||||||
Ports: []discovery.EndpointPort{{
|
Ports: []discovery.EndpointPort{{
|
||||||
Name: utilpointer.StringPtr(""),
|
Name: utilpointer.StringPtr(""),
|
||||||
Port: utilpointer.Int32Ptr(80),
|
Port: utilpointer.Int32Ptr(80),
|
||||||
|
Protocol: &tcpProtocol,
|
||||||
}},
|
}},
|
||||||
AddressType: &ipAddressType,
|
AddressType: &ipAddressType,
|
||||||
Endpoints: []discovery.Endpoint{{
|
Endpoints: []discovery.Endpoint{{
|
||||||
@ -2394,7 +2416,7 @@ COMMIT
|
|||||||
|
|
||||||
fp.OnEndpointSliceDelete(endpointSlice)
|
fp.OnEndpointSliceDelete(endpointSlice)
|
||||||
fp.syncProxyRules()
|
fp.syncProxyRules()
|
||||||
assert.Equal(t, expectedIPTablesWithoutSlice, fp.iptablesData.String())
|
assert.NotEqual(t, expectedIPTablesWithSlice, fp.iptablesData.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(thockin): add *more* tests for syncProxyRules() or break it down further and test the pieces.
|
// TODO(thockin): add *more* tests for syncProxyRules() or break it down further and test the pieces.
|
||||||
|
@ -460,6 +460,7 @@ func TestNodePort(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p80",
|
Name: "p80",
|
||||||
Port: int32(80),
|
Port: int32(80),
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}),
|
}),
|
||||||
@ -577,6 +578,7 @@ func TestNodePort(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p80",
|
Name: "p80",
|
||||||
Port: int32(80),
|
Port: int32(80),
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}),
|
}),
|
||||||
@ -728,6 +730,7 @@ func TestNodePort(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p80",
|
Name: "p80",
|
||||||
Port: int32(80),
|
Port: int32(80),
|
||||||
|
Protocol: v1.ProtocolSCTP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}),
|
}),
|
||||||
@ -1003,6 +1006,7 @@ func TestClusterIP(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p80",
|
Name: "p80",
|
||||||
Port: int32(80),
|
Port: int32(80),
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}),
|
}),
|
||||||
@ -1014,6 +1018,7 @@ func TestClusterIP(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p8080",
|
Name: "p8080",
|
||||||
Port: int32(8080),
|
Port: int32(8080),
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}),
|
}),
|
||||||
@ -1388,6 +1393,7 @@ func TestOnlyLocalNodePorts(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: svcPortName.Port,
|
Name: svcPortName.Port,
|
||||||
Port: int32(svcPort),
|
Port: int32(svcPort),
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}}},
|
}}},
|
||||||
{ // **remote** endpoint address, should not be added as RS
|
{ // **remote** endpoint address, should not be added as RS
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -1397,6 +1403,7 @@ func TestOnlyLocalNodePorts(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: svcPortName.Port,
|
Name: svcPortName.Port,
|
||||||
Port: int32(svcPort),
|
Port: int32(svcPort),
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}),
|
}),
|
||||||
@ -1485,6 +1492,7 @@ func TestLoadBalanceSourceRanges(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: svcPortName.Port,
|
Name: svcPortName.Port,
|
||||||
Port: int32(svcPort),
|
Port: int32(svcPort),
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}),
|
}),
|
||||||
@ -1653,6 +1661,7 @@ func TestOnlyLocalLoadBalancing(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: svcPortName.Port,
|
Name: svcPortName.Port,
|
||||||
Port: int32(svcPort),
|
Port: int32(svcPort),
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}}},
|
}}},
|
||||||
{ // **remote** endpoint address, should not be added as RS
|
{ // **remote** endpoint address, should not be added as RS
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -1662,6 +1671,7 @@ func TestOnlyLocalLoadBalancing(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: svcPortName.Port,
|
Name: svcPortName.Port,
|
||||||
Port: int32(svcPort),
|
Port: int32(svcPort),
|
||||||
|
Protocol: v1.ProtocolTCP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}),
|
}),
|
||||||
@ -2030,10 +2040,11 @@ func TestSessionAffinity(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeServicePortName(ns, name, port string) proxy.ServicePortName {
|
func makeServicePortName(ns, name, port string, protocol v1.Protocol) proxy.ServicePortName {
|
||||||
return proxy.ServicePortName{
|
return proxy.ServicePortName{
|
||||||
NamespacedName: makeNSN(ns, name),
|
NamespacedName: makeNSN(ns, name),
|
||||||
Port: port,
|
Port: port,
|
||||||
|
Protocol: protocol,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2050,6 +2061,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
}},
|
}},
|
||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2061,6 +2073,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
}},
|
}},
|
||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2073,6 +2086,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2084,6 +2098,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2095,6 +2110,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11-2",
|
Name: "p11-2",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2106,6 +2122,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 22,
|
Port: 22,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2120,9 +2137,11 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}, {
|
}, {
|
||||||
Name: "p12",
|
Name: "p12",
|
||||||
Port: 12,
|
Port: 12,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2134,6 +2153,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -2142,6 +2162,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p12",
|
Name: "p12",
|
||||||
Port: 12,
|
Port: 12,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2153,6 +2174,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -2162,6 +2184,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p12",
|
Name: "p12",
|
||||||
Port: 12,
|
Port: 12,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2174,9 +2197,11 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}, {
|
}, {
|
||||||
Name: "p12",
|
Name: "p12",
|
||||||
Port: 12,
|
Port: 12,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -2185,6 +2210,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p13",
|
Name: "p13",
|
||||||
Port: 13,
|
Port: 13,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2199,9 +2225,11 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}, {
|
}, {
|
||||||
Name: "p12",
|
Name: "p12",
|
||||||
Port: 12,
|
Port: 12,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -2213,9 +2241,11 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p13",
|
Name: "p13",
|
||||||
Port: 13,
|
Port: 13,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}, {
|
}, {
|
||||||
Name: "p14",
|
Name: "p14",
|
||||||
Port: 14,
|
Port: 14,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2230,9 +2260,11 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p21",
|
Name: "p21",
|
||||||
Port: 21,
|
Port: 21,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}, {
|
}, {
|
||||||
Name: "p22",
|
Name: "p22",
|
||||||
Port: 22,
|
Port: 22,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2244,6 +2276,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2259,6 +2292,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p22",
|
Name: "p22",
|
||||||
Port: 22,
|
Port: 22,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -2268,6 +2302,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p23",
|
Name: "p23",
|
||||||
Port: 23,
|
Port: 23,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2283,6 +2318,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p44",
|
Name: "p44",
|
||||||
Port: 44,
|
Port: 44,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -2292,6 +2328,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p45",
|
Name: "p45",
|
||||||
Port: 45,
|
Port: 45,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2305,6 +2342,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p11",
|
Name: "p11",
|
||||||
Port: 11,
|
Port: 11,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}, {
|
}, {
|
||||||
Addresses: []v1.EndpointAddress{{
|
Addresses: []v1.EndpointAddress{{
|
||||||
@ -2313,9 +2351,11 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p12",
|
Name: "p12",
|
||||||
Port: 12,
|
Port: 12,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}, {
|
}, {
|
||||||
Name: "p122",
|
Name: "p122",
|
||||||
Port: 122,
|
Port: 122,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2327,6 +2367,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p33",
|
Name: "p33",
|
||||||
Port: 33,
|
Port: 33,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2339,6 +2380,7 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
Ports: []v1.EndpointPort{{
|
Ports: []v1.EndpointPort{{
|
||||||
Name: "p44",
|
Name: "p44",
|
||||||
Port: 44,
|
Port: 44,
|
||||||
|
Protocol: v1.ProtocolUDP,
|
||||||
}},
|
}},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -2370,12 +2412,12 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", unnamedPort),
|
makeTestEndpoints("ns1", "ep1", unnamedPort),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", ""): {
|
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", ""): {
|
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2391,12 +2433,12 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", namedPortLocal),
|
makeTestEndpoints("ns1", "ep1", namedPortLocal),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2414,18 +2456,18 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", multipleSubsets),
|
makeTestEndpoints("ns1", "ep1", multipleSubsets),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.2:12", IsLocal: false},
|
{Endpoint: "1.1.1.2:12", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.2:12", IsLocal: false},
|
{Endpoint: "1.1.1.2:12", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2441,24 +2483,24 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", multipleSubsetsMultiplePortsLocal),
|
makeTestEndpoints("ns1", "ep1", multipleSubsetsMultiplePortsLocal),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:12", IsLocal: true},
|
{Endpoint: "1.1.1.1:12", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p13"): {
|
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.3:13", IsLocal: false},
|
{Endpoint: "1.1.1.3:13", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:12", IsLocal: true},
|
{Endpoint: "1.1.1.1:12", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p13"): {
|
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.3:13", IsLocal: false},
|
{Endpoint: "1.1.1.3:13", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2478,53 +2520,53 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns2", "ep2", multipleSubsetsIPsPorts2),
|
makeTestEndpoints("ns2", "ep2", multipleSubsetsIPsPorts2),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
{Endpoint: "1.1.1.2:11", IsLocal: true},
|
{Endpoint: "1.1.1.2:11", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:12", IsLocal: false},
|
{Endpoint: "1.1.1.1:12", IsLocal: false},
|
||||||
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p13"): {
|
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.3:13", IsLocal: false},
|
{Endpoint: "1.1.1.3:13", IsLocal: false},
|
||||||
{Endpoint: "1.1.1.4:13", IsLocal: true},
|
{Endpoint: "1.1.1.4:13", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p14"): {
|
makeServicePortName("ns1", "ep1", "p14", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.3:14", IsLocal: false},
|
{Endpoint: "1.1.1.3:14", IsLocal: false},
|
||||||
{Endpoint: "1.1.1.4:14", IsLocal: true},
|
{Endpoint: "1.1.1.4:14", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns2", "ep2", "p21"): {
|
makeServicePortName("ns2", "ep2", "p21", v1.ProtocolUDP): {
|
||||||
{Endpoint: "2.2.2.1:21", IsLocal: false},
|
{Endpoint: "2.2.2.1:21", IsLocal: false},
|
||||||
{Endpoint: "2.2.2.2:21", IsLocal: true},
|
{Endpoint: "2.2.2.2:21", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns2", "ep2", "p22"): {
|
makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): {
|
||||||
{Endpoint: "2.2.2.1:22", IsLocal: false},
|
{Endpoint: "2.2.2.1:22", IsLocal: false},
|
||||||
{Endpoint: "2.2.2.2:22", IsLocal: true},
|
{Endpoint: "2.2.2.2:22", IsLocal: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
{Endpoint: "1.1.1.2:11", IsLocal: true},
|
{Endpoint: "1.1.1.2:11", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:12", IsLocal: false},
|
{Endpoint: "1.1.1.1:12", IsLocal: false},
|
||||||
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p13"): {
|
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.3:13", IsLocal: false},
|
{Endpoint: "1.1.1.3:13", IsLocal: false},
|
||||||
{Endpoint: "1.1.1.4:13", IsLocal: true},
|
{Endpoint: "1.1.1.4:13", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p14"): {
|
makeServicePortName("ns1", "ep1", "p14", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.3:14", IsLocal: false},
|
{Endpoint: "1.1.1.3:14", IsLocal: false},
|
||||||
{Endpoint: "1.1.1.4:14", IsLocal: true},
|
{Endpoint: "1.1.1.4:14", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns2", "ep2", "p21"): {
|
makeServicePortName("ns2", "ep2", "p21", v1.ProtocolUDP): {
|
||||||
{Endpoint: "2.2.2.1:21", IsLocal: false},
|
{Endpoint: "2.2.2.1:21", IsLocal: false},
|
||||||
{Endpoint: "2.2.2.2:21", IsLocal: true},
|
{Endpoint: "2.2.2.2:21", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns2", "ep2", "p22"): {
|
makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): {
|
||||||
{Endpoint: "2.2.2.1:22", IsLocal: false},
|
{Endpoint: "2.2.2.1:22", IsLocal: false},
|
||||||
{Endpoint: "2.2.2.2:22", IsLocal: true},
|
{Endpoint: "2.2.2.2:22", IsLocal: true},
|
||||||
},
|
},
|
||||||
@ -2545,13 +2587,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{},
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", ""): {
|
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||||
makeServicePortName("ns1", "ep1", ""): true,
|
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): true,
|
||||||
},
|
},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{
|
expectedHealthchecks: map[types.NamespacedName]int{
|
||||||
makeNSN("ns1", "ep1"): 1,
|
makeNSN("ns1", "ep1"): 1,
|
||||||
@ -2565,14 +2607,14 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", ""): {
|
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{},
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||||
Endpoint: "1.1.1.1:11",
|
Endpoint: "1.1.1.1:11",
|
||||||
ServicePortName: makeServicePortName("ns1", "ep1", ""),
|
ServicePortName: makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP),
|
||||||
}},
|
}},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||||
@ -2585,23 +2627,23 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", namedPortsLocalNoLocal),
|
makeTestEndpoints("ns1", "ep1", namedPortsLocalNoLocal),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
{Endpoint: "1.1.1.2:11", IsLocal: true},
|
{Endpoint: "1.1.1.2:11", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:12", IsLocal: false},
|
{Endpoint: "1.1.1.1:12", IsLocal: false},
|
||||||
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||||
makeServicePortName("ns1", "ep1", "p12"): true,
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): true,
|
||||||
},
|
},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{
|
expectedHealthchecks: map[types.NamespacedName]int{
|
||||||
makeNSN("ns1", "ep1"): 1,
|
makeNSN("ns1", "ep1"): 1,
|
||||||
@ -2615,29 +2657,29 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", namedPort),
|
makeTestEndpoints("ns1", "ep1", namedPort),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
{Endpoint: "1.1.1.2:11", IsLocal: true},
|
{Endpoint: "1.1.1.2:11", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:12", IsLocal: false},
|
{Endpoint: "1.1.1.1:12", IsLocal: false},
|
||||||
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||||
Endpoint: "1.1.1.2:11",
|
Endpoint: "1.1.1.2:11",
|
||||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11"),
|
ServicePortName: makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP),
|
||||||
}, {
|
}, {
|
||||||
Endpoint: "1.1.1.1:12",
|
Endpoint: "1.1.1.1:12",
|
||||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12"),
|
ServicePortName: makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP),
|
||||||
}, {
|
}, {
|
||||||
Endpoint: "1.1.1.2:12",
|
Endpoint: "1.1.1.2:12",
|
||||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12"),
|
ServicePortName: makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP),
|
||||||
}},
|
}},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||||
@ -2650,21 +2692,21 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", multipleSubsetsWithLocal),
|
makeTestEndpoints("ns1", "ep1", multipleSubsetsWithLocal),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||||
makeServicePortName("ns1", "ep1", "p12"): true,
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): true,
|
||||||
},
|
},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{
|
expectedHealthchecks: map[types.NamespacedName]int{
|
||||||
makeNSN("ns1", "ep1"): 1,
|
makeNSN("ns1", "ep1"): 1,
|
||||||
@ -2678,21 +2720,21 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", namedPort),
|
makeTestEndpoints("ns1", "ep1", namedPort),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.2:12", IsLocal: false},
|
{Endpoint: "1.1.1.2:12", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||||
Endpoint: "1.1.1.2:12",
|
Endpoint: "1.1.1.2:12",
|
||||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12"),
|
ServicePortName: makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP),
|
||||||
}},
|
}},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||||
@ -2705,21 +2747,21 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", namedPortRenamed),
|
makeTestEndpoints("ns1", "ep1", namedPortRenamed),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11-2"): {
|
makeServicePortName("ns1", "ep1", "p11-2", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||||
Endpoint: "1.1.1.1:11",
|
Endpoint: "1.1.1.1:11",
|
||||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11"),
|
ServicePortName: makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP),
|
||||||
}},
|
}},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||||
makeServicePortName("ns1", "ep1", "p11-2"): true,
|
makeServicePortName("ns1", "ep1", "p11-2", v1.ProtocolUDP): true,
|
||||||
},
|
},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||||
}, {
|
}, {
|
||||||
@ -2731,18 +2773,18 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns1", "ep1", namedPortRenumbered),
|
makeTestEndpoints("ns1", "ep1", namedPortRenumbered),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:22", IsLocal: false},
|
{Endpoint: "1.1.1.1:22", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||||
Endpoint: "1.1.1.1:11",
|
Endpoint: "1.1.1.1:11",
|
||||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11"),
|
ServicePortName: makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP),
|
||||||
}},
|
}},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||||
@ -2761,62 +2803,62 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
makeTestEndpoints("ns4", "ep4", complexAfter4),
|
makeTestEndpoints("ns4", "ep4", complexAfter4),
|
||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns2", "ep2", "p22"): {
|
makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): {
|
||||||
{Endpoint: "2.2.2.2:22", IsLocal: true},
|
{Endpoint: "2.2.2.2:22", IsLocal: true},
|
||||||
{Endpoint: "2.2.2.22:22", IsLocal: true},
|
{Endpoint: "2.2.2.22:22", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns2", "ep2", "p23"): {
|
makeServicePortName("ns2", "ep2", "p23", v1.ProtocolUDP): {
|
||||||
{Endpoint: "2.2.2.3:23", IsLocal: true},
|
{Endpoint: "2.2.2.3:23", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns4", "ep4", "p44"): {
|
makeServicePortName("ns4", "ep4", "p44", v1.ProtocolUDP): {
|
||||||
{Endpoint: "4.4.4.4:44", IsLocal: true},
|
{Endpoint: "4.4.4.4:44", IsLocal: true},
|
||||||
{Endpoint: "4.4.4.5:44", IsLocal: true},
|
{Endpoint: "4.4.4.5:44", IsLocal: true},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns4", "ep4", "p45"): {
|
makeServicePortName("ns4", "ep4", "p45", v1.ProtocolUDP): {
|
||||||
{Endpoint: "4.4.4.6:45", IsLocal: true},
|
{Endpoint: "4.4.4.6:45", IsLocal: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", "p11"): {
|
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
{Endpoint: "1.1.1.11:11", IsLocal: false},
|
{Endpoint: "1.1.1.11:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p12"): {
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.2:12", IsLocal: false},
|
{Endpoint: "1.1.1.2:12", IsLocal: false},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns1", "ep1", "p122"): {
|
makeServicePortName("ns1", "ep1", "p122", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.2:122", IsLocal: false},
|
{Endpoint: "1.1.1.2:122", IsLocal: false},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns3", "ep3", "p33"): {
|
makeServicePortName("ns3", "ep3", "p33", v1.ProtocolUDP): {
|
||||||
{Endpoint: "3.3.3.3:33", IsLocal: false},
|
{Endpoint: "3.3.3.3:33", IsLocal: false},
|
||||||
},
|
},
|
||||||
makeServicePortName("ns4", "ep4", "p44"): {
|
makeServicePortName("ns4", "ep4", "p44", v1.ProtocolUDP): {
|
||||||
{Endpoint: "4.4.4.4:44", IsLocal: true},
|
{Endpoint: "4.4.4.4:44", IsLocal: true},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||||
Endpoint: "2.2.2.2:22",
|
Endpoint: "2.2.2.2:22",
|
||||||
ServicePortName: makeServicePortName("ns2", "ep2", "p22"),
|
ServicePortName: makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP),
|
||||||
}, {
|
}, {
|
||||||
Endpoint: "2.2.2.22:22",
|
Endpoint: "2.2.2.22:22",
|
||||||
ServicePortName: makeServicePortName("ns2", "ep2", "p22"),
|
ServicePortName: makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP),
|
||||||
}, {
|
}, {
|
||||||
Endpoint: "2.2.2.3:23",
|
Endpoint: "2.2.2.3:23",
|
||||||
ServicePortName: makeServicePortName("ns2", "ep2", "p23"),
|
ServicePortName: makeServicePortName("ns2", "ep2", "p23", v1.ProtocolUDP),
|
||||||
}, {
|
}, {
|
||||||
Endpoint: "4.4.4.5:44",
|
Endpoint: "4.4.4.5:44",
|
||||||
ServicePortName: makeServicePortName("ns4", "ep4", "p44"),
|
ServicePortName: makeServicePortName("ns4", "ep4", "p44", v1.ProtocolUDP),
|
||||||
}, {
|
}, {
|
||||||
Endpoint: "4.4.4.6:45",
|
Endpoint: "4.4.4.6:45",
|
||||||
ServicePortName: makeServicePortName("ns4", "ep4", "p45"),
|
ServicePortName: makeServicePortName("ns4", "ep4", "p45", v1.ProtocolUDP),
|
||||||
}},
|
}},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||||
makeServicePortName("ns1", "ep1", "p12"): true,
|
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): true,
|
||||||
makeServicePortName("ns1", "ep1", "p122"): true,
|
makeServicePortName("ns1", "ep1", "p122", v1.ProtocolUDP): true,
|
||||||
makeServicePortName("ns3", "ep3", "p33"): true,
|
makeServicePortName("ns3", "ep3", "p33", v1.ProtocolUDP): true,
|
||||||
},
|
},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{
|
expectedHealthchecks: map[types.NamespacedName]int{
|
||||||
makeNSN("ns4", "ep4"): 1,
|
makeNSN("ns4", "ep4"): 1,
|
||||||
@ -2831,13 +2873,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
|||||||
},
|
},
|
||||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{},
|
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{},
|
||||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||||
makeServicePortName("ns1", "ep1", ""): {
|
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||||
makeServicePortName("ns1", "ep1", ""): true,
|
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): true,
|
||||||
},
|
},
|
||||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||||
},
|
},
|
||||||
@ -3687,12 +3729,13 @@ func TestEndpointSliceE2E(t *testing.T) {
|
|||||||
Spec: v1.ServiceSpec{
|
Spec: v1.ServiceSpec{
|
||||||
ClusterIP: "172.20.1.1",
|
ClusterIP: "172.20.1.1",
|
||||||
Selector: map[string]string{"foo": "bar"},
|
Selector: map[string]string{"foo": "bar"},
|
||||||
Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt(80)}},
|
Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add initial endpoint slice
|
// Add initial endpoint slice
|
||||||
ipAddressType := discovery.AddressTypeIP
|
ipAddressType := discovery.AddressTypeIP
|
||||||
|
tcpProtocol := v1.ProtocolTCP
|
||||||
endpointSlice := &discovery.EndpointSlice{
|
endpointSlice := &discovery.EndpointSlice{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: fmt.Sprintf("%s-1", serviceName),
|
Name: fmt.Sprintf("%s-1", serviceName),
|
||||||
@ -3702,6 +3745,7 @@ func TestEndpointSliceE2E(t *testing.T) {
|
|||||||
Ports: []discovery.EndpointPort{{
|
Ports: []discovery.EndpointPort{{
|
||||||
Name: utilpointer.StringPtr(""),
|
Name: utilpointer.StringPtr(""),
|
||||||
Port: utilpointer.Int32Ptr(80),
|
Port: utilpointer.Int32Ptr(80),
|
||||||
|
Protocol: &tcpProtocol,
|
||||||
}},
|
}},
|
||||||
AddressType: &ipAddressType,
|
AddressType: &ipAddressType,
|
||||||
Endpoints: []discovery.Endpoint{{
|
Endpoints: []discovery.Endpoint{{
|
||||||
|
@ -299,7 +299,7 @@ func (sct *ServiceChangeTracker) serviceToServiceMap(service *v1.Service) Servic
|
|||||||
serviceMap := make(ServiceMap)
|
serviceMap := make(ServiceMap)
|
||||||
for i := range service.Spec.Ports {
|
for i := range service.Spec.Ports {
|
||||||
servicePort := &service.Spec.Ports[i]
|
servicePort := &service.Spec.Ports[i]
|
||||||
svcPortName := ServicePortName{NamespacedName: svcName, Port: servicePort.Name}
|
svcPortName := ServicePortName{NamespacedName: svcName, Port: servicePort.Name, Protocol: servicePort.Protocol}
|
||||||
baseSvcInfo := sct.newBaseServiceInfo(servicePort, service)
|
baseSvcInfo := sct.newBaseServiceInfo(servicePort, service)
|
||||||
if sct.makeServiceInfo != nil {
|
if sct.makeServiceInfo != nil {
|
||||||
serviceMap[svcPortName] = sct.makeServiceInfo(servicePort, service, baseSvcInfo)
|
serviceMap[svcPortName] = sct.makeServiceInfo(servicePort, service, baseSvcInfo)
|
||||||
|
@ -75,10 +75,11 @@ func makeNSN(namespace, name string) types.NamespacedName {
|
|||||||
return types.NamespacedName{Namespace: namespace, Name: name}
|
return types.NamespacedName{Namespace: namespace, Name: name}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeServicePortName(ns, name, port string) ServicePortName {
|
func makeServicePortName(ns, name, port string, protocol v1.Protocol) ServicePortName {
|
||||||
return ServicePortName{
|
return ServicePortName{
|
||||||
NamespacedName: makeNSN(ns, name),
|
NamespacedName: makeNSN(ns, name),
|
||||||
Port: port,
|
Port: port,
|
||||||
|
Protocol: protocol,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,8 +141,8 @@ func TestServiceToServiceMap(t *testing.T) {
|
|||||||
svc.Spec.Ports = addTestPort(svc.Spec.Ports, "p2", "UDP", 1235, 5321, 0)
|
svc.Spec.Ports = addTestPort(svc.Spec.Ports, "p2", "UDP", 1235, 5321, 0)
|
||||||
}),
|
}),
|
||||||
expected: map[ServicePortName]*BaseServiceInfo{
|
expected: map[ServicePortName]*BaseServiceInfo{
|
||||||
makeServicePortName("ns2", "cluster-ip", "p1"): makeTestServiceInfo("172.16.55.4", 1234, "UDP", 0),
|
makeServicePortName("ns2", "cluster-ip", "p1", v1.ProtocolUDP): makeTestServiceInfo("172.16.55.4", 1234, "UDP", 0),
|
||||||
makeServicePortName("ns2", "cluster-ip", "p2"): makeTestServiceInfo("172.16.55.4", 1235, "UDP", 0),
|
makeServicePortName("ns2", "cluster-ip", "p2", v1.ProtocolUDP): makeTestServiceInfo("172.16.55.4", 1235, "UDP", 0),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -153,8 +154,8 @@ func TestServiceToServiceMap(t *testing.T) {
|
|||||||
svc.Spec.Ports = addTestPort(svc.Spec.Ports, "port2", "TCP", 344, 677, 0)
|
svc.Spec.Ports = addTestPort(svc.Spec.Ports, "port2", "TCP", 344, 677, 0)
|
||||||
}),
|
}),
|
||||||
expected: map[ServicePortName]*BaseServiceInfo{
|
expected: map[ServicePortName]*BaseServiceInfo{
|
||||||
makeServicePortName("ns2", "node-port", "port1"): makeTestServiceInfo("172.16.55.10", 345, "UDP", 0),
|
makeServicePortName("ns2", "node-port", "port1", v1.ProtocolUDP): makeTestServiceInfo("172.16.55.10", 345, "UDP", 0),
|
||||||
makeServicePortName("ns2", "node-port", "port2"): makeTestServiceInfo("172.16.55.10", 344, "TCP", 0),
|
makeServicePortName("ns2", "node-port", "port2", v1.ProtocolTCP): makeTestServiceInfo("172.16.55.10", 344, "TCP", 0),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -172,8 +173,8 @@ func TestServiceToServiceMap(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
expected: map[ServicePortName]*BaseServiceInfo{
|
expected: map[ServicePortName]*BaseServiceInfo{
|
||||||
makeServicePortName("ns1", "load-balancer", "port3"): makeTestServiceInfo("172.16.55.11", 8675, "UDP", 0),
|
makeServicePortName("ns1", "load-balancer", "port3", v1.ProtocolUDP): makeTestServiceInfo("172.16.55.11", 8675, "UDP", 0),
|
||||||
makeServicePortName("ns1", "load-balancer", "port4"): makeTestServiceInfo("172.16.55.11", 8676, "UDP", 0),
|
makeServicePortName("ns1", "load-balancer", "port4", v1.ProtocolUDP): makeTestServiceInfo("172.16.55.11", 8676, "UDP", 0),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -193,8 +194,8 @@ func TestServiceToServiceMap(t *testing.T) {
|
|||||||
svc.Spec.HealthCheckNodePort = 345
|
svc.Spec.HealthCheckNodePort = 345
|
||||||
}),
|
}),
|
||||||
expected: map[ServicePortName]*BaseServiceInfo{
|
expected: map[ServicePortName]*BaseServiceInfo{
|
||||||
makeServicePortName("ns1", "only-local-load-balancer", "portx"): makeTestServiceInfo("172.16.55.12", 8677, "UDP", 345),
|
makeServicePortName("ns1", "only-local-load-balancer", "portx", v1.ProtocolUDP): makeTestServiceInfo("172.16.55.12", 8677, "UDP", 345),
|
||||||
makeServicePortName("ns1", "only-local-load-balancer", "porty"): makeTestServiceInfo("172.16.55.12", 8678, "UDP", 345),
|
makeServicePortName("ns1", "only-local-load-balancer", "porty", v1.ProtocolUDP): makeTestServiceInfo("172.16.55.12", 8678, "UDP", 345),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -268,7 +269,7 @@ func TestServiceToServiceMap(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: map[ServicePortName]*BaseServiceInfo{
|
expected: map[ServicePortName]*BaseServiceInfo{
|
||||||
makeServicePortName("test", "validIPv4", "testPort"): makeTestServiceInfo(testClusterIPv4, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
makeServicePortName("test", "validIPv4", "testPort", v1.ProtocolTCP): makeTestServiceInfo(testClusterIPv4, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
||||||
info.externalIPs = []string{testExternalIPv4}
|
info.externalIPs = []string{testExternalIPv4}
|
||||||
info.loadBalancerSourceRanges = []string{testSourceRangeIPv4}
|
info.loadBalancerSourceRanges = []string{testSourceRangeIPv4}
|
||||||
}),
|
}),
|
||||||
@ -296,7 +297,7 @@ func TestServiceToServiceMap(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: map[ServicePortName]*BaseServiceInfo{
|
expected: map[ServicePortName]*BaseServiceInfo{
|
||||||
makeServicePortName("test", "validIPv6", "testPort"): makeTestServiceInfo(testClusterIPv6, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
makeServicePortName("test", "validIPv6", "testPort", v1.ProtocolTCP): makeTestServiceInfo(testClusterIPv6, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
||||||
info.externalIPs = []string{testExternalIPv6}
|
info.externalIPs = []string{testExternalIPv6}
|
||||||
info.loadBalancerSourceRanges = []string{testSourceRangeIPv6}
|
info.loadBalancerSourceRanges = []string{testSourceRangeIPv6}
|
||||||
}),
|
}),
|
||||||
@ -324,7 +325,7 @@ func TestServiceToServiceMap(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: map[ServicePortName]*BaseServiceInfo{
|
expected: map[ServicePortName]*BaseServiceInfo{
|
||||||
makeServicePortName("test", "filterIPv6InIPV4Mode", "testPort"): makeTestServiceInfo(testClusterIPv4, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
makeServicePortName("test", "filterIPv6InIPV4Mode", "testPort", v1.ProtocolTCP): makeTestServiceInfo(testClusterIPv4, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
||||||
info.externalIPs = []string{testExternalIPv4}
|
info.externalIPs = []string{testExternalIPv4}
|
||||||
info.loadBalancerSourceRanges = []string{testSourceRangeIPv4}
|
info.loadBalancerSourceRanges = []string{testSourceRangeIPv4}
|
||||||
}),
|
}),
|
||||||
@ -352,7 +353,7 @@ func TestServiceToServiceMap(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: map[ServicePortName]*BaseServiceInfo{
|
expected: map[ServicePortName]*BaseServiceInfo{
|
||||||
makeServicePortName("test", "filterIPv4InIPV6Mode", "testPort"): makeTestServiceInfo(testClusterIPv6, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
makeServicePortName("test", "filterIPv4InIPV6Mode", "testPort", v1.ProtocolTCP): makeTestServiceInfo(testClusterIPv6, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
||||||
info.externalIPs = []string{testExternalIPv6}
|
info.externalIPs = []string{testExternalIPv6}
|
||||||
info.loadBalancerSourceRanges = []string{testSourceRangeIPv6}
|
info.loadBalancerSourceRanges = []string{testSourceRangeIPv6}
|
||||||
}),
|
}),
|
||||||
@ -370,7 +371,7 @@ func TestServiceToServiceMap(t *testing.T) {
|
|||||||
t.Errorf("[%s] expected %d new, got %d: %v", tc.desc, len(tc.expected), len(newServices), spew.Sdump(newServices))
|
t.Errorf("[%s] expected %d new, got %d: %v", tc.desc, len(tc.expected), len(newServices), spew.Sdump(newServices))
|
||||||
}
|
}
|
||||||
for svcKey, expectedInfo := range tc.expected {
|
for svcKey, expectedInfo := range tc.expected {
|
||||||
svcInfo := newServices[svcKey].(*BaseServiceInfo)
|
svcInfo, _ := newServices[svcKey].(*BaseServiceInfo)
|
||||||
if !svcInfo.clusterIP.Equal(expectedInfo.clusterIP) ||
|
if !svcInfo.clusterIP.Equal(expectedInfo.clusterIP) ||
|
||||||
svcInfo.port != expectedInfo.port ||
|
svcInfo.port != expectedInfo.port ||
|
||||||
svcInfo.protocol != expectedInfo.protocol ||
|
svcInfo.protocol != expectedInfo.protocol ||
|
||||||
|
@ -44,6 +44,7 @@ type Provider interface {
|
|||||||
type ServicePortName struct {
|
type ServicePortName struct {
|
||||||
types.NamespacedName
|
types.NamespacedName
|
||||||
Port string
|
Port string
|
||||||
|
Protocol v1.Protocol
|
||||||
}
|
}
|
||||||
|
|
||||||
func (spn ServicePortName) String() string {
|
func (spn ServicePortName) String() string {
|
||||||
|
Loading…
Reference in New Issue
Block a user