Skip to content

Commit e646596

Browse files
committed
don't resolve DNS in Ec2DiscoveryTests
1 parent 4e0352f commit e646596

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryTests.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,26 @@
2424
import org.elasticsearch.cloud.aws.AwsEc2Service;
2525
import org.elasticsearch.cloud.aws.AwsEc2Service.DISCOVERY_EC2;
2626
import org.elasticsearch.cluster.node.DiscoveryNode;
27+
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
28+
import org.elasticsearch.common.network.NetworkService;
2729
import org.elasticsearch.common.settings.Settings;
2830
import org.elasticsearch.common.transport.LocalTransportAddress;
2931
import org.elasticsearch.common.transport.TransportAddress;
32+
import org.elasticsearch.common.util.BigArrays;
33+
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
3034
import org.elasticsearch.test.ESTestCase;
3135
import org.elasticsearch.test.transport.MockTransportService;
3236
import org.elasticsearch.threadpool.TestThreadPool;
3337
import org.elasticsearch.threadpool.ThreadPool;
38+
import org.elasticsearch.transport.MockTcpTransport;
39+
import org.elasticsearch.transport.Transport;
3440
import org.elasticsearch.transport.TransportService;
3541
import org.junit.AfterClass;
3642
import org.junit.Before;
3743
import org.junit.BeforeClass;
3844

3945
import java.util.ArrayList;
46+
import java.util.Collections;
4047
import java.util.List;
4148

4249
import static org.hamcrest.Matchers.containsString;
@@ -66,7 +73,17 @@ public static void stopThreadPool() throws InterruptedException {
6673

6774
@Before
6875
public void createTransportService() {
69-
transportService = MockTransportService.createNewService(Settings.EMPTY, Version.CURRENT, threadPool);
76+
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
77+
final Transport transport = new MockTcpTransport(Settings.EMPTY, threadPool, BigArrays.NON_RECYCLING_INSTANCE,
78+
new NoneCircuitBreakerService(), namedWriteableRegistry, new NetworkService(Settings.EMPTY, Collections.emptyList()),
79+
Version.CURRENT) {
80+
@Override
81+
public TransportAddress[] addressesFromString(String address, int perAddressLimit) throws Exception {
82+
// we just need to ensure we don't resolve DNS here
83+
return new TransportAddress[] {new LocalTransportAddress(address)};
84+
}
85+
};
86+
transportService = new MockTransportService(Settings.EMPTY, transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR);
7087
}
7188

7289
protected List<DiscoveryNode> buildDynamicNodes(Settings nodeSettings, int nodes) {

0 commit comments

Comments
 (0)