Skip to content

Commit 77d07b1

Browse files
authored
[tests] Fix unstable TabletServerFailOverITCase#testIOExceptionShouldStopTabletServer (#743)
1 parent 26a313b commit 77d07b1

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

fluss-server/src/test/java/com/alibaba/fluss/server/tablet/TabletServerFailOverITCase.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ void testIOExceptionShouldStopTabletServer(boolean isLogTable) throws Exception
8888
.waitAndGetLeaderReplica(tb)
8989
.getLogTablet()
9090
.activeLogSegment();
91-
logSegment.flush();
9291
logSegment.deleteIfExists();
9392

9493
// should get RetriableException since the leader server is shutdown

fluss-server/src/test/java/com/alibaba/fluss/server/testutils/FlussClusterExtension.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public final class FlussClusterExtension
115115
private File tempDir;
116116

117117
private final Map<Integer, TabletServer> tabletServers;
118-
private final List<ServerInfo> tabletServerInfos;
118+
private final Map<Integer, ServerInfo> tabletServerInfos;
119119
private final Configuration clusterConf;
120120

121121
/** Creates a new {@link Builder} for {@link FlussClusterExtension}. */
@@ -132,7 +132,7 @@ private FlussClusterExtension(
132132
this.tabletServers = new HashMap<>(numOfTabletServers);
133133
this.coordinatorServerListeners = coordinatorServerListeners;
134134
this.tabletServerListeners = tabletServerListeners;
135-
this.tabletServerInfos = new ArrayList<>();
135+
this.tabletServerInfos = new HashMap<>();
136136
this.clusterConf = clusterConf;
137137
}
138138

@@ -268,9 +268,7 @@ public void startTabletServer(int serverId) throws Exception {
268268

269269
public void startTabletServer(int serverId, boolean forceStartIfExists) throws Exception {
270270
if (tabletServers.containsKey(serverId)) {
271-
if (forceStartIfExists) {
272-
tabletServers.remove(serverId);
273-
} else {
271+
if (!forceStartIfExists) {
274272
throw new IllegalArgumentException(
275273
"Tablet server " + serverId + " already exists.");
276274
}
@@ -294,7 +292,7 @@ public void startTabletServer(int serverId, boolean forceStartIfExists) throws E
294292
ServerType.TABLET_SERVER);
295293

296294
tabletServers.put(serverId, tabletServer);
297-
tabletServerInfos.add(serverInfo);
295+
tabletServerInfos.put(serverId, serverInfo);
298296
}
299297

300298
public void assertHasTabletServerNumber(int tabletServerNumber) {
@@ -333,7 +331,7 @@ public void stopTabletServer(int serverId) throws Exception {
333331
throw new IllegalArgumentException("Tablet server " + serverId + " does not exist.");
334332
}
335333
tabletServers.remove(serverId).close();
336-
tabletServerInfos.removeIf(node -> node.id() == serverId);
334+
tabletServerInfos.remove(serverId);
337335
}
338336

339337
public Configuration getClientConfig() {
@@ -363,7 +361,7 @@ public ServerInfo getCoordinatorServerInfo() {
363361
}
364362

365363
public List<ServerInfo> getTabletServerInfos() {
366-
return tabletServerInfos;
364+
return new ArrayList<>(tabletServerInfos.values());
367365
}
368366

369367
public ServerNode getCoordinatorServerNode() {
@@ -391,7 +389,7 @@ public List<ServerNode> getTabletServerNodes() {
391389
}
392390

393391
public List<ServerNode> getTabletServerNodes(@Nullable String listenerName) {
394-
return tabletServerInfos.stream()
392+
return tabletServerInfos.values().stream()
395393
.map(
396394
node -> {
397395
Endpoint endpoint =

0 commit comments

Comments
 (0)