You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: Non-Deterministic Test shouldHonourConfiguredUpstreamConnectTimeout #5111
java.lang.AssertionError:
Expecting actual:
1.983740463S
to be greater than or equal to:
2S
at io.kroxylicious.it.ResilienceIT.shouldHonourConfiguredUpstreamConnectTimeout(ResilienceIT.java:231)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
The test validates that a configured 2-second upstream connect timeout is honored. The measured timeout was 1.983740463 seconds—only 16 milliseconds short of the expected value. This type of failure is typical of timing-sensitive tests where system load, thread scheduling, or other timing variations cause the measurement to fall just below the threshold.
The new integration test for this issue fails intermittently on CI, never locally:
Expecting actual: 1.983740463S
to be greater than or equal to: 2S
Cause: the test times a window that starts after the thing it's measuring.
The proxy's dial to the blackholed address is already in flight before System.nanoTime() is read. Measured by scraping the connect-initiation counter immediately after tester.admin() returns, with no describeCluster() call at all:
moment
kroxylicious_proxy_to_server_connections_total
..._errors_total
right after tester.admin()
1.0
0.0
+3s, still no describeCluster()
2.0
1.0
proxyToServerConnectionCounter.increment() is the first statement in ServerConnectionStateMachine#connect, so that counter marks initiation rather than completion — the dial starts during AdminClient construction, and the connect fails on its own clock without the describe call driving it.
So elapsed = CONNECT_TIMEOUT − gap + reconnect, where gap is the time between the dial starting and the clock being read. The gap is small — tester.admin() returns in ~1ms, getManagementClient() in ~0.2ms — but it's positive, and it sits on the wrong side of the inequality: anything that stalls in that window makes elapsedsmaller.
That leaves ~120ms of margin. Locally I measured 2123–2162ms over five runs, so it never crossed zero — but five runs of identical code also produced one outlier at 2368ms against a 2147ms minimum, so >200ms of jitter is reachable in a single JVM. On a loaded CI runner that margin isn't safe, which is why this only shows up there.
Fix: read the clock before anything that can initiate an upstream connect.
The clock now precedes the dial, so elapsed > CONNECT_TIMEOUT + reconnect and the floor holds by construction — any pause anywhere only increases elapsed. Measured 2146–2161ms locally, well inside the 5s completion budget.
To be clear what this does and doesn't establish: the mechanism is confirmed by measurement, and the fix removes the failure mode by inverting the inequality rather than widening a margin. I could not reproduce the CI failure locally, so I haven't demonstrated the fix prevents that specific run — but the floor is no longer sensitive to jitter at all.
Activity
AdityaThakur1998 commentedon Oct 15, 2026
Can I get assignment ?
AdityaThakur1998 commentedon Oct 16, 2026
Flaky integration test:
shouldHonourConfiguredUpstreamConnectTimeoutThe new integration test for this issue fails intermittently on CI, never locally:
Cause: the test times a window that starts after the thing it's measuring.
The proxy's dial to the blackholed address is already in flight before
System.nanoTime()is read. Measured by scraping the connect-initiation counter immediately aftertester.admin()returns, with nodescribeCluster()call at all:kroxylicious_proxy_to_server_connections_total..._errors_totaltester.admin()describeCluster()proxyToServerConnectionCounter.increment()is the first statement inServerConnectionStateMachine#connect, so that counter marks initiation rather than completion — the dial starts during AdminClient construction, and the connect fails on its own clock without the describe call driving it.So
elapsed = CONNECT_TIMEOUT − gap + reconnect, wheregapis the time between the dial starting and the clock being read. The gap is small —tester.admin()returns in ~1ms,getManagementClient()in ~0.2ms — but it's positive, and it sits on the wrong side of the inequality: anything that stalls in that window makeselapsedsmaller.That leaves ~120ms of margin. Locally I measured 2123–2162ms over five runs, so it never crossed zero — but five runs of identical code also produced one outlier at 2368ms against a 2147ms minimum, so >200ms of jitter is reachable in a single JVM. On a loaded CI runner that margin isn't safe, which is why this only shows up there.
Fix: read the clock before anything that can initiate an upstream connect.
The clock now precedes the dial, so
elapsed > CONNECT_TIMEOUT + reconnectand the floor holds by construction — any pause anywhere only increaseselapsed. Measured 2146–2161ms locally, well inside the 5s completion budget.To be clear what this does and doesn't establish: the mechanism is confirmed by measurement, and the fix removes the failure mode by inverting the inequality rather than widening a margin. I could not reproduce the CI failure locally, so I haven't demonstrated the fix prevents that specific run — but the floor is no longer sensitive to jitter at all.
chore(tests): temporarily disable connection timeout test to avoid bl…
ci(publish): rename Maven server ID to avoid Maven 3.10 credential co…
fix(tests): read clock before upstream dial in connect timeout test (k…
ci(publish): rename Maven server ID to avoid Maven 3.10 credential co…
chore(tests): temporarily disable connection timeout test to avoid bl…
ci(publish): rename Maven server ID to avoid Maven 3.10 credential co…
fix(tests): read clock before upstream dial in connect timeout test (k…
chore(tests): temporarily disable connection timeout test to avoid bl…
ci(publish): rename Maven server ID to avoid Maven 3.10 credential co…
fix(tests): read clock before upstream dial in connect timeout test (k…
chore(tests): temporarily disable connection timeout test to avoid bl…
ci(publish): rename Maven server ID to avoid Maven 3.10 credential co…
fix(tests): read clock before upstream dial in connect timeout test (k…
chore(tests): temporarily disable connection timeout test to avoid bl…
ci(publish): rename Maven server ID to avoid Maven 3.10 credential co…
fix(tests): read clock before upstream dial in connect timeout test (k…