This is an automated email from the ASF dual-hosted git repository.
maobaolong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git
The following commit(s) were added to refs/heads/master by this push:
new 5b7d18c30 [MINOR] fix(test): Fix flaky test CoordinatorServerTest#test
(#2332)
5b7d18c30 is described below
commit 5b7d18c308ee4669337c6ab76010333b61c6be00
Author: maobaolong <[email protected]>
AuthorDate: Thu Jan 9 16:19:23 2025 +0800
[MINOR] fix(test): Fix flaky test CoordinatorServerTest#test (#2332)
### What changes were proposed in this pull request?
Fix flaky test CoordinatorServerTest#test
### Why are the changes needed?
Make CI stable.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Existing UT.
---
.../uniffle/coordinator/CoordinatorServerTest.java | 75 ++++++++++++----------
1 file changed, 42 insertions(+), 33 deletions(-)
diff --git
a/coordinator/src/test/java/org/apache/uniffle/coordinator/CoordinatorServerTest.java
b/coordinator/src/test/java/org/apache/uniffle/coordinator/CoordinatorServerTest.java
index 2fb4810ec..357bf6986 100644
---
a/coordinator/src/test/java/org/apache/uniffle/coordinator/CoordinatorServerTest.java
+++
b/coordinator/src/test/java/org/apache/uniffle/coordinator/CoordinatorServerTest.java
@@ -36,43 +36,52 @@ public class CoordinatorServerTest {
CoordinatorServer cs1 = new CoordinatorServer(coordinatorConf);
CoordinatorServer cs2 = new CoordinatorServer(coordinatorConf);
- cs1.start();
-
- ExitUtils.disableSystemExit();
- String expectMessage = "Fail to start jetty http server";
- final int expectStatus = 1;
+ CoordinatorServer cs3 = null;
try {
- cs2.start();
- } catch (Exception e) {
- assertTrue(e.getMessage().startsWith(expectMessage));
- assertEquals(expectStatus, ((ExitException) e).getStatus());
- } finally {
- // Always call stopServer after new CoordinatorServer to shut down
ExecutorService
- cs2.stopServer();
- }
+ cs1.start();
- coordinatorConf.setInteger("rss.jetty.http.port", 9529);
- cs2 = new CoordinatorServer(coordinatorConf);
- expectMessage = "Fail to start grpc server";
- try {
- cs2.start();
- } catch (Exception e) {
- assertEquals(expectMessage, e.getMessage());
- assertEquals(expectStatus, ((ExitException) e).getStatus());
+ ExitUtils.disableSystemExit();
+ String expectMessage = "Fail to start jetty http server";
+ final int expectStatus = 1;
+ try {
+ cs2.start();
+ } catch (Exception e) {
+ assertTrue(e.getMessage().startsWith(expectMessage));
+ assertEquals(expectStatus, ((ExitException) e).getStatus());
+ } finally {
+ // Always call stopServer after new CoordinatorServer to shut down
ExecutorService
+ cs2.stopServer();
+ }
+
+ coordinatorConf.setInteger("rss.jetty.http.port", 9529);
+ cs3 = new CoordinatorServer(coordinatorConf);
+ expectMessage = "Fail to start grpc server";
+ try {
+ cs3.start();
+ } catch (Exception e) {
+ assertEquals(expectMessage, e.getMessage());
+ assertEquals(expectStatus, ((ExitException) e).getStatus());
+ } finally {
+ // Always call stopServer after new CoordinatorServer to shut down
ExecutorService
+ cs2.stopServer();
+ cs1.stopServer();
+ }
+
+ final Thread t =
+ new Thread(
+ null,
+ () -> {
+ throw new AssertionError("TestUncaughtException");
+ },
+ "testThread");
+ t.start();
+ t.join();
} finally {
- // Always call stopServer after new CoordinatorServer to shut down
ExecutorService
- cs2.stopServer();
cs1.stopServer();
+ cs2.stopServer();
+ if (cs3 != null) {
+ cs3.stopServer();
+ }
}
-
- final Thread t =
- new Thread(
- null,
- () -> {
- throw new AssertionError("TestUncaughtException");
- },
- "testThread");
- t.start();
- t.join();
}
}