mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +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
|
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
|
// waitTest waits until all tests, controllers and other goroutines do their
|
||||||
// job and no new actions are registered for 10 milliseconds.
|
// job and no new actions are registered for 10 milliseconds.
|
||||||
func (r *volumeReactor) waitTest() {
|
func (r *volumeReactor) waitTest() {
|
||||||
@ -354,7 +360,7 @@ func (r *volumeReactor) waitTest() {
|
|||||||
for {
|
for {
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(10 * time.Millisecond)
|
||||||
changes := r.getChangeCount()
|
changes := r.getChangeCount()
|
||||||
if changes == oldChanges {
|
if changes == oldChanges && r.getOperationCount() == 0 {
|
||||||
// No changes for last 10ms -> controller must be idle.
|
// No changes for last 10ms -> controller must be idle.
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user