Fix flaking TestStoreListResourceVersion
This commit is contained in:
		@@ -2446,6 +2446,14 @@ func newTestGenericStoreRegistry(t *testing.T, scheme *runtime.Scheme, hasCacheE
 | 
				
			|||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			t.Fatalf("Couldn't create cacher: %v", err)
 | 
								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
 | 
							d := destroyFunc
 | 
				
			||||||
		s = cacher
 | 
							s = cacher
 | 
				
			||||||
		destroyFunc = func() {
 | 
							destroyFunc = func() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1358,6 +1358,11 @@ func (c *Cacher) waitUntilWatchCacheFreshAndForceAllEvents(ctx context.Context,
 | 
				
			|||||||
	return nil
 | 
						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
 | 
					// errWatcher implements watch.Interface to return a single error
 | 
				
			||||||
type errWatcher struct {
 | 
					type errWatcher struct {
 | 
				
			||||||
	result chan watch.Event
 | 
						result chan watch.Event
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -472,8 +472,8 @@ func testSetupWithEtcdServer(t *testing.T, opts ...setupOption) (context.Context
 | 
				
			|||||||
	if utilfeature.DefaultFeatureGate.Enabled(features.ResilientWatchCacheInitialization) {
 | 
						if utilfeature.DefaultFeatureGate.Enabled(features.ResilientWatchCacheInitialization) {
 | 
				
			||||||
		// The tests assume that Get/GetList/Watch calls shouldn't fail.
 | 
							// The tests assume that Get/GetList/Watch calls shouldn't fail.
 | 
				
			||||||
		// However, 429 error can now be returned if watchcache is under initialization.
 | 
							// However, 429 error can now be returned if watchcache is under initialization.
 | 
				
			||||||
		// To avoid rewriting all tests, we wait for watcache to initialize.
 | 
							// To avoid rewriting all tests, we wait for watchcache to initialize.
 | 
				
			||||||
		if err := cacher.ready.wait(ctx); err != nil {
 | 
							if err := cacher.Wait(ctx); err != nil {
 | 
				
			||||||
			t.Fatal(err)
 | 
								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.
 | 
							// The tests assume that Get/GetList/Watch calls shouldn't fail.
 | 
				
			||||||
		// However, 429 error can now be returned if watchcache is under initialization.
 | 
							// However, 429 error can now be returned if watchcache is under initialization.
 | 
				
			||||||
		// To avoid rewriting all tests, we wait for watcache to initialize.
 | 
							// 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
 | 
								return nil, storage.APIObjectVersioner{}, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user