diff --git a/pkg/proxy/endpoints_test.go b/pkg/proxy/endpoints_test.go index d736cd15eb8..a5c678cae77 100644 --- a/pkg/proxy/endpoints_test.go +++ b/pkg/proxy/endpoints_test.go @@ -134,6 +134,28 @@ func TestGetLocalEndpointIPs(t *testing.T) { {Namespace: "ns2", Name: "ep2"}: sets.NewString("2.2.2.2", "2.2.2.22"), {Namespace: "ns4", Name: "ep4"}: sets.NewString("4.4.4.4", "4.4.4.6"), }, + }, { + // Case[6]: all endpoints are terminating,, so getLocalReadyEndpointIPs should return 0 ready endpoints + endpointsMap: EndpointsMap{ + makeServicePortName("ns1", "ep1", "p11", v1.ProtocolTCP): []Endpoint{ + &BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false, Ready: false, Serving: true, Terminating: true}, + }, + makeServicePortName("ns2", "ep2", "p22", v1.ProtocolTCP): []Endpoint{ + &BaseEndpointInfo{Endpoint: "2.2.2.2:22", IsLocal: true, Ready: false, Serving: true, Terminating: true}, + &BaseEndpointInfo{Endpoint: "2.2.2.22:22", IsLocal: true, Ready: false, Serving: true, Terminating: true}, + }, + makeServicePortName("ns2", "ep2", "p23", v1.ProtocolTCP): []Endpoint{ + &BaseEndpointInfo{Endpoint: "2.2.2.3:23", IsLocal: true, Ready: false, Serving: true, Terminating: true}, + }, + makeServicePortName("ns4", "ep4", "p44", v1.ProtocolTCP): []Endpoint{ + &BaseEndpointInfo{Endpoint: "4.4.4.4:44", IsLocal: true, Ready: false, Serving: true, Terminating: true}, + &BaseEndpointInfo{Endpoint: "4.4.4.5:44", IsLocal: false, Ready: false, Serving: true, Terminating: true}, + }, + makeServicePortName("ns4", "ep4", "p45", v1.ProtocolTCP): []Endpoint{ + &BaseEndpointInfo{Endpoint: "4.4.4.6:45", IsLocal: true, Ready: false, Serving: true, Terminating: true}, + }, + }, + expected: make(map[types.NamespacedName]sets.String, 0), }} for tci, tc := range testCases {