chore: stabilize health test
It was failing randomly due to Sleep being insufficient for the desired condition being reached. Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
This commit is contained in:
parent
8362f58e7a
commit
2f0698def2
@ -27,11 +27,11 @@ func (suite *CheckSuite) TestHealthy() {
|
||||
Timeout: time.Millisecond,
|
||||
}
|
||||
|
||||
var called int
|
||||
var called uint32
|
||||
|
||||
// nolint: unparam
|
||||
check := func(context.Context) error {
|
||||
called++
|
||||
atomic.AddUint32(&called, 1)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -45,7 +45,13 @@ func (suite *CheckSuite) TestHealthy() {
|
||||
errCh <- health.Run(ctx, &settings, &state, check)
|
||||
}()
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
for i := 0; i < 20; i++ {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
|
||||
if atomic.LoadUint32(&called) > 2 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
ctxCancel()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user