Skip to content

Commit 5f8bcf8

Browse files
junkaixueclaude
andcommitted
Add timeout to prevent test hanging in testDisconnectWhenConnectionBreak
The test was hanging because testThread.join() was waiting indefinitely. If disconnect() hangs when ZK connection is broken, the test would wait forever. This caused the CI test to timeout after 15 minutes. Fix by: 1. Add 10 second timeout to join() to prevent indefinite wait 2. Make forceful stop conditional - only if thread is still alive 3. Add descriptive assertion message Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6bef6b9 commit 5f8bcf8

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

helix-core/src/test/java/org/apache/helix/integration/TestZkConnectionLost.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,17 @@ public void run() {
132132
};
133133
try {
134134
testThread.start();
135-
testThread.join();
136-
Assert.assertTrue(disconnected.get());
135+
// Add timeout to prevent test from hanging forever if disconnect() hangs
136+
testThread.join(10000);
137+
Assert.assertTrue(disconnected.get(),
138+
"disconnect() should complete within 10 seconds");
137139
Assert.assertFalse(controllerManager.isConnected());
138140
} finally {
139-
testThread.stop();
140-
TestHelper.verify(() -> testThread.getState().equals(Thread.State.TERMINATED),
141-
TestHelper.WAIT_DURATION);
141+
if (testThread.isAlive()) {
142+
testThread.stop();
143+
TestHelper.verify(() -> testThread.getState().equals(Thread.State.TERMINATED),
144+
TestHelper.WAIT_DURATION);
145+
}
142146
_zkServerRef.set(TestHelper.startZkServer(_zkAddr, null, false));
143147
}
144148
}

0 commit comments

Comments
 (0)