@@ -36,6 +36,8 @@ import (
36
36
utiltesting "k8s.io/kubernetes/pkg/util/testing"
37
37
)
38
38
39
+ var alwaysReady = func () bool { return true }
40
+
39
41
func addPods (store cache.Store , namespace string , nPods int , nPorts int , nNotReady int ) {
40
42
for i := 0 ; i < nPods + nNotReady ; i ++ {
41
43
p := & api.Pod {
@@ -107,6 +109,7 @@ func TestSyncEndpointsItemsPreserveNoSelector(t *testing.T) {
107
109
// defer testServer.Close()
108
110
client := clientset .NewForConfigOrDie (& restclient.Config {Host : testServer .URL , ContentConfig : restclient.ContentConfig {GroupVersion : testapi .Default .GroupVersion ()}})
109
111
endpoints := NewEndpointController (client , controller .NoResyncPeriodFunc )
112
+ endpoints .podStoreSynced = alwaysReady
110
113
endpoints .serviceStore .Store .Add (& api.Service {
111
114
ObjectMeta : api.ObjectMeta {Name : "foo" , Namespace : ns },
112
115
Spec : api.ServiceSpec {Ports : []api.ServicePort {{Port : 80 }}},
@@ -140,6 +143,7 @@ func TestCheckLeftoverEndpoints(t *testing.T) {
140
143
// defer testServer.Close()
141
144
client := clientset .NewForConfigOrDie (& restclient.Config {Host : testServer .URL , ContentConfig : restclient.ContentConfig {GroupVersion : testapi .Default .GroupVersion ()}})
142
145
endpoints := NewEndpointController (client , controller .NoResyncPeriodFunc )
146
+ endpoints .podStoreSynced = alwaysReady
143
147
endpoints .checkLeftoverEndpoints ()
144
148
145
149
if e , a := 1 , endpoints .queue .Len (); e != a {
@@ -169,6 +173,8 @@ func TestSyncEndpointsProtocolTCP(t *testing.T) {
169
173
// defer testServer.Close()
170
174
client := clientset .NewForConfigOrDie (& restclient.Config {Host : testServer .URL , ContentConfig : restclient.ContentConfig {GroupVersion : testapi .Default .GroupVersion ()}})
171
175
endpoints := NewEndpointController (client , controller .NoResyncPeriodFunc )
176
+ endpoints .podStoreSynced = alwaysReady
177
+
172
178
addPods (endpoints .podStore .Store , ns , 1 , 1 , 0 )
173
179
endpoints .serviceStore .Store .Add (& api.Service {
174
180
ObjectMeta : api.ObjectMeta {Name : "foo" , Namespace : ns },
@@ -211,6 +217,7 @@ func TestSyncEndpointsProtocolUDP(t *testing.T) {
211
217
// defer testServer.Close()
212
218
client := clientset .NewForConfigOrDie (& restclient.Config {Host : testServer .URL , ContentConfig : restclient.ContentConfig {GroupVersion : testapi .Default .GroupVersion ()}})
213
219
endpoints := NewEndpointController (client , controller .NoResyncPeriodFunc )
220
+ endpoints .podStoreSynced = alwaysReady
214
221
addPods (endpoints .podStore .Store , ns , 1 , 1 , 0 )
215
222
endpoints .serviceStore .Store .Add (& api.Service {
216
223
ObjectMeta : api.ObjectMeta {Name : "foo" , Namespace : ns },
@@ -250,6 +257,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAll(t *testing.T) {
250
257
// defer testServer.Close()
251
258
client := clientset .NewForConfigOrDie (& restclient.Config {Host : testServer .URL , ContentConfig : restclient.ContentConfig {GroupVersion : testapi .Default .GroupVersion ()}})
252
259
endpoints := NewEndpointController (client , controller .NoResyncPeriodFunc )
260
+ endpoints .podStoreSynced = alwaysReady
253
261
addPods (endpoints .podStore .Store , ns , 1 , 1 , 0 )
254
262
endpoints .serviceStore .Store .Add (& api.Service {
255
263
ObjectMeta : api.ObjectMeta {Name : "foo" , Namespace : ns },
@@ -288,6 +296,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAllNotReady(t *testing.T) {
288
296
// defer testServer.Close()
289
297
client := clientset .NewForConfigOrDie (& restclient.Config {Host : testServer .URL , ContentConfig : restclient.ContentConfig {GroupVersion : testapi .Default .GroupVersion ()}})
290
298
endpoints := NewEndpointController (client , controller .NoResyncPeriodFunc )
299
+ endpoints .podStoreSynced = alwaysReady
291
300
addPods (endpoints .podStore .Store , ns , 0 , 1 , 1 )
292
301
endpoints .serviceStore .Store .Add (& api.Service {
293
302
ObjectMeta : api.ObjectMeta {Name : "foo" , Namespace : ns },
@@ -326,6 +335,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAllMixed(t *testing.T) {
326
335
// defer testServer.Close()
327
336
client := clientset .NewForConfigOrDie (& restclient.Config {Host : testServer .URL , ContentConfig : restclient.ContentConfig {GroupVersion : testapi .Default .GroupVersion ()}})
328
337
endpoints := NewEndpointController (client , controller .NoResyncPeriodFunc )
338
+ endpoints .podStoreSynced = alwaysReady
329
339
addPods (endpoints .podStore .Store , ns , 1 , 1 , 1 )
330
340
endpoints .serviceStore .Store .Add (& api.Service {
331
341
ObjectMeta : api.ObjectMeta {Name : "foo" , Namespace : ns },
@@ -368,6 +378,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) {
368
378
// defer testServer.Close()
369
379
client := clientset .NewForConfigOrDie (& restclient.Config {Host : testServer .URL , ContentConfig : restclient.ContentConfig {GroupVersion : testapi .Default .GroupVersion ()}})
370
380
endpoints := NewEndpointController (client , controller .NoResyncPeriodFunc )
381
+ endpoints .podStoreSynced = alwaysReady
371
382
addPods (endpoints .podStore .Store , ns , 1 , 1 , 0 )
372
383
endpoints .serviceStore .Store .Add (& api.Service {
373
384
ObjectMeta : api.ObjectMeta {Name : "foo" , Namespace : ns },
@@ -409,6 +420,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) {
409
420
// defer testServer.Close()
410
421
client := clientset .NewForConfigOrDie (& restclient.Config {Host : testServer .URL , ContentConfig : restclient.ContentConfig {GroupVersion : testapi .Default .GroupVersion ()}})
411
422
endpoints := NewEndpointController (client , controller .NoResyncPeriodFunc )
423
+ endpoints .podStoreSynced = alwaysReady
412
424
addPods (endpoints .podStore .Store , api .NamespaceDefault , 1 , 1 , 0 )
413
425
endpoints .serviceStore .Store .Add (& api.Service {
414
426
ObjectMeta : api.ObjectMeta {Name : "foo" , Namespace : api .NamespaceDefault },
@@ -429,6 +441,7 @@ func TestSyncEndpointsItems(t *testing.T) {
429
441
// defer testServer.Close()
430
442
client := clientset .NewForConfigOrDie (& restclient.Config {Host : testServer .URL , ContentConfig : restclient.ContentConfig {GroupVersion : testapi .Default .GroupVersion ()}})
431
443
endpoints := NewEndpointController (client , controller .NoResyncPeriodFunc )
444
+ endpoints .podStoreSynced = alwaysReady
432
445
addPods (endpoints .podStore .Store , ns , 3 , 2 , 0 )
433
446
addPods (endpoints .podStore .Store , "blah" , 5 , 2 , 0 ) // make sure these aren't found!
434
447
endpoints .serviceStore .Store .Add (& api.Service {
@@ -472,6 +485,7 @@ func TestSyncEndpointsItemsWithLabels(t *testing.T) {
472
485
// defer testServer.Close()
473
486
client := clientset .NewForConfigOrDie (& restclient.Config {Host : testServer .URL , ContentConfig : restclient.ContentConfig {GroupVersion : testapi .Default .GroupVersion ()}})
474
487
endpoints := NewEndpointController (client , controller .NoResyncPeriodFunc )
488
+ endpoints .podStoreSynced = alwaysReady
475
489
addPods (endpoints .podStore .Store , ns , 3 , 2 , 0 )
476
490
serviceLabels := map [string ]string {"foo" : "bar" }
477
491
endpoints .serviceStore .Store .Add (& api.Service {
@@ -533,6 +547,7 @@ func TestSyncEndpointsItemsPreexistingLabelsChange(t *testing.T) {
533
547
// defer testServer.Close()
534
548
client := clientset .NewForConfigOrDie (& restclient.Config {Host : testServer .URL , ContentConfig : restclient.ContentConfig {GroupVersion : testapi .Default .GroupVersion ()}})
535
549
endpoints := NewEndpointController (client , controller .NoResyncPeriodFunc )
550
+ endpoints .podStoreSynced = alwaysReady
536
551
addPods (endpoints .podStore .Store , ns , 1 , 1 , 0 )
537
552
serviceLabels := map [string ]string {"baz" : "blah" }
538
553
endpoints .serviceStore .Store .Add (& api.Service {
0 commit comments