pkg/storage/cacher/cacher_whitebox_test: deflake TestConsistentReadFallback when ResilientWatchCacheInitialization is off

Kubernetes-commit: 077c35ee82e40fa808fa4b45b86d843cded3cfa3
This commit is contained in:
Lukasz Szaszkiewicz 2024-09-20 06:15:22 +02:00 committed by Kubernetes Publisher
parent f5a73ba0a4
commit bafce892d3
1 changed files with 5 additions and 0 deletions

View File

@ -381,6 +381,11 @@ apiserver_watch_cache_consistent_read_total{fallback="true", resource="pods", su
t.Fatalf("Couldn't create cacher: %v", err)
}
defer cacher.Stop()
if !utilfeature.DefaultFeatureGate.Enabled(features.ResilientWatchCacheInitialization) {
if err := cacher.ready.wait(context.Background()); err != nil {
t.Fatalf("unexpected error waiting for the cache to be ready")
}
}
if fmt.Sprintf("%d", cacher.watchCache.resourceVersion) != tc.watchCacheRV {
t.Fatalf("Expected watch cache RV to equal watchCacheRV, got: %d, want: %s", cacher.watchCache.resourceVersion, tc.watchCacheRV)