Skip to content

Commit 3f8aafc

Browse files
committed
Use loopback address in RemoteClusterConnectionTests
Replaced the usage of `InetAddress.getLocalHost()` with `InetAddress.getLoopbackAddress()` in the `testSlowNodeCanBeCancelled` test to make it work on Debian 12 where `InetAddress.getLocalHost()` may return non-existing address due to incorrectly set value in `/etc/hosts` by GCP VM script `google_set_hostname`.
1 parent 70ba917 commit 3f8aafc

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

server/src/test/java/org/elasticsearch/transport/RemoteClusterConnectionTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.elasticsearch.common.xcontent.XContentHelper;
4141
import org.elasticsearch.core.IOUtils;
4242
import org.elasticsearch.core.ReleasableRef;
43-
import org.elasticsearch.core.SuppressForbidden;
4443
import org.elasticsearch.core.TimeValue;
4544
import org.elasticsearch.index.IndexNotFoundException;
4645
import org.elasticsearch.mocksocket.MockServerSocket;
@@ -213,10 +212,9 @@ public static MockTransportService startTransport(
213212
}
214213
}
215214

216-
@SuppressForbidden(reason = "calls getLocalHost here but it's fine in this case")
217215
public void testSlowNodeCanBeCancelled() throws IOException, InterruptedException {
218216
try (ServerSocket socket = new MockServerSocket()) {
219-
socket.bind(new InetSocketAddress(InetAddress.getLocalHost(), 0), 1);
217+
socket.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 1);
220218
socket.setReuseAddress(true);
221219
DiscoveryNode seedNode = DiscoveryNodeUtils.create(
222220
"TEST",

0 commit comments

Comments
 (0)