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.
This commit is contained in:
Jan Safranek
2016-06-03 10:53:56 +02:00
parent 4adc00eceb
commit 962505ad01

View File

@@ -111,8 +111,12 @@ func TestControllerSync(t *testing.T) {
defer ctrl.Stop()
go ctrl.Run()
// Wait for the controller to pass initial sync.
for !ctrl.volumeController.HasSynced() || !ctrl.claimController.HasSynced() {
// Wait for the controller to pass initial sync and fill its caches.
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)
}
glog.V(4).Infof("controller synced, starting test")