forked from TrueCloudLab/frostfs-node
[#1705] engine: Use condition var for evacuation unit tests
To know exactly when the evacuation was completed, a conditional variable was added. Closes #1705 Change-Id: I86f6d7d2ad2b9759905b6b5e9341008cb74f5dfd Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
64c1392513
commit
e06ecacf57
3 changed files with 29 additions and 11 deletions
|
@ -204,11 +204,10 @@ func TestEvacuateShardObjects(t *testing.T) {
|
|||
func testWaitForEvacuationCompleted(t *testing.T, e *StorageEngine) *EvacuationState {
|
||||
var st *EvacuationState
|
||||
var err error
|
||||
require.Eventually(t, func() bool {
|
||||
st, err = e.GetEvacuationState(context.Background())
|
||||
require.NoError(t, err)
|
||||
return st.ProcessingStatus() == EvacuateProcessStateCompleted
|
||||
}, 6*time.Second, 10*time.Millisecond)
|
||||
e.evacuateLimiter.waitForCompleted()
|
||||
st, err = e.GetEvacuationState(context.Background())
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, EvacuateProcessStateCompleted, st.ProcessingStatus())
|
||||
return st
|
||||
}
|
||||
|
||||
|
@ -817,3 +816,12 @@ func TestEvacuateShardObjectsRepOneOnlyBench(t *testing.T) {
|
|||
t.Logf("evacuate took %v\n", time.Since(start))
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func (l *evacuationLimiter) waitForCompleted() {
|
||||
l.guard.Lock()
|
||||
defer l.guard.Unlock()
|
||||
|
||||
for l.state.processState != EvacuateProcessStateCompleted {
|
||||
l.statusCond.Wait()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue