mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
Fresh dep ensure
This commit is contained in:
28
vendor/k8s.io/kubernetes/pkg/proxy/config/BUILD
generated
vendored
28
vendor/k8s.io/kubernetes/pkg/proxy/config/BUILD
generated
vendored
@ -14,13 +14,13 @@ go_library(
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/pkg/proxy/config",
|
||||
deps = [
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/client/informers/informers_generated/internalversion/core/internalversion:go_default_library",
|
||||
"//pkg/client/listers/core/internalversion:go_default_library",
|
||||
"//pkg/controller:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@ -32,14 +32,14 @@ go_test(
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//pkg/apis/core:go_default_library",
|
||||
"//pkg/client/clientset_generated/internalclientset/fake:go_default_library",
|
||||
"//pkg/client/informers/informers_generated/internalversion:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
|
||||
"//vendor/k8s.io/client-go/testing:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
||||
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/informers:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/testing:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
98
vendor/k8s.io/kubernetes/pkg/proxy/config/api_test.go
generated
vendored
98
vendor/k8s.io/kubernetes/pkg/proxy/config/api_test.go
generated
vendored
@ -22,25 +22,25 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
informers "k8s.io/client-go/informers"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
ktesting "k8s.io/client-go/testing"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
|
||||
informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion"
|
||||
)
|
||||
|
||||
func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
|
||||
service1v1 := &api.Service{
|
||||
service1v1 := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "s1"},
|
||||
Spec: api.ServiceSpec{Ports: []api.ServicePort{{Protocol: "TCP", Port: 10}}}}
|
||||
service1v2 := &api.Service{
|
||||
Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{Protocol: "TCP", Port: 10}}}}
|
||||
service1v2 := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "s1"},
|
||||
Spec: api.ServiceSpec{Ports: []api.ServicePort{{Protocol: "TCP", Port: 20}}}}
|
||||
service2 := &api.Service{
|
||||
Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{Protocol: "TCP", Port: 20}}}}
|
||||
service2 := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "s2"},
|
||||
Spec: api.ServiceSpec{Ports: []api.ServicePort{{Protocol: "TCP", Port: 30}}}}
|
||||
Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{Protocol: "TCP", Port: 30}}}}
|
||||
|
||||
// Setup fake api client.
|
||||
client := fake.NewSimpleClientset()
|
||||
@ -54,59 +54,59 @@ func TestNewServicesSourceApi_UpdatesAndMultipleServices(t *testing.T) {
|
||||
|
||||
sharedInformers := informers.NewSharedInformerFactory(client, time.Minute)
|
||||
|
||||
serviceConfig := NewServiceConfig(sharedInformers.Core().InternalVersion().Services(), time.Minute)
|
||||
serviceConfig := NewServiceConfig(sharedInformers.Core().V1().Services(), time.Minute)
|
||||
serviceConfig.RegisterEventHandler(handler)
|
||||
go sharedInformers.Start(stopCh)
|
||||
go serviceConfig.Run(stopCh)
|
||||
|
||||
// Add the first service
|
||||
fakeWatch.Add(service1v1)
|
||||
handler.ValidateServices(t, []*api.Service{service1v1})
|
||||
handler.ValidateServices(t, []*v1.Service{service1v1})
|
||||
|
||||
// Add another service
|
||||
fakeWatch.Add(service2)
|
||||
handler.ValidateServices(t, []*api.Service{service1v1, service2})
|
||||
handler.ValidateServices(t, []*v1.Service{service1v1, service2})
|
||||
|
||||
// Modify service1
|
||||
fakeWatch.Modify(service1v2)
|
||||
handler.ValidateServices(t, []*api.Service{service1v2, service2})
|
||||
handler.ValidateServices(t, []*v1.Service{service1v2, service2})
|
||||
|
||||
// Delete service1
|
||||
fakeWatch.Delete(service1v2)
|
||||
handler.ValidateServices(t, []*api.Service{service2})
|
||||
handler.ValidateServices(t, []*v1.Service{service2})
|
||||
|
||||
// Delete service2
|
||||
fakeWatch.Delete(service2)
|
||||
handler.ValidateServices(t, []*api.Service{})
|
||||
handler.ValidateServices(t, []*v1.Service{})
|
||||
}
|
||||
|
||||
func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
|
||||
endpoints1v1 := &api.Endpoints{
|
||||
endpoints1v1 := &v1.Endpoints{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "e1"},
|
||||
Subsets: []api.EndpointSubset{{
|
||||
Addresses: []api.EndpointAddress{
|
||||
Subsets: []v1.EndpointSubset{{
|
||||
Addresses: []v1.EndpointAddress{
|
||||
{IP: "1.2.3.4"},
|
||||
},
|
||||
Ports: []api.EndpointPort{{Port: 8080, Protocol: "TCP"}},
|
||||
Ports: []v1.EndpointPort{{Port: 8080, Protocol: "TCP"}},
|
||||
}},
|
||||
}
|
||||
endpoints1v2 := &api.Endpoints{
|
||||
endpoints1v2 := &v1.Endpoints{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "e1"},
|
||||
Subsets: []api.EndpointSubset{{
|
||||
Addresses: []api.EndpointAddress{
|
||||
Subsets: []v1.EndpointSubset{{
|
||||
Addresses: []v1.EndpointAddress{
|
||||
{IP: "1.2.3.4"},
|
||||
{IP: "4.3.2.1"},
|
||||
},
|
||||
Ports: []api.EndpointPort{{Port: 8080, Protocol: "TCP"}},
|
||||
Ports: []v1.EndpointPort{{Port: 8080, Protocol: "TCP"}},
|
||||
}},
|
||||
}
|
||||
endpoints2 := &api.Endpoints{
|
||||
endpoints2 := &v1.Endpoints{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "e2"},
|
||||
Subsets: []api.EndpointSubset{{
|
||||
Addresses: []api.EndpointAddress{
|
||||
Subsets: []v1.EndpointSubset{{
|
||||
Addresses: []v1.EndpointAddress{
|
||||
{IP: "5.6.7.8"},
|
||||
},
|
||||
Ports: []api.EndpointPort{{Port: 80, Protocol: "TCP"}},
|
||||
Ports: []v1.EndpointPort{{Port: 80, Protocol: "TCP"}},
|
||||
}},
|
||||
}
|
||||
|
||||
@ -122,37 +122,37 @@ func TestNewEndpointsSourceApi_UpdatesAndMultipleEndpoints(t *testing.T) {
|
||||
|
||||
sharedInformers := informers.NewSharedInformerFactory(client, time.Minute)
|
||||
|
||||
endpointsConfig := NewEndpointsConfig(sharedInformers.Core().InternalVersion().Endpoints(), time.Minute)
|
||||
endpointsConfig := NewEndpointsConfig(sharedInformers.Core().V1().Endpoints(), time.Minute)
|
||||
endpointsConfig.RegisterEventHandler(handler)
|
||||
go sharedInformers.Start(stopCh)
|
||||
go endpointsConfig.Run(stopCh)
|
||||
|
||||
// Add the first endpoints
|
||||
fakeWatch.Add(endpoints1v1)
|
||||
handler.ValidateEndpoints(t, []*api.Endpoints{endpoints1v1})
|
||||
handler.ValidateEndpoints(t, []*v1.Endpoints{endpoints1v1})
|
||||
|
||||
// Add another endpoints
|
||||
fakeWatch.Add(endpoints2)
|
||||
handler.ValidateEndpoints(t, []*api.Endpoints{endpoints1v1, endpoints2})
|
||||
handler.ValidateEndpoints(t, []*v1.Endpoints{endpoints1v1, endpoints2})
|
||||
|
||||
// Modify endpoints1
|
||||
fakeWatch.Modify(endpoints1v2)
|
||||
handler.ValidateEndpoints(t, []*api.Endpoints{endpoints1v2, endpoints2})
|
||||
handler.ValidateEndpoints(t, []*v1.Endpoints{endpoints1v2, endpoints2})
|
||||
|
||||
// Delete endpoints1
|
||||
fakeWatch.Delete(endpoints1v2)
|
||||
handler.ValidateEndpoints(t, []*api.Endpoints{endpoints2})
|
||||
handler.ValidateEndpoints(t, []*v1.Endpoints{endpoints2})
|
||||
|
||||
// Delete endpoints2
|
||||
fakeWatch.Delete(endpoints2)
|
||||
handler.ValidateEndpoints(t, []*api.Endpoints{})
|
||||
handler.ValidateEndpoints(t, []*v1.Endpoints{})
|
||||
}
|
||||
|
||||
func newSvcHandler(t *testing.T, svcs []*api.Service, done func()) ServiceHandler {
|
||||
func newSvcHandler(t *testing.T, svcs []*v1.Service, done func()) ServiceHandler {
|
||||
shm := &ServiceHandlerMock{
|
||||
state: make(map[types.NamespacedName]*api.Service),
|
||||
state: make(map[types.NamespacedName]*v1.Service),
|
||||
}
|
||||
shm.process = func(services []*api.Service) {
|
||||
shm.process = func(services []*v1.Service) {
|
||||
defer done()
|
||||
if !reflect.DeepEqual(services, svcs) {
|
||||
t.Errorf("Unexpected services: %#v, expected: %#v", services, svcs)
|
||||
@ -161,11 +161,11 @@ func newSvcHandler(t *testing.T, svcs []*api.Service, done func()) ServiceHandle
|
||||
return shm
|
||||
}
|
||||
|
||||
func newEpsHandler(t *testing.T, eps []*api.Endpoints, done func()) EndpointsHandler {
|
||||
func newEpsHandler(t *testing.T, eps []*v1.Endpoints, done func()) EndpointsHandler {
|
||||
ehm := &EndpointsHandlerMock{
|
||||
state: make(map[types.NamespacedName]*api.Endpoints),
|
||||
state: make(map[types.NamespacedName]*v1.Endpoints),
|
||||
}
|
||||
ehm.process = func(endpoints []*api.Endpoints) {
|
||||
ehm.process = func(endpoints []*v1.Endpoints) {
|
||||
defer done()
|
||||
if !reflect.DeepEqual(eps, endpoints) {
|
||||
t.Errorf("Unexpected endpoints: %#v, expected: %#v", endpoints, eps)
|
||||
@ -175,18 +175,18 @@ func newEpsHandler(t *testing.T, eps []*api.Endpoints, done func()) EndpointsHan
|
||||
}
|
||||
|
||||
func TestInitialSync(t *testing.T) {
|
||||
svc1 := &api.Service{
|
||||
svc1 := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "foo"},
|
||||
Spec: api.ServiceSpec{Ports: []api.ServicePort{{Protocol: "TCP", Port: 10}}},
|
||||
Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{Protocol: "TCP", Port: 10}}},
|
||||
}
|
||||
svc2 := &api.Service{
|
||||
svc2 := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "bar"},
|
||||
Spec: api.ServiceSpec{Ports: []api.ServicePort{{Protocol: "TCP", Port: 10}}},
|
||||
Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{Protocol: "TCP", Port: 10}}},
|
||||
}
|
||||
eps1 := &api.Endpoints{
|
||||
eps1 := &v1.Endpoints{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "foo"},
|
||||
}
|
||||
eps2 := &api.Endpoints{
|
||||
eps2 := &v1.Endpoints{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "bar"},
|
||||
}
|
||||
|
||||
@ -198,11 +198,11 @@ func TestInitialSync(t *testing.T) {
|
||||
client := fake.NewSimpleClientset(svc1, svc2, eps2, eps1)
|
||||
sharedInformers := informers.NewSharedInformerFactory(client, 0)
|
||||
|
||||
svcConfig := NewServiceConfig(sharedInformers.Core().InternalVersion().Services(), 0)
|
||||
epsConfig := NewEndpointsConfig(sharedInformers.Core().InternalVersion().Endpoints(), 0)
|
||||
svcHandler := newSvcHandler(t, []*api.Service{svc2, svc1}, wg.Done)
|
||||
svcConfig := NewServiceConfig(sharedInformers.Core().V1().Services(), 0)
|
||||
epsConfig := NewEndpointsConfig(sharedInformers.Core().V1().Endpoints(), 0)
|
||||
svcHandler := newSvcHandler(t, []*v1.Service{svc2, svc1}, wg.Done)
|
||||
svcConfig.RegisterEventHandler(svcHandler)
|
||||
epsHandler := newEpsHandler(t, []*api.Endpoints{eps2, eps1}, wg.Done)
|
||||
epsHandler := newEpsHandler(t, []*v1.Endpoints{eps2, eps1}, wg.Done)
|
||||
epsConfig.RegisterEventHandler(epsHandler)
|
||||
|
||||
stopCh := make(chan struct{})
|
||||
|
64
vendor/k8s.io/kubernetes/pkg/proxy/config/config.go
generated
vendored
64
vendor/k8s.io/kubernetes/pkg/proxy/config/config.go
generated
vendored
@ -20,12 +20,12 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/api/core/v1"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
coreinformers "k8s.io/client-go/informers/core/v1"
|
||||
listers "k8s.io/client-go/listers/core/v1"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
coreinformers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion/core/internalversion"
|
||||
listers "k8s.io/kubernetes/pkg/client/listers/core/internalversion"
|
||||
"k8s.io/klog"
|
||||
"k8s.io/kubernetes/pkg/controller"
|
||||
)
|
||||
|
||||
@ -34,13 +34,13 @@ import (
|
||||
type ServiceHandler interface {
|
||||
// OnServiceAdd is called whenever creation of new service object
|
||||
// is observed.
|
||||
OnServiceAdd(service *api.Service)
|
||||
OnServiceAdd(service *v1.Service)
|
||||
// OnServiceUpdate is called whenever modification of an existing
|
||||
// service object is observed.
|
||||
OnServiceUpdate(oldService, service *api.Service)
|
||||
OnServiceUpdate(oldService, service *v1.Service)
|
||||
// OnServiceDelete is called whenever deletion of an existing service
|
||||
// object is observed.
|
||||
OnServiceDelete(service *api.Service)
|
||||
OnServiceDelete(service *v1.Service)
|
||||
// OnServiceSynced is called once all the initial even handlers were
|
||||
// called and the state is fully propagated to local cache.
|
||||
OnServiceSynced()
|
||||
@ -51,13 +51,13 @@ type ServiceHandler interface {
|
||||
type EndpointsHandler interface {
|
||||
// OnEndpointsAdd is called whenever creation of new endpoints object
|
||||
// is observed.
|
||||
OnEndpointsAdd(endpoints *api.Endpoints)
|
||||
OnEndpointsAdd(endpoints *v1.Endpoints)
|
||||
// OnEndpointsUpdate is called whenever modification of an existing
|
||||
// endpoints object is observed.
|
||||
OnEndpointsUpdate(oldEndpoints, endpoints *api.Endpoints)
|
||||
OnEndpointsUpdate(oldEndpoints, endpoints *v1.Endpoints)
|
||||
// OnEndpointsDelete is called whever deletion of an existing endpoints
|
||||
// object is observed.
|
||||
OnEndpointsDelete(endpoints *api.Endpoints)
|
||||
OnEndpointsDelete(endpoints *v1.Endpoints)
|
||||
// OnEndpointsSynced is called once all the initial event handlers were
|
||||
// called and the state is fully propagated to local cache.
|
||||
OnEndpointsSynced()
|
||||
@ -99,15 +99,15 @@ func (c *EndpointsConfig) RegisterEventHandler(handler EndpointsHandler) {
|
||||
func (c *EndpointsConfig) Run(stopCh <-chan struct{}) {
|
||||
defer utilruntime.HandleCrash()
|
||||
|
||||
glog.Info("Starting endpoints config controller")
|
||||
defer glog.Info("Shutting down endpoints config controller")
|
||||
klog.Info("Starting endpoints config controller")
|
||||
defer klog.Info("Shutting down endpoints config controller")
|
||||
|
||||
if !controller.WaitForCacheSync("endpoints config", stopCh, c.listerSynced) {
|
||||
return
|
||||
}
|
||||
|
||||
for i := range c.eventHandlers {
|
||||
glog.V(3).Infof("Calling handler.OnEndpointsSynced()")
|
||||
klog.V(3).Infof("Calling handler.OnEndpointsSynced()")
|
||||
c.eventHandlers[i].OnEndpointsSynced()
|
||||
}
|
||||
|
||||
@ -115,49 +115,49 @@ func (c *EndpointsConfig) Run(stopCh <-chan struct{}) {
|
||||
}
|
||||
|
||||
func (c *EndpointsConfig) handleAddEndpoints(obj interface{}) {
|
||||
endpoints, ok := obj.(*api.Endpoints)
|
||||
endpoints, ok := obj.(*v1.Endpoints)
|
||||
if !ok {
|
||||
utilruntime.HandleError(fmt.Errorf("unexpected object type: %v", obj))
|
||||
return
|
||||
}
|
||||
for i := range c.eventHandlers {
|
||||
glog.V(4).Infof("Calling handler.OnEndpointsAdd")
|
||||
klog.V(4).Infof("Calling handler.OnEndpointsAdd")
|
||||
c.eventHandlers[i].OnEndpointsAdd(endpoints)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *EndpointsConfig) handleUpdateEndpoints(oldObj, newObj interface{}) {
|
||||
oldEndpoints, ok := oldObj.(*api.Endpoints)
|
||||
oldEndpoints, ok := oldObj.(*v1.Endpoints)
|
||||
if !ok {
|
||||
utilruntime.HandleError(fmt.Errorf("unexpected object type: %v", oldObj))
|
||||
return
|
||||
}
|
||||
endpoints, ok := newObj.(*api.Endpoints)
|
||||
endpoints, ok := newObj.(*v1.Endpoints)
|
||||
if !ok {
|
||||
utilruntime.HandleError(fmt.Errorf("unexpected object type: %v", newObj))
|
||||
return
|
||||
}
|
||||
for i := range c.eventHandlers {
|
||||
glog.V(4).Infof("Calling handler.OnEndpointsUpdate")
|
||||
klog.V(4).Infof("Calling handler.OnEndpointsUpdate")
|
||||
c.eventHandlers[i].OnEndpointsUpdate(oldEndpoints, endpoints)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *EndpointsConfig) handleDeleteEndpoints(obj interface{}) {
|
||||
endpoints, ok := obj.(*api.Endpoints)
|
||||
endpoints, ok := obj.(*v1.Endpoints)
|
||||
if !ok {
|
||||
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
||||
if !ok {
|
||||
utilruntime.HandleError(fmt.Errorf("unexpected object type: %v", obj))
|
||||
return
|
||||
}
|
||||
if endpoints, ok = tombstone.Obj.(*api.Endpoints); !ok {
|
||||
if endpoints, ok = tombstone.Obj.(*v1.Endpoints); !ok {
|
||||
utilruntime.HandleError(fmt.Errorf("unexpected object type: %v", obj))
|
||||
return
|
||||
}
|
||||
}
|
||||
for i := range c.eventHandlers {
|
||||
glog.V(4).Infof("Calling handler.OnEndpointsDelete")
|
||||
klog.V(4).Infof("Calling handler.OnEndpointsDelete")
|
||||
c.eventHandlers[i].OnEndpointsDelete(endpoints)
|
||||
}
|
||||
}
|
||||
@ -199,15 +199,15 @@ func (c *ServiceConfig) RegisterEventHandler(handler ServiceHandler) {
|
||||
func (c *ServiceConfig) Run(stopCh <-chan struct{}) {
|
||||
defer utilruntime.HandleCrash()
|
||||
|
||||
glog.Info("Starting service config controller")
|
||||
defer glog.Info("Shutting down service config controller")
|
||||
klog.Info("Starting service config controller")
|
||||
defer klog.Info("Shutting down service config controller")
|
||||
|
||||
if !controller.WaitForCacheSync("service config", stopCh, c.listerSynced) {
|
||||
return
|
||||
}
|
||||
|
||||
for i := range c.eventHandlers {
|
||||
glog.V(3).Infof("Calling handler.OnServiceSynced()")
|
||||
klog.V(3).Info("Calling handler.OnServiceSynced()")
|
||||
c.eventHandlers[i].OnServiceSynced()
|
||||
}
|
||||
|
||||
@ -215,49 +215,49 @@ func (c *ServiceConfig) Run(stopCh <-chan struct{}) {
|
||||
}
|
||||
|
||||
func (c *ServiceConfig) handleAddService(obj interface{}) {
|
||||
service, ok := obj.(*api.Service)
|
||||
service, ok := obj.(*v1.Service)
|
||||
if !ok {
|
||||
utilruntime.HandleError(fmt.Errorf("unexpected object type: %v", obj))
|
||||
return
|
||||
}
|
||||
for i := range c.eventHandlers {
|
||||
glog.V(4).Infof("Calling handler.OnServiceAdd")
|
||||
klog.V(4).Info("Calling handler.OnServiceAdd")
|
||||
c.eventHandlers[i].OnServiceAdd(service)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ServiceConfig) handleUpdateService(oldObj, newObj interface{}) {
|
||||
oldService, ok := oldObj.(*api.Service)
|
||||
oldService, ok := oldObj.(*v1.Service)
|
||||
if !ok {
|
||||
utilruntime.HandleError(fmt.Errorf("unexpected object type: %v", oldObj))
|
||||
return
|
||||
}
|
||||
service, ok := newObj.(*api.Service)
|
||||
service, ok := newObj.(*v1.Service)
|
||||
if !ok {
|
||||
utilruntime.HandleError(fmt.Errorf("unexpected object type: %v", newObj))
|
||||
return
|
||||
}
|
||||
for i := range c.eventHandlers {
|
||||
glog.V(4).Infof("Calling handler.OnServiceUpdate")
|
||||
klog.V(4).Info("Calling handler.OnServiceUpdate")
|
||||
c.eventHandlers[i].OnServiceUpdate(oldService, service)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ServiceConfig) handleDeleteService(obj interface{}) {
|
||||
service, ok := obj.(*api.Service)
|
||||
service, ok := obj.(*v1.Service)
|
||||
if !ok {
|
||||
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
|
||||
if !ok {
|
||||
utilruntime.HandleError(fmt.Errorf("unexpected object type: %v", obj))
|
||||
return
|
||||
}
|
||||
if service, ok = tombstone.Obj.(*api.Service); !ok {
|
||||
if service, ok = tombstone.Obj.(*v1.Service); !ok {
|
||||
utilruntime.HandleError(fmt.Errorf("unexpected object type: %v", obj))
|
||||
return
|
||||
}
|
||||
}
|
||||
for i := range c.eventHandlers {
|
||||
glog.V(4).Infof("Calling handler.OnServiceDelete")
|
||||
klog.V(4).Info("Calling handler.OnServiceDelete")
|
||||
c.eventHandlers[i].OnServiceDelete(service)
|
||||
}
|
||||
}
|
||||
|
156
vendor/k8s.io/kubernetes/pkg/proxy/config/config_test.go
generated
vendored
156
vendor/k8s.io/kubernetes/pkg/proxy/config/config_test.go
generated
vendored
@ -23,17 +23,17 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
informers "k8s.io/client-go/informers"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
ktesting "k8s.io/client-go/testing"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
|
||||
informers "k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion"
|
||||
)
|
||||
|
||||
type sortedServices []*api.Service
|
||||
type sortedServices []*v1.Service
|
||||
|
||||
func (s sortedServices) Len() int {
|
||||
return len(s)
|
||||
@ -48,24 +48,24 @@ func (s sortedServices) Less(i, j int) bool {
|
||||
type ServiceHandlerMock struct {
|
||||
lock sync.Mutex
|
||||
|
||||
state map[types.NamespacedName]*api.Service
|
||||
state map[types.NamespacedName]*v1.Service
|
||||
synced bool
|
||||
updated chan []*api.Service
|
||||
process func([]*api.Service)
|
||||
updated chan []*v1.Service
|
||||
process func([]*v1.Service)
|
||||
}
|
||||
|
||||
func NewServiceHandlerMock() *ServiceHandlerMock {
|
||||
shm := &ServiceHandlerMock{
|
||||
state: make(map[types.NamespacedName]*api.Service),
|
||||
updated: make(chan []*api.Service, 5),
|
||||
state: make(map[types.NamespacedName]*v1.Service),
|
||||
updated: make(chan []*v1.Service, 5),
|
||||
}
|
||||
shm.process = func(services []*api.Service) {
|
||||
shm.process = func(services []*v1.Service) {
|
||||
shm.updated <- services
|
||||
}
|
||||
return shm
|
||||
}
|
||||
|
||||
func (h *ServiceHandlerMock) OnServiceAdd(service *api.Service) {
|
||||
func (h *ServiceHandlerMock) OnServiceAdd(service *v1.Service) {
|
||||
h.lock.Lock()
|
||||
defer h.lock.Unlock()
|
||||
namespacedName := types.NamespacedName{Namespace: service.Namespace, Name: service.Name}
|
||||
@ -73,7 +73,7 @@ func (h *ServiceHandlerMock) OnServiceAdd(service *api.Service) {
|
||||
h.sendServices()
|
||||
}
|
||||
|
||||
func (h *ServiceHandlerMock) OnServiceUpdate(oldService, service *api.Service) {
|
||||
func (h *ServiceHandlerMock) OnServiceUpdate(oldService, service *v1.Service) {
|
||||
h.lock.Lock()
|
||||
defer h.lock.Unlock()
|
||||
namespacedName := types.NamespacedName{Namespace: service.Namespace, Name: service.Name}
|
||||
@ -81,7 +81,7 @@ func (h *ServiceHandlerMock) OnServiceUpdate(oldService, service *api.Service) {
|
||||
h.sendServices()
|
||||
}
|
||||
|
||||
func (h *ServiceHandlerMock) OnServiceDelete(service *api.Service) {
|
||||
func (h *ServiceHandlerMock) OnServiceDelete(service *v1.Service) {
|
||||
h.lock.Lock()
|
||||
defer h.lock.Unlock()
|
||||
namespacedName := types.NamespacedName{Namespace: service.Namespace, Name: service.Name}
|
||||
@ -100,7 +100,7 @@ func (h *ServiceHandlerMock) sendServices() {
|
||||
if !h.synced {
|
||||
return
|
||||
}
|
||||
services := make([]*api.Service, 0, len(h.state))
|
||||
services := make([]*v1.Service, 0, len(h.state))
|
||||
for _, svc := range h.state {
|
||||
services = append(services, svc)
|
||||
}
|
||||
@ -108,11 +108,11 @@ func (h *ServiceHandlerMock) sendServices() {
|
||||
h.process(services)
|
||||
}
|
||||
|
||||
func (h *ServiceHandlerMock) ValidateServices(t *testing.T, expectedServices []*api.Service) {
|
||||
func (h *ServiceHandlerMock) ValidateServices(t *testing.T, expectedServices []*v1.Service) {
|
||||
// We might get 1 or more updates for N service updates, because we
|
||||
// over write older snapshots of services from the producer go-routine
|
||||
// if the consumer falls behind.
|
||||
var services []*api.Service
|
||||
var services []*v1.Service
|
||||
for {
|
||||
select {
|
||||
case services = <-h.updated:
|
||||
@ -128,7 +128,7 @@ func (h *ServiceHandlerMock) ValidateServices(t *testing.T, expectedServices []*
|
||||
}
|
||||
}
|
||||
|
||||
type sortedEndpoints []*api.Endpoints
|
||||
type sortedEndpoints []*v1.Endpoints
|
||||
|
||||
func (s sortedEndpoints) Len() int {
|
||||
return len(s)
|
||||
@ -143,24 +143,24 @@ func (s sortedEndpoints) Less(i, j int) bool {
|
||||
type EndpointsHandlerMock struct {
|
||||
lock sync.Mutex
|
||||
|
||||
state map[types.NamespacedName]*api.Endpoints
|
||||
state map[types.NamespacedName]*v1.Endpoints
|
||||
synced bool
|
||||
updated chan []*api.Endpoints
|
||||
process func([]*api.Endpoints)
|
||||
updated chan []*v1.Endpoints
|
||||
process func([]*v1.Endpoints)
|
||||
}
|
||||
|
||||
func NewEndpointsHandlerMock() *EndpointsHandlerMock {
|
||||
ehm := &EndpointsHandlerMock{
|
||||
state: make(map[types.NamespacedName]*api.Endpoints),
|
||||
updated: make(chan []*api.Endpoints, 5),
|
||||
state: make(map[types.NamespacedName]*v1.Endpoints),
|
||||
updated: make(chan []*v1.Endpoints, 5),
|
||||
}
|
||||
ehm.process = func(endpoints []*api.Endpoints) {
|
||||
ehm.process = func(endpoints []*v1.Endpoints) {
|
||||
ehm.updated <- endpoints
|
||||
}
|
||||
return ehm
|
||||
}
|
||||
|
||||
func (h *EndpointsHandlerMock) OnEndpointsAdd(endpoints *api.Endpoints) {
|
||||
func (h *EndpointsHandlerMock) OnEndpointsAdd(endpoints *v1.Endpoints) {
|
||||
h.lock.Lock()
|
||||
defer h.lock.Unlock()
|
||||
namespacedName := types.NamespacedName{Namespace: endpoints.Namespace, Name: endpoints.Name}
|
||||
@ -168,7 +168,7 @@ func (h *EndpointsHandlerMock) OnEndpointsAdd(endpoints *api.Endpoints) {
|
||||
h.sendEndpoints()
|
||||
}
|
||||
|
||||
func (h *EndpointsHandlerMock) OnEndpointsUpdate(oldEndpoints, endpoints *api.Endpoints) {
|
||||
func (h *EndpointsHandlerMock) OnEndpointsUpdate(oldEndpoints, endpoints *v1.Endpoints) {
|
||||
h.lock.Lock()
|
||||
defer h.lock.Unlock()
|
||||
namespacedName := types.NamespacedName{Namespace: endpoints.Namespace, Name: endpoints.Name}
|
||||
@ -176,7 +176,7 @@ func (h *EndpointsHandlerMock) OnEndpointsUpdate(oldEndpoints, endpoints *api.En
|
||||
h.sendEndpoints()
|
||||
}
|
||||
|
||||
func (h *EndpointsHandlerMock) OnEndpointsDelete(endpoints *api.Endpoints) {
|
||||
func (h *EndpointsHandlerMock) OnEndpointsDelete(endpoints *v1.Endpoints) {
|
||||
h.lock.Lock()
|
||||
defer h.lock.Unlock()
|
||||
namespacedName := types.NamespacedName{Namespace: endpoints.Namespace, Name: endpoints.Name}
|
||||
@ -195,7 +195,7 @@ func (h *EndpointsHandlerMock) sendEndpoints() {
|
||||
if !h.synced {
|
||||
return
|
||||
}
|
||||
endpoints := make([]*api.Endpoints, 0, len(h.state))
|
||||
endpoints := make([]*v1.Endpoints, 0, len(h.state))
|
||||
for _, eps := range h.state {
|
||||
endpoints = append(endpoints, eps)
|
||||
}
|
||||
@ -203,11 +203,11 @@ func (h *EndpointsHandlerMock) sendEndpoints() {
|
||||
h.process(endpoints)
|
||||
}
|
||||
|
||||
func (h *EndpointsHandlerMock) ValidateEndpoints(t *testing.T, expectedEndpoints []*api.Endpoints) {
|
||||
func (h *EndpointsHandlerMock) ValidateEndpoints(t *testing.T, expectedEndpoints []*v1.Endpoints) {
|
||||
// We might get 1 or more updates for N endpoint updates, because we
|
||||
// over write older snapshots of endpoints from the producer go-routine
|
||||
// if the consumer falls behind. Unittests will hard timeout in 5m.
|
||||
var endpoints []*api.Endpoints
|
||||
var endpoints []*v1.Endpoints
|
||||
for {
|
||||
select {
|
||||
case endpoints = <-h.updated:
|
||||
@ -233,18 +233,18 @@ func TestNewServiceAddedAndNotified(t *testing.T) {
|
||||
|
||||
sharedInformers := informers.NewSharedInformerFactory(client, time.Minute)
|
||||
|
||||
config := NewServiceConfig(sharedInformers.Core().InternalVersion().Services(), time.Minute)
|
||||
config := NewServiceConfig(sharedInformers.Core().V1().Services(), time.Minute)
|
||||
handler := NewServiceHandlerMock()
|
||||
config.RegisterEventHandler(handler)
|
||||
go sharedInformers.Start(stopCh)
|
||||
go config.Run(stopCh)
|
||||
|
||||
service := &api.Service{
|
||||
service := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "foo"},
|
||||
Spec: api.ServiceSpec{Ports: []api.ServicePort{{Protocol: "TCP", Port: 10}}},
|
||||
Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{Protocol: "TCP", Port: 10}}},
|
||||
}
|
||||
fakeWatch.Add(service)
|
||||
handler.ValidateServices(t, []*api.Service{service})
|
||||
handler.ValidateServices(t, []*v1.Service{service})
|
||||
}
|
||||
|
||||
func TestServiceAddedRemovedSetAndNotified(t *testing.T) {
|
||||
@ -257,29 +257,29 @@ func TestServiceAddedRemovedSetAndNotified(t *testing.T) {
|
||||
|
||||
sharedInformers := informers.NewSharedInformerFactory(client, time.Minute)
|
||||
|
||||
config := NewServiceConfig(sharedInformers.Core().InternalVersion().Services(), time.Minute)
|
||||
config := NewServiceConfig(sharedInformers.Core().V1().Services(), time.Minute)
|
||||
handler := NewServiceHandlerMock()
|
||||
config.RegisterEventHandler(handler)
|
||||
go sharedInformers.Start(stopCh)
|
||||
go config.Run(stopCh)
|
||||
|
||||
service1 := &api.Service{
|
||||
service1 := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "foo"},
|
||||
Spec: api.ServiceSpec{Ports: []api.ServicePort{{Protocol: "TCP", Port: 10}}},
|
||||
Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{Protocol: "TCP", Port: 10}}},
|
||||
}
|
||||
fakeWatch.Add(service1)
|
||||
handler.ValidateServices(t, []*api.Service{service1})
|
||||
handler.ValidateServices(t, []*v1.Service{service1})
|
||||
|
||||
service2 := &api.Service{
|
||||
service2 := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "bar"},
|
||||
Spec: api.ServiceSpec{Ports: []api.ServicePort{{Protocol: "TCP", Port: 20}}},
|
||||
Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{Protocol: "TCP", Port: 20}}},
|
||||
}
|
||||
fakeWatch.Add(service2)
|
||||
services := []*api.Service{service2, service1}
|
||||
services := []*v1.Service{service2, service1}
|
||||
handler.ValidateServices(t, services)
|
||||
|
||||
fakeWatch.Delete(service1)
|
||||
services = []*api.Service{service2}
|
||||
services = []*v1.Service{service2}
|
||||
handler.ValidateServices(t, services)
|
||||
}
|
||||
|
||||
@ -293,7 +293,7 @@ func TestNewServicesMultipleHandlersAddedAndNotified(t *testing.T) {
|
||||
|
||||
sharedInformers := informers.NewSharedInformerFactory(client, time.Minute)
|
||||
|
||||
config := NewServiceConfig(sharedInformers.Core().InternalVersion().Services(), time.Minute)
|
||||
config := NewServiceConfig(sharedInformers.Core().V1().Services(), time.Minute)
|
||||
handler := NewServiceHandlerMock()
|
||||
handler2 := NewServiceHandlerMock()
|
||||
config.RegisterEventHandler(handler)
|
||||
@ -301,18 +301,18 @@ func TestNewServicesMultipleHandlersAddedAndNotified(t *testing.T) {
|
||||
go sharedInformers.Start(stopCh)
|
||||
go config.Run(stopCh)
|
||||
|
||||
service1 := &api.Service{
|
||||
service1 := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "foo"},
|
||||
Spec: api.ServiceSpec{Ports: []api.ServicePort{{Protocol: "TCP", Port: 10}}},
|
||||
Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{Protocol: "TCP", Port: 10}}},
|
||||
}
|
||||
service2 := &api.Service{
|
||||
service2 := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "bar"},
|
||||
Spec: api.ServiceSpec{Ports: []api.ServicePort{{Protocol: "TCP", Port: 20}}},
|
||||
Spec: v1.ServiceSpec{Ports: []v1.ServicePort{{Protocol: "TCP", Port: 20}}},
|
||||
}
|
||||
fakeWatch.Add(service1)
|
||||
fakeWatch.Add(service2)
|
||||
|
||||
services := []*api.Service{service2, service1}
|
||||
services := []*v1.Service{service2, service1}
|
||||
handler.ValidateServices(t, services)
|
||||
handler2.ValidateServices(t, services)
|
||||
}
|
||||
@ -327,7 +327,7 @@ func TestNewEndpointsMultipleHandlersAddedAndNotified(t *testing.T) {
|
||||
|
||||
sharedInformers := informers.NewSharedInformerFactory(client, time.Minute)
|
||||
|
||||
config := NewEndpointsConfig(sharedInformers.Core().InternalVersion().Endpoints(), time.Minute)
|
||||
config := NewEndpointsConfig(sharedInformers.Core().V1().Endpoints(), time.Minute)
|
||||
handler := NewEndpointsHandlerMock()
|
||||
handler2 := NewEndpointsHandlerMock()
|
||||
config.RegisterEventHandler(handler)
|
||||
@ -335,24 +335,24 @@ func TestNewEndpointsMultipleHandlersAddedAndNotified(t *testing.T) {
|
||||
go sharedInformers.Start(stopCh)
|
||||
go config.Run(stopCh)
|
||||
|
||||
endpoints1 := &api.Endpoints{
|
||||
endpoints1 := &v1.Endpoints{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "foo"},
|
||||
Subsets: []api.EndpointSubset{{
|
||||
Addresses: []api.EndpointAddress{{IP: "1.1.1.1"}, {IP: "2.2.2.2"}},
|
||||
Ports: []api.EndpointPort{{Port: 80}},
|
||||
Subsets: []v1.EndpointSubset{{
|
||||
Addresses: []v1.EndpointAddress{{IP: "1.1.1.1"}, {IP: "2.2.2.2"}},
|
||||
Ports: []v1.EndpointPort{{Port: 80}},
|
||||
}},
|
||||
}
|
||||
endpoints2 := &api.Endpoints{
|
||||
endpoints2 := &v1.Endpoints{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "bar"},
|
||||
Subsets: []api.EndpointSubset{{
|
||||
Addresses: []api.EndpointAddress{{IP: "3.3.3.3"}, {IP: "4.4.4.4"}},
|
||||
Ports: []api.EndpointPort{{Port: 80}},
|
||||
Subsets: []v1.EndpointSubset{{
|
||||
Addresses: []v1.EndpointAddress{{IP: "3.3.3.3"}, {IP: "4.4.4.4"}},
|
||||
Ports: []v1.EndpointPort{{Port: 80}},
|
||||
}},
|
||||
}
|
||||
fakeWatch.Add(endpoints1)
|
||||
fakeWatch.Add(endpoints2)
|
||||
|
||||
endpoints := []*api.Endpoints{endpoints2, endpoints1}
|
||||
endpoints := []*v1.Endpoints{endpoints2, endpoints1}
|
||||
handler.ValidateEndpoints(t, endpoints)
|
||||
handler2.ValidateEndpoints(t, endpoints)
|
||||
}
|
||||
@ -367,7 +367,7 @@ func TestNewEndpointsMultipleHandlersAddRemoveSetAndNotified(t *testing.T) {
|
||||
|
||||
sharedInformers := informers.NewSharedInformerFactory(client, time.Minute)
|
||||
|
||||
config := NewEndpointsConfig(sharedInformers.Core().InternalVersion().Endpoints(), time.Minute)
|
||||
config := NewEndpointsConfig(sharedInformers.Core().V1().Endpoints(), time.Minute)
|
||||
handler := NewEndpointsHandlerMock()
|
||||
handler2 := NewEndpointsHandlerMock()
|
||||
config.RegisterEventHandler(handler)
|
||||
@ -375,56 +375,56 @@ func TestNewEndpointsMultipleHandlersAddRemoveSetAndNotified(t *testing.T) {
|
||||
go sharedInformers.Start(stopCh)
|
||||
go config.Run(stopCh)
|
||||
|
||||
endpoints1 := &api.Endpoints{
|
||||
endpoints1 := &v1.Endpoints{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "foo"},
|
||||
Subsets: []api.EndpointSubset{{
|
||||
Addresses: []api.EndpointAddress{{IP: "1.1.1.1"}, {IP: "2.2.2.2"}},
|
||||
Ports: []api.EndpointPort{{Port: 80}},
|
||||
Subsets: []v1.EndpointSubset{{
|
||||
Addresses: []v1.EndpointAddress{{IP: "1.1.1.1"}, {IP: "2.2.2.2"}},
|
||||
Ports: []v1.EndpointPort{{Port: 80}},
|
||||
}},
|
||||
}
|
||||
endpoints2 := &api.Endpoints{
|
||||
endpoints2 := &v1.Endpoints{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "bar"},
|
||||
Subsets: []api.EndpointSubset{{
|
||||
Addresses: []api.EndpointAddress{{IP: "3.3.3.3"}, {IP: "4.4.4.4"}},
|
||||
Ports: []api.EndpointPort{{Port: 80}},
|
||||
Subsets: []v1.EndpointSubset{{
|
||||
Addresses: []v1.EndpointAddress{{IP: "3.3.3.3"}, {IP: "4.4.4.4"}},
|
||||
Ports: []v1.EndpointPort{{Port: 80}},
|
||||
}},
|
||||
}
|
||||
fakeWatch.Add(endpoints1)
|
||||
fakeWatch.Add(endpoints2)
|
||||
|
||||
endpoints := []*api.Endpoints{endpoints2, endpoints1}
|
||||
endpoints := []*v1.Endpoints{endpoints2, endpoints1}
|
||||
handler.ValidateEndpoints(t, endpoints)
|
||||
handler2.ValidateEndpoints(t, endpoints)
|
||||
|
||||
// Add one more
|
||||
endpoints3 := &api.Endpoints{
|
||||
endpoints3 := &v1.Endpoints{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "foobar"},
|
||||
Subsets: []api.EndpointSubset{{
|
||||
Addresses: []api.EndpointAddress{{IP: "5.5.5.5"}, {IP: "6.6.6.6"}},
|
||||
Ports: []api.EndpointPort{{Port: 80}},
|
||||
Subsets: []v1.EndpointSubset{{
|
||||
Addresses: []v1.EndpointAddress{{IP: "5.5.5.5"}, {IP: "6.6.6.6"}},
|
||||
Ports: []v1.EndpointPort{{Port: 80}},
|
||||
}},
|
||||
}
|
||||
fakeWatch.Add(endpoints3)
|
||||
endpoints = []*api.Endpoints{endpoints2, endpoints1, endpoints3}
|
||||
endpoints = []*v1.Endpoints{endpoints2, endpoints1, endpoints3}
|
||||
handler.ValidateEndpoints(t, endpoints)
|
||||
handler2.ValidateEndpoints(t, endpoints)
|
||||
|
||||
// Update the "foo" service with new endpoints
|
||||
endpoints1v2 := &api.Endpoints{
|
||||
endpoints1v2 := &v1.Endpoints{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "testnamespace", Name: "foo"},
|
||||
Subsets: []api.EndpointSubset{{
|
||||
Addresses: []api.EndpointAddress{{IP: "7.7.7.7"}},
|
||||
Ports: []api.EndpointPort{{Port: 80}},
|
||||
Subsets: []v1.EndpointSubset{{
|
||||
Addresses: []v1.EndpointAddress{{IP: "7.7.7.7"}},
|
||||
Ports: []v1.EndpointPort{{Port: 80}},
|
||||
}},
|
||||
}
|
||||
fakeWatch.Modify(endpoints1v2)
|
||||
endpoints = []*api.Endpoints{endpoints2, endpoints1v2, endpoints3}
|
||||
endpoints = []*v1.Endpoints{endpoints2, endpoints1v2, endpoints3}
|
||||
handler.ValidateEndpoints(t, endpoints)
|
||||
handler2.ValidateEndpoints(t, endpoints)
|
||||
|
||||
// Remove "bar" endpoints
|
||||
fakeWatch.Delete(endpoints2)
|
||||
endpoints = []*api.Endpoints{endpoints1v2, endpoints3}
|
||||
endpoints = []*v1.Endpoints{endpoints1v2, endpoints3}
|
||||
handler.ValidateEndpoints(t, endpoints)
|
||||
handler2.ValidateEndpoints(t, endpoints)
|
||||
}
|
||||
|
Reference in New Issue
Block a user