Merge pull request #125450 from mauri870/hotfix/flaky-TestStoreListResourceVersion

Fix flaking TestStoreListResourceVersion
This commit is contained in:
Kubernetes Prow Robot 2024-06-12 06:32:11 -07:00 committed by GitHub
commit 4630bef303
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 3 deletions

View File

@ -2446,6 +2446,14 @@ func newTestGenericStoreRegistry(t *testing.T, scheme *runtime.Scheme, hasCacheE
if err != nil {
t.Fatalf("Couldn't create cacher: %v", err)
}
if utilfeature.DefaultFeatureGate.Enabled(features.ResilientWatchCacheInitialization) {
// The tests assume that Get/GetList/Watch calls shouldn't fail.
// However, 429 error can now be returned if watchcache is under initialization.
// To avoid rewriting all tests, we wait for watchcache to initialize.
if err := cacher.Wait(context.Background()); err != nil {
t.Fatal(err)
}
}
d := destroyFunc
s = cacher
destroyFunc = func() {

View File

@ -1358,6 +1358,11 @@ func (c *Cacher) waitUntilWatchCacheFreshAndForceAllEvents(ctx context.Context,
return nil
}
// Wait blocks until the cacher is Ready or Stopped, it returns an error if Stopped.
func (c *Cacher) Wait(ctx context.Context) error {
return c.ready.wait(ctx)
}
// errWatcher implements watch.Interface to return a single error
type errWatcher struct {
result chan watch.Event

View File

@ -472,8 +472,8 @@ func testSetupWithEtcdServer(t *testing.T, opts ...setupOption) (context.Context
if utilfeature.DefaultFeatureGate.Enabled(features.ResilientWatchCacheInitialization) {
// The tests assume that Get/GetList/Watch calls shouldn't fail.
// However, 429 error can now be returned if watchcache is under initialization.
// To avoid rewriting all tests, we wait for watcache to initialize.
if err := cacher.ready.wait(ctx); err != nil {
// To avoid rewriting all tests, we wait for watchcache to initialize.
if err := cacher.Wait(ctx); err != nil {
t.Fatal(err)
}
}

View File

@ -93,7 +93,7 @@ func newTestCacher(s storage.Interface) (*Cacher, storage.Versioner, error) {
// The tests assume that Get/GetList/Watch calls shouldn't fail.
// However, 429 error can now be returned if watchcache is under initialization.
// To avoid rewriting all tests, we wait for watcache to initialize.
if err := cacher.ready.wait(context.Background()); err != nil {
if err := cacher.Wait(context.Background()); err != nil {
return nil, storage.APIObjectVersioner{}, err
}
}