@@ -257,7 +257,7 @@ func TestListResourceVersionMatch(t *testing.T) {
257
257
}
258
258
259
259
func TestNamespaceScopedList (t * testing.T ) {
260
- ctx , cacher , terminate := testSetup (t , withSpecNodeNameIndexerFuncs )
260
+ ctx , cacher , terminate := testSetup (t , withNodeNameAndNamespaceIndex )
261
261
t .Cleanup (terminate )
262
262
storagetesting .RunTestNamespaceScopedList (ctx , t , cacher )
263
263
}
@@ -355,13 +355,13 @@ func TestWatchInitializationSignal(t *testing.T) {
355
355
}
356
356
357
357
func TestClusterScopedWatch (t * testing.T ) {
358
- ctx , cacher , terminate := testSetup (t , withClusterScopedKeyFunc , withSpecNodeNameIndexerFuncs )
358
+ ctx , cacher , terminate := testSetup (t , withClusterScopedKeyFunc , withNodeNameAndNamespaceIndex )
359
359
t .Cleanup (terminate )
360
360
storagetesting .RunTestClusterScopedWatch (ctx , t , cacher )
361
361
}
362
362
363
363
func TestNamespaceScopedWatch (t * testing.T ) {
364
- ctx , cacher , terminate := testSetup (t , withSpecNodeNameIndexerFuncs )
364
+ ctx , cacher , terminate := testSetup (t , withNodeNameAndNamespaceIndex )
365
365
t .Cleanup (terminate )
366
366
storagetesting .RunTestNamespaceScopedWatch (ctx , t , cacher )
367
367
}
@@ -432,7 +432,8 @@ func withClusterScopedKeyFunc(options *setupOptions) {
432
432
}
433
433
}
434
434
435
- func withSpecNodeNameIndexerFuncs (options * setupOptions ) {
435
+ // mirror indexer configuration from pkg/registry/core/pod/strategy.go
436
+ func withNodeNameAndNamespaceIndex (options * setupOptions ) {
436
437
options .indexerFuncs = map [string ]storage.IndexerFunc {
437
438
"spec.nodeName" : func (obj runtime.Object ) string {
438
439
pod , ok := obj .(* example.Pod )
@@ -447,6 +448,10 @@ func withSpecNodeNameIndexerFuncs(options *setupOptions) {
447
448
pod := obj .(* example.Pod )
448
449
return []string {pod .Spec .NodeName }, nil
449
450
},
451
+ "f:metadata.namespace" : func (obj interface {}) ([]string , error ) {
452
+ pod := obj .(* example.Pod )
453
+ return []string {pod .ObjectMeta .Namespace }, nil
454
+ },
450
455
}
451
456
}
452
457
@@ -571,7 +576,7 @@ func BenchmarkStoreCreateList(b *testing.B) {
571
576
b .Run (fmt .Sprintf ("Indexed=%v" , useIndex ), func (b * testing.B ) {
572
577
opts := []setupOption {}
573
578
if useIndex {
574
- opts = append (opts , withSpecNodeNameIndexerFuncs )
579
+ opts = append (opts , withNodeNameAndNamespaceIndex )
575
580
}
576
581
ctx , cacher , _ , terminate := testSetupWithEtcdServer (b , opts ... )
577
582
b .Cleanup (terminate )
@@ -627,7 +632,7 @@ func BenchmarkStoreList(b *testing.B) {
627
632
for _ , store := range storeOptions {
628
633
b .Run (fmt .Sprintf ("Store=%s" , store .name ), func (b * testing.B ) {
629
634
featuregatetesting .SetFeatureGateDuringTest (b , utilfeature .DefaultFeatureGate , features .BtreeWatchCache , store .btreeEnabled )
630
- ctx , cacher , _ , terminate := testSetupWithEtcdServer (b , withSpecNodeNameIndexerFuncs )
635
+ ctx , cacher , _ , terminate := testSetupWithEtcdServer (b , withNodeNameAndNamespaceIndex )
631
636
b .Cleanup (terminate )
632
637
var out example.Pod
633
638
for _ , pod := range data .Pods {
0 commit comments