Close listener at last sequence to avoid flakiness
This commit is contained in:
parent
c3d428a16e
commit
206427c4ea
1 changed files with 6 additions and 1 deletions
|
|
@ -481,7 +481,7 @@ func TestServiceTCPHealthChecker_Launch(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for all health checks to complete deterministically
|
// Wait for all health checks to complete deterministically
|
||||||
for range test.server.StatusSequence {
|
for i := range test.server.StatusSequence {
|
||||||
test.server.Next()
|
test.server.Next()
|
||||||
|
|
||||||
initialUpserted := lb.numUpsertedServers
|
initialUpserted := lb.numUpsertedServers
|
||||||
|
|
@ -490,6 +490,11 @@ func TestServiceTCPHealthChecker_Launch(t *testing.T) {
|
||||||
for time.Now().Before(deadline) {
|
for time.Now().Before(deadline) {
|
||||||
time.Sleep(5 * time.Millisecond)
|
time.Sleep(5 * time.Millisecond)
|
||||||
if lb.numUpsertedServers > initialUpserted || lb.numRemovedServers > initialRemoved {
|
if lb.numUpsertedServers > initialUpserted || lb.numRemovedServers > initialRemoved {
|
||||||
|
// Stop the health checker immediately after the last expected sequence completes
|
||||||
|
// to prevent extra health checks from firing and modifying the counters.
|
||||||
|
if i == len(test.server.StatusSequence)-1 {
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue