@@ -287,7 +287,7 @@ func TestEvents(t *testing.T) {
287
287
288
288
// Test for Added event.
289
289
{
290
- _ , err := store .getAllEventsSince (1 , storage.ListOptions {})
290
+ _ , err := store .getAllEventsSince (1 , storage.ListOptions {Predicate : storage . Everything })
291
291
if err == nil {
292
292
t .Errorf ("expected error too old" )
293
293
}
@@ -296,7 +296,7 @@ func TestEvents(t *testing.T) {
296
296
}
297
297
}
298
298
{
299
- result , err := store .getAllEventsSince (2 , storage.ListOptions {})
299
+ result , err := store .getAllEventsSince (2 , storage.ListOptions {Predicate : storage . Everything })
300
300
if err != nil {
301
301
t .Errorf ("unexpected error: %v" , err )
302
302
}
@@ -320,13 +320,13 @@ func TestEvents(t *testing.T) {
320
320
321
321
// Test with not full cache.
322
322
{
323
- _ , err := store .getAllEventsSince (1 , storage.ListOptions {})
323
+ _ , err := store .getAllEventsSince (1 , storage.ListOptions {Predicate : storage . Everything })
324
324
if err == nil {
325
325
t .Errorf ("expected error too old" )
326
326
}
327
327
}
328
328
{
329
- result , err := store .getAllEventsSince (3 , storage.ListOptions {})
329
+ result , err := store .getAllEventsSince (3 , storage.ListOptions {Predicate : storage . Everything })
330
330
if err != nil {
331
331
t .Errorf ("unexpected error: %v" , err )
332
332
}
@@ -354,13 +354,13 @@ func TestEvents(t *testing.T) {
354
354
355
355
// Test with full cache - there should be elements from 5 to 9.
356
356
{
357
- _ , err := store .getAllEventsSince (3 , storage.ListOptions {})
357
+ _ , err := store .getAllEventsSince (3 , storage.ListOptions {Predicate : storage . Everything })
358
358
if err == nil {
359
359
t .Errorf ("expected error too old" )
360
360
}
361
361
}
362
362
{
363
- result , err := store .getAllEventsSince (4 , storage.ListOptions {})
363
+ result , err := store .getAllEventsSince (4 , storage.ListOptions {Predicate : storage . Everything })
364
364
if err != nil {
365
365
t .Errorf ("unexpected error: %v" , err )
366
366
}
@@ -379,7 +379,7 @@ func TestEvents(t *testing.T) {
379
379
store .Delete (makeTestPod ("pod" , uint64 (10 )))
380
380
381
381
{
382
- result , err := store .getAllEventsSince (9 , storage.ListOptions {})
382
+ result , err := store .getAllEventsSince (9 , storage.ListOptions {Predicate : storage . Everything })
383
383
if err != nil {
384
384
t .Errorf ("unexpected error: %v" , err )
385
385
}
@@ -410,13 +410,13 @@ func TestMarker(t *testing.T) {
410
410
makeTestPod ("pod2" , 9 ),
411
411
}, "9" )
412
412
413
- _ , err := store .getAllEventsSince (8 , storage.ListOptions {})
413
+ _ , err := store .getAllEventsSince (8 , storage.ListOptions {Predicate : storage . Everything })
414
414
if err == nil || ! strings .Contains (err .Error (), "too old resource version" ) {
415
415
t .Errorf ("unexpected error: %v" , err )
416
416
}
417
417
// Getting events from 8 should return no events,
418
418
// even though there is a marker there.
419
- result , err := store .getAllEventsSince (9 , storage.ListOptions {})
419
+ result , err := store .getAllEventsSince (9 , storage.ListOptions {Predicate : storage . Everything })
420
420
if err != nil {
421
421
t .Fatalf ("unexpected error: %v" , err )
422
422
}
@@ -427,7 +427,7 @@ func TestMarker(t *testing.T) {
427
427
pod := makeTestPod ("pods" , 12 )
428
428
store .Add (pod )
429
429
// Getting events from 8 should still work and return one event.
430
- result , err = store .getAllEventsSince (9 , storage.ListOptions {})
430
+ result , err = store .getAllEventsSince (9 , storage.ListOptions {Predicate : storage . Everything })
431
431
if err != nil {
432
432
t .Fatalf ("unexpected error: %v" , err )
433
433
}
@@ -466,7 +466,7 @@ func TestWaitUntilFreshAndList(t *testing.T) {
466
466
}()
467
467
468
468
// list by empty MatchValues.
469
- resp , indexUsed , err := store .WaitUntilFreshAndList (ctx , 5 , "prefix/" , nil )
469
+ resp , indexUsed , err := store .WaitUntilFreshAndList (ctx , 5 , "prefix/" , storage. ListOptions { Predicate : storage . Everything } )
470
470
if err != nil {
471
471
t .Fatalf ("unexpected error: %v" , err )
472
472
}
@@ -481,11 +481,15 @@ func TestWaitUntilFreshAndList(t *testing.T) {
481
481
}
482
482
483
483
// list by label index.
484
- matchValues := []storage.MatchValue {
485
- {IndexName : "l:label" , Value : "value1" },
486
- {IndexName : "f:spec.nodeName" , Value : "node2" },
487
- }
488
- resp , indexUsed , err = store .WaitUntilFreshAndList (ctx , 5 , "prefix/" , matchValues )
484
+ resp , indexUsed , err = store .WaitUntilFreshAndList (ctx , 5 , "prefix/" , storage.ListOptions {Predicate : storage.SelectionPredicate {
485
+ Label : labels .SelectorFromSet (map [string ]string {
486
+ "label" : "value1" ,
487
+ }),
488
+ Field : fields .SelectorFromSet (map [string ]string {
489
+ "spec.nodeName" : "node2" ,
490
+ }),
491
+ IndexLabels : []string {"label" },
492
+ }})
489
493
if err != nil {
490
494
t .Fatalf ("unexpected error: %v" , err )
491
495
}
@@ -500,11 +504,15 @@ func TestWaitUntilFreshAndList(t *testing.T) {
500
504
}
501
505
502
506
// list with spec.nodeName index.
503
- matchValues = []storage.MatchValue {
504
- {IndexName : "l:not-exist-label" , Value : "whatever" },
505
- {IndexName : "f:spec.nodeName" , Value : "node2" },
506
- }
507
- resp , indexUsed , err = store .WaitUntilFreshAndList (ctx , 5 , "prefix/" , matchValues )
507
+ resp , indexUsed , err = store .WaitUntilFreshAndList (ctx , 5 , "prefix/" , storage.ListOptions {Predicate : storage.SelectionPredicate {
508
+ Label : labels .SelectorFromSet (map [string ]string {
509
+ "not-exist-label" : "whatever" ,
510
+ }),
511
+ Field : fields .SelectorFromSet (map [string ]string {
512
+ "spec.nodeName" : "node2" ,
513
+ }),
514
+ IndexFields : []string {"spec.nodeName" },
515
+ }})
508
516
if err != nil {
509
517
t .Fatalf ("unexpected error: %v" , err )
510
518
}
@@ -519,10 +527,13 @@ func TestWaitUntilFreshAndList(t *testing.T) {
519
527
}
520
528
521
529
// list with index not exists.
522
- matchValues = []storage.MatchValue {
523
- {IndexName : "l:not-exist-label" , Value : "whatever" },
524
- }
525
- resp , indexUsed , err = store .WaitUntilFreshAndList (ctx , 5 , "prefix/" , matchValues )
530
+ resp , indexUsed , err = store .WaitUntilFreshAndList (ctx , 5 , "prefix/" , storage.ListOptions {Predicate : storage.SelectionPredicate {
531
+ Label : labels .SelectorFromSet (map [string ]string {
532
+ "not-exist-label" : "whatever" ,
533
+ }),
534
+ Field : fields .Everything (),
535
+ IndexLabels : []string {"label" },
536
+ }})
526
537
if err != nil {
527
538
t .Fatalf ("unexpected error: %v" , err )
528
539
}
@@ -550,7 +561,7 @@ func TestWaitUntilFreshAndListFromCache(t *testing.T) {
550
561
}()
551
562
552
563
// list from future revision. Requires watch cache to request bookmark to get it.
553
- resp , indexUsed , err := store .WaitUntilFreshAndList (ctx , 3 , "prefix/" , nil )
564
+ resp , indexUsed , err := store .WaitUntilFreshAndList (ctx , 3 , "prefix/" , storage. ListOptions { Predicate : storage . Everything } )
554
565
if err != nil {
555
566
t .Fatalf ("unexpected error: %v" , err )
556
567
}
@@ -630,7 +641,7 @@ func TestWaitUntilFreshAndListTimeout(t *testing.T) {
630
641
store .Add (makeTestPod ("bar" , 4 ))
631
642
}()
632
643
633
- _ , _ , err := store .WaitUntilFreshAndList (ctx , 4 , "" , nil )
644
+ _ , _ , err := store .WaitUntilFreshAndList (ctx , 4 , "" , storage. ListOptions { Predicate : storage . Everything } )
634
645
if ! errors .IsTimeout (err ) {
635
646
t .Errorf ("expected timeout error but got: %v" , err )
636
647
}
@@ -659,7 +670,7 @@ func TestReflectorForWatchCache(t *testing.T) {
659
670
defer store .Stop ()
660
671
661
672
{
662
- resp , _ , err := store .WaitUntilFreshAndList (ctx , 0 , "" , nil )
673
+ resp , _ , err := store .WaitUntilFreshAndList (ctx , 0 , "" , storage. ListOptions { Predicate : storage . Everything } )
663
674
if err != nil {
664
675
t .Fatalf ("unexpected error: %v" , err )
665
676
}
@@ -682,7 +693,7 @@ func TestReflectorForWatchCache(t *testing.T) {
682
693
r .ListAndWatch (wait .NeverStop )
683
694
684
695
{
685
- resp , _ , err := store .WaitUntilFreshAndList (ctx , 10 , "" , nil )
696
+ resp , _ , err := store .WaitUntilFreshAndList (ctx , 10 , "" , storage. ListOptions { Predicate : storage . Everything } )
686
697
if err != nil {
687
698
t .Fatalf ("unexpected error: %v" , err )
688
699
}
@@ -994,7 +1005,7 @@ func TestCacheIncreaseDoesNotBreakWatch(t *testing.T) {
994
1005
// Force cache resize.
995
1006
addEvent ("key4" , 50 , later .Add (time .Second ))
996
1007
997
- _ , err := store .getAllEventsSince (15 , storage.ListOptions {})
1008
+ _ , err := store .getAllEventsSince (15 , storage.ListOptions {Predicate : storage . Everything })
998
1009
if err == nil || ! strings .Contains (err .Error (), "too old resource version" ) {
999
1010
t .Errorf ("unexpected error: %v" , err )
1000
1011
}
0 commit comments