Commit 84e2142
committed
fix(tests): wait for box.stat.net().CONNECTIONS.current to stabilise
The ConnectionPoolHeartbeatTest assertions in BasePoolTest.getActiveConnectionsCount
were flaky because tarantool's box.stat.net().CONNECTIONS.current is updated
asynchronously by the IProto worker.
When the test creates 20+ pool entries in a tight burst (pool.get() in a loop
followed by CompletableFuture.allOf().join()), netty establishes all the TCP
connections in ~50 ms, but the IProto worker in tarantool processes them serially
with 10-30 ms per connection. The test then reads the counter before the worker
has caught up, so the returned value is 5-15 below the expected count.
In the most extreme case, even the helper's own 'tt' connection is not yet
counted in CONNECTIONS.current by the time the Lua runs (because the IProto
worker updates the counter after sending the response, and the 'tt' connection
can close before the response reaches it), producing a delta of -2 to -5
relative to the baseline and failing the equality check with messages like
'expected: <20> but was: <10>' or 'expected: <13> but was: <-2>'.
Fix: run the read inside a wait-for-stable loop. The Lua sleeps on a fiber
for 50 ms between reads, which yields the IProto worker and gives it time to
accept the pending TCP connections and update the counter. The loop exits as
soon as two consecutive reads return the same value, with a 2.5 s safety
timeout.
Verified:
- ConnectionPoolHeartbeatTest: 10/10 runs pass (previously 2-5/10)
- ConnectionPoolHeartbeatTest: 5/5 full profile runs pass (17/17 tests)
- ConnectionPoolReconnectsTest: 5/5 runs pass (no regression)
- ConnectionPoolTest: 5/5 runs pass (12/12 tests, no regression)
- 24/24 unit tests pass (no regression)
- 349/349 crud integration tests pass (no regression)1 parent bba3007 commit 84e2142
1 file changed
Lines changed: 17 additions & 4 deletions
Lines changed: 17 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
100 | 113 | | |
101 | 114 | | |
102 | 115 | | |
| |||
0 commit comments