Merge pull request #26772 from jsafrane/flake-controller-cache-empty

Automatic merge from submit-queue

Wait for all volumes/claims to get synced in unit test.

Controller.HasSynced() returns true when all initial claims/volumes were sent
to appropriate goroutines, not when the goroutine has actually processed them.

Fixes #26712
pull/6/head
k8s-merge-robot 2016-06-03 17:05:22 -07:00
commit 4877153727
1 changed files with 6 additions and 2 deletions

View File

@ -111,8 +111,12 @@ func TestControllerSync(t *testing.T) {
defer ctrl.Stop() defer ctrl.Stop()
go ctrl.Run() go ctrl.Run()
// Wait for the controller to pass initial sync. // Wait for the controller to pass initial sync and fill its caches.
for !ctrl.volumeController.HasSynced() || !ctrl.claimController.HasSynced() { for !ctrl.volumeController.HasSynced() ||
!ctrl.claimController.HasSynced() ||
len(ctrl.claims.ListKeys()) < len(test.initialClaims) ||
len(ctrl.volumes.store.ListKeys()) < len(test.initialVolumes) {
time.Sleep(10 * time.Millisecond) time.Sleep(10 * time.Millisecond)
} }
glog.V(4).Infof("controller synced, starting test") glog.V(4).Infof("controller synced, starting test")