KAFKA-14249: Make TLS idle expiry test deterministic - #22943
Conversation
gaurav-narula
left a comment
There was a problem hiding this comment.
Thanks for this. I've a question about post handshake messages in TLS 1.3
There was a problem hiding this comment.
Pull request overview
This PR makes the TLS idle connection expiry test deterministic across TLS versions by ensuring the connection is fully handshake-complete (READY) before the idle timer window begins, and re-enables the TLS 1.3 variant as a normal (non-flaky) regression test.
Changes:
- In
SelectorTest#testCloseOldestConnection, wait for the channel to becomeREADY(not just TCPCONNECTED) before advancing time and asserting idle expiry. - Remove the TLS 1.3-only
@Flakyoverride sotestCloseOldestConnectionruns normally under TLS 1.3.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| clients/src/test/java/org/apache/kafka/common/network/Tls13SelectorTest.java | Removes the TLS 1.3 @Flaky override so the shared idle-expiry test executes normally. |
| clients/src/test/java/org/apache/kafka/common/network/SelectorTest.java | Adds a waitForChannelReady precondition to make idle-expiry timing deterministic after TLS handshakes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Rebased this PR onto the latest trunk and added Kafka's required The previous Java 25 full-suite failure was unrelated to this change:
|
Generated-by: OpenAI Codex (GPT-5)
Generated-by: OpenAI Codex (GPT-5)
b3fafa7 to
db5fa2a
Compare
|
Follow-up on the TLS 1.3 post-handshake question: I rechecked the selector ordering. During The targeted selector suites and full |
Exercise an application round trip before advancing the idle timer so TLS 1.3 post-handshake messages cannot race with the expiry assertion. Generated-by: OpenAI Codex (GPT-5) Signed-off-by: Yunseop Eom <62834176+lh0156@users.noreply.github.com>
Summary
Motivation
Fixes KAFKA-14249.
The idle-expiry test only waited for the TCP connection to reach
CONNECTED. With TLS 1.3, the first subsequent poll can still process handshake I/O and refresh the selector's last-active timestamp. The test then misses the expiry deadline and was marked flaky and excluded from normal test execution.Waiting for
READYmakes the test precondition match the behavior being tested: no handshake work remains before the idle period starts. This lets the TLS 1.3 variant run as a regular regression test.Validation
testCloseOldestConnectionincluded; it passed.SelectorTest,Tls12SelectorTest, andTls13SelectorTest; all passed../gradlew :clients:test --no-build-cache --console=plainsuccessfully.git diff --checksuccessfully.Reviewers: Gaurav Narula gaurav_narula2@apple.com