mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +00:00
Fix flaking TestStoreListResourceVersion
This commit is contained in:
parent
1815a14c32
commit
e59988d769
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user