[#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:
Dmitrii Stepanov 2025-04-10 16:04:04 +03:00
parent 64c1392513
commit e06ecacf57
Signed by: dstepanov-yadro
GPG key ID: 237AF1A763293BC0
3 changed files with 29 additions and 11 deletions

View file

@ -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()
}
}