Skip to content

Commit

Permalink
[chore] use require.Eventually instead of time.Sleep to retry checks (o…
Browse files Browse the repository at this point in the history
…pen-telemetry#31006)

Do not use time.Sleep in tests. Use require.Eventually instead or
channels.
  • Loading branch information
atoulme authored Feb 1, 2024
1 parent f12f0ad commit e0a18f0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions connector/failoverconnector/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,11 @@ func TestTracesWithFailoverRecovery(t *testing.T) {
// Simulate recovery of exporter
failoverConnector.failover.ModifyConsumerAtIndex(0, consumertest.NewNop())

time.Sleep(100 * time.Millisecond)

_, ch, ok = failoverConnector.failover.getCurrentConsumer()
idx = failoverConnector.failover.pS.ChannelIndex(ch)
assert.True(t, ok)
require.Equal(t, idx, 0)
require.Eventually(t, func() bool {
_, ch, ok = failoverConnector.failover.getCurrentConsumer()
idx = failoverConnector.failover.pS.ChannelIndex(ch)
return ok && idx == 0
}, 3*time.Second, 100*time.Millisecond)
}

func sampleTrace() ptrace.Traces {
Expand Down

0 comments on commit e0a18f0

Please sign in to comment.