mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
unit test framework: Wait for all running operations to finish during all tests.
This commit is contained in:
parent
cf68370371
commit
56cae2dc20
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user