mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-12 20:57:20 +00:00
Refactor tests to split ObjectMeta from TypeMeta
This commit is contained in:
@@ -27,7 +27,7 @@ import (
|
||||
)
|
||||
|
||||
func TestServices(t *testing.T) {
|
||||
service := api.Service{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}}
|
||||
service := api.Service{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}}
|
||||
|
||||
fakeWatch := watch.NewFake()
|
||||
fakeClient := &client.Fake{Watch: fakeWatch}
|
||||
@@ -72,13 +72,13 @@ func TestServices(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServicesFromZero(t *testing.T) {
|
||||
service := api.Service{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}}
|
||||
service := api.Service{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}}
|
||||
|
||||
fakeWatch := watch.NewFake()
|
||||
fakeWatch.Stop()
|
||||
fakeClient := &client.Fake{Watch: fakeWatch}
|
||||
fakeClient.ServiceList = api.ServiceList{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "2"},
|
||||
ListMeta: api.ListMeta{ResourceVersion: "2"},
|
||||
Items: []api.Service{
|
||||
service,
|
||||
},
|
||||
@@ -152,7 +152,7 @@ func TestServicesFromZeroError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEndpoints(t *testing.T) {
|
||||
endpoint := api.Endpoints{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}}
|
||||
endpoint := api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}}
|
||||
|
||||
fakeWatch := watch.NewFake()
|
||||
fakeClient := &client.Fake{Watch: fakeWatch}
|
||||
@@ -197,13 +197,13 @@ func TestEndpoints(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEndpointsFromZero(t *testing.T) {
|
||||
endpoint := api.Endpoints{TypeMeta: api.TypeMeta{Name: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}}
|
||||
endpoint := api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"}, Endpoints: []string{"127.0.0.1:9000"}}
|
||||
|
||||
fakeWatch := watch.NewFake()
|
||||
fakeWatch.Stop()
|
||||
fakeClient := &client.Fake{Watch: fakeWatch}
|
||||
fakeClient.EndpointsList = api.EndpointsList{
|
||||
TypeMeta: api.TypeMeta{ResourceVersion: "2"},
|
||||
ListMeta: api.ListMeta{ResourceVersion: "2"},
|
||||
Items: []api.Endpoints{
|
||||
endpoint,
|
||||
},
|
||||
|
@@ -136,7 +136,7 @@ func TestNewServiceAddedAndNotified(t *testing.T) {
|
||||
handler := NewServiceHandlerMock()
|
||||
handler.Wait(1)
|
||||
config.RegisterHandler(handler)
|
||||
serviceUpdate := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}, Port: 10})
|
||||
channel <- serviceUpdate
|
||||
handler.ValidateServices(t, serviceUpdate.Services)
|
||||
|
||||
@@ -147,24 +147,24 @@ func TestServiceAddedRemovedSetAndNotified(t *testing.T) {
|
||||
channel := config.Channel("one")
|
||||
handler := NewServiceHandlerMock()
|
||||
config.RegisterHandler(handler)
|
||||
serviceUpdate := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}, Port: 10})
|
||||
handler.Wait(1)
|
||||
channel <- serviceUpdate
|
||||
handler.ValidateServices(t, serviceUpdate.Services)
|
||||
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "bar"}, Port: 20})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "bar"}, Port: 20})
|
||||
handler.Wait(1)
|
||||
channel <- serviceUpdate2
|
||||
services := []api.Service{serviceUpdate2.Services[0], serviceUpdate.Services[0]}
|
||||
handler.ValidateServices(t, services)
|
||||
|
||||
serviceUpdate3 := CreateServiceUpdate(REMOVE, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}})
|
||||
serviceUpdate3 := CreateServiceUpdate(REMOVE, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}})
|
||||
handler.Wait(1)
|
||||
channel <- serviceUpdate3
|
||||
services = []api.Service{serviceUpdate2.Services[0]}
|
||||
handler.ValidateServices(t, services)
|
||||
|
||||
serviceUpdate4 := CreateServiceUpdate(SET, api.Service{TypeMeta: api.TypeMeta{Name: "foobar"}, Port: 99})
|
||||
serviceUpdate4 := CreateServiceUpdate(SET, api.Service{ObjectMeta: api.ObjectMeta{Name: "foobar"}, Port: 99})
|
||||
handler.Wait(1)
|
||||
channel <- serviceUpdate4
|
||||
services = []api.Service{serviceUpdate4.Services[0]}
|
||||
@@ -180,8 +180,8 @@ func TestNewMultipleSourcesServicesAddedAndNotified(t *testing.T) {
|
||||
}
|
||||
handler := NewServiceHandlerMock()
|
||||
config.RegisterHandler(handler)
|
||||
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "bar"}, Port: 20})
|
||||
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "bar"}, Port: 20})
|
||||
handler.Wait(2)
|
||||
channelOne <- serviceUpdate1
|
||||
channelTwo <- serviceUpdate2
|
||||
@@ -197,8 +197,8 @@ func TestNewMultipleSourcesServicesMultipleHandlersAddedAndNotified(t *testing.T
|
||||
handler2 := NewServiceHandlerMock()
|
||||
config.RegisterHandler(handler)
|
||||
config.RegisterHandler(handler2)
|
||||
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{TypeMeta: api.TypeMeta{Name: "bar"}, Port: 20})
|
||||
serviceUpdate1 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "foo"}, Port: 10})
|
||||
serviceUpdate2 := CreateServiceUpdate(ADD, api.Service{ObjectMeta: api.ObjectMeta{Name: "bar"}, Port: 20})
|
||||
handler.Wait(2)
|
||||
handler2.Wait(2)
|
||||
channelOne <- serviceUpdate1
|
||||
@@ -217,12 +217,12 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddedAndNotified(t *testing.
|
||||
config.RegisterHandler(handler)
|
||||
config.RegisterHandler(handler2)
|
||||
endpointsUpdate1 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1", "endpoint2"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1", "endpoint2"},
|
||||
})
|
||||
endpointsUpdate2 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint3", "endpoint4"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint3", "endpoint4"},
|
||||
})
|
||||
handler.Wait(2)
|
||||
handler2.Wait(2)
|
||||
@@ -243,12 +243,12 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
|
||||
config.RegisterHandler(handler)
|
||||
config.RegisterHandler(handler2)
|
||||
endpointsUpdate1 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1", "endpoint2"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1", "endpoint2"},
|
||||
})
|
||||
endpointsUpdate2 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint3", "endpoint4"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint3", "endpoint4"},
|
||||
})
|
||||
handler.Wait(2)
|
||||
handler2.Wait(2)
|
||||
@@ -261,8 +261,8 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
|
||||
|
||||
// Add one more
|
||||
endpointsUpdate3 := CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foobar"},
|
||||
Endpoints: []string{"endpoint5", "endpoint6"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foobar"},
|
||||
Endpoints: []string{"endpoint5", "endpoint6"},
|
||||
})
|
||||
handler.Wait(1)
|
||||
handler2.Wait(1)
|
||||
@@ -273,8 +273,8 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
|
||||
|
||||
// Update the "foo" service with new endpoints
|
||||
endpointsUpdate1 = CreateEndpointsUpdate(ADD, api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint77"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint77"},
|
||||
})
|
||||
handler.Wait(1)
|
||||
handler2.Wait(1)
|
||||
@@ -284,7 +284,7 @@ func TestNewMultipleSourcesEndpointsMultipleHandlersAddRemoveSetAndNotified(t *t
|
||||
handler2.ValidateEndpoints(t, endpoints)
|
||||
|
||||
// Remove "bar" service
|
||||
endpointsUpdate2 = CreateEndpointsUpdate(REMOVE, api.Endpoints{TypeMeta: api.TypeMeta{Name: "bar"}})
|
||||
endpointsUpdate2 = CreateEndpointsUpdate(REMOVE, api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "bar"}})
|
||||
handler.Wait(1)
|
||||
handler2.Wait(1)
|
||||
channelTwo <- endpointsUpdate2
|
||||
|
@@ -163,8 +163,8 @@ func TestTCPProxy(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -181,8 +181,8 @@ func TestUDPProxy(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -208,8 +208,8 @@ func TestTCPProxyStop(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -236,8 +236,8 @@ func TestUDPProxyStop(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -264,8 +264,8 @@ func TestTCPProxyUpdateDelete(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -291,8 +291,8 @@ func TestUDPProxyUpdateDelete(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -318,8 +318,8 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -340,7 +340,7 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) {
|
||||
t.Fatalf(err.Error())
|
||||
}
|
||||
p.OnUpdate([]api.Service{
|
||||
{TypeMeta: api.TypeMeta{Name: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "TCP"},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "TCP"},
|
||||
})
|
||||
testEchoTCP(t, "127.0.0.1", svcInfo.proxyPort)
|
||||
}
|
||||
@@ -349,8 +349,8 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -371,7 +371,7 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) {
|
||||
t.Fatalf(err.Error())
|
||||
}
|
||||
p.OnUpdate([]api.Service{
|
||||
{TypeMeta: api.TypeMeta{Name: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "UDP"},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "echo"}, Port: svcInfo.proxyPort, ProxyPort: svcInfo.proxyPort, Protocol: "UDP"},
|
||||
})
|
||||
testEchoUDP(t, "127.0.0.1", svcInfo.proxyPort)
|
||||
}
|
||||
@@ -380,8 +380,8 @@ func TestTCPProxyUpdatePort(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", tcpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -406,7 +406,7 @@ func TestTCPProxyUpdatePort(t *testing.T) {
|
||||
t.Errorf("expected difference, got %d %d", newPort, svcInfo.proxyPort)
|
||||
}
|
||||
p.OnUpdate([]api.Service{
|
||||
{TypeMeta: api.TypeMeta{Name: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "TCP"},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "TCP"},
|
||||
})
|
||||
if err := waitForClosedPortTCP(p, svcInfo.proxyPort); err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
@@ -425,8 +425,8 @@ func TestUDPProxyUpdatePort(t *testing.T) {
|
||||
lb := NewLoadBalancerRR()
|
||||
lb.OnUpdate([]api.Endpoints{
|
||||
{
|
||||
TypeMeta: api.TypeMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
ObjectMeta: api.ObjectMeta{Name: "echo"},
|
||||
Endpoints: []string{net.JoinHostPort("127.0.0.1", udpServerPort)},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -451,7 +451,7 @@ func TestUDPProxyUpdatePort(t *testing.T) {
|
||||
t.Errorf("expected difference, got %d %d", newPort, svcInfo.proxyPort)
|
||||
}
|
||||
p.OnUpdate([]api.Service{
|
||||
{TypeMeta: api.TypeMeta{Name: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "UDP"},
|
||||
{ObjectMeta: api.ObjectMeta{Name: "echo"}, Port: newPort, ProxyPort: newPort, Protocol: "UDP"},
|
||||
})
|
||||
if err := waitForClosedPortUDP(p, svcInfo.proxyPort); err != nil {
|
||||
t.Fatalf(err.Error())
|
||||
|
@@ -86,8 +86,8 @@ func TestLoadBalanceWorksWithSingleEndpoint(t *testing.T) {
|
||||
}
|
||||
endpoints := make([]api.Endpoints, 1)
|
||||
endpoints[0] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1:40"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint1:40"},
|
||||
}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint1:40")
|
||||
@@ -104,8 +104,8 @@ func TestLoadBalanceWorksWithMultipleEndpoints(t *testing.T) {
|
||||
}
|
||||
endpoints := make([]api.Endpoints, 1)
|
||||
endpoints[0] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint:1")
|
||||
@@ -122,8 +122,8 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
|
||||
}
|
||||
endpoints := make([]api.Endpoints, 1)
|
||||
endpoints[0] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint:1")
|
||||
@@ -133,7 +133,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint:2")
|
||||
// Then update the configuration with one fewer endpoints, make sure
|
||||
// we start in the beginning again
|
||||
endpoints[0] = api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
endpoints[0] = api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:8", "endpoint:9"},
|
||||
}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
@@ -142,7 +142,7 @@ func TestLoadBalanceWorksWithMultipleEndpointsAndUpdates(t *testing.T) {
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint:8")
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint:9")
|
||||
// Clear endpoints
|
||||
endpoints[0] = api.Endpoints{TypeMeta: api.TypeMeta{Name: "foo"}, Endpoints: []string{}}
|
||||
endpoints[0] = api.Endpoints{ObjectMeta: api.ObjectMeta{Name: "foo"}, Endpoints: []string{}}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
|
||||
endpoint, err = loadBalancer.NextEndpoint("foo", nil)
|
||||
@@ -159,12 +159,12 @@ func TestLoadBalanceWorksWithServiceRemoval(t *testing.T) {
|
||||
}
|
||||
endpoints := make([]api.Endpoints, 2)
|
||||
endpoints[0] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Endpoints: []string{"endpoint:1", "endpoint:2", "endpoint:3"},
|
||||
}
|
||||
endpoints[1] = api.Endpoints{
|
||||
TypeMeta: api.TypeMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint:4", "endpoint:5"},
|
||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||
Endpoints: []string{"endpoint:4", "endpoint:5"},
|
||||
}
|
||||
loadBalancer.OnUpdate(endpoints)
|
||||
expectEndpoint(t, loadBalancer, "foo", "endpoint:1")
|
||||
|
Reference in New Issue
Block a user