Skip to content

Commit 39c7e0b

Browse files
authored
Always write unicast hosts file in tests (#118121)
This commit adds the ability to restart a node within a test cluster. The newly started node uses the same configuration and directories. Since we use ephemeral ports, the unicast hosts list is rewritten for all nodes once the restarted node comes back up.
1 parent 05eee61 commit 39c7e0b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultLocalClusterHandle.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,9 @@ public long getPid(int index) {
176176
return nodes.get(index).getPid();
177177
}
178178

179+
@Override
179180
public void stopNode(int index, boolean forcibly) {
180-
nodes.get(index).stop(false);
181+
nodes.get(index).stop(forcibly);
181182
}
182183

183184
@Override
@@ -252,9 +253,8 @@ private void writeUnicastHostsFile() {
252253
execute(() -> nodes.parallelStream().forEach(node -> {
253254
try {
254255
Path hostsFile = node.getWorkingDir().resolve("config").resolve("unicast_hosts.txt");
255-
if (Files.notExists(hostsFile)) {
256-
Files.writeString(hostsFile, transportUris);
257-
}
256+
LOGGER.info("Writing unicast hosts file {} for node {}", hostsFile, node.getName());
257+
Files.writeString(hostsFile, transportUris);
258258
} catch (IOException e) {
259259
throw new UncheckedIOException("Failed to write unicast_hosts for: " + node, e);
260260
}

0 commit comments

Comments
 (0)