unit test framework: Wait for all running operations to finish during all tests.

This commit is contained in:
Jan Safranek 2016-05-17 14:55:19 +02:00
parent cf68370371
commit 56cae2dc20

View File

@ -345,6 +345,12 @@ func (r *volumeReactor) getChangeCount() int {
return r.changedSinceLastSync
}
func (r *volumeReactor) getOperationCount() int {
r.ctrl.runningOperationsMapLock.Lock()
defer r.ctrl.runningOperationsMapLock.Unlock()
return len(r.ctrl.runningOperations)
}
// waitTest waits until all tests, controllers and other goroutines do their
// job and no new actions are registered for 10 milliseconds.
func (r *volumeReactor) waitTest() {
@ -354,7 +360,7 @@ func (r *volumeReactor) waitTest() {
for {
time.Sleep(10 * time.Millisecond)
changes := r.getChangeCount()
if changes == oldChanges {
if changes == oldChanges && r.getOperationCount() == 0 {
// No changes for last 10ms -> controller must be idle.
break
}