Skip to content

Commit

Permalink
Merge pull request #13222 from martijnvg/tests/external_tests_provide…
Browse files Browse the repository at this point in the history
…_transport_client_with_plugins

Provide the plugins to transport client communicating with the the external cluster
  • Loading branch information
martijnvg committed Aug 31, 2015
2 parents db7aeca + 1b84cad commit 1230cb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,7 @@ private ExternalTestCluster buildExternalCluster(String clusterAddresses) throws
throw new IllegalArgumentException("port is not valid, expected number but was [" + split[1] + "]");
}
}
return new ExternalTestCluster(createTempDir(), externalClusterClientSettings(), transportAddresses);
return new ExternalTestCluster(createTempDir(), externalClusterClientSettings(), transportClientPlugins(), transportAddresses);
}

protected Settings externalClusterClientSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.plugins.Plugin;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -65,7 +67,7 @@ public final class ExternalTestCluster extends TestCluster {
private final int numDataNodes;
private final int numMasterAndDataNodes;

public ExternalTestCluster(Path tempDir, Settings additionalSettings, TransportAddress... transportAddresses) {
public ExternalTestCluster(Path tempDir, Settings additionalSettings, Collection<Class<? extends Plugin>> pluginClasses, TransportAddress... transportAddresses) {
super(0);
Settings clientSettings = Settings.settingsBuilder()
.put(additionalSettings)
Expand All @@ -75,7 +77,11 @@ public ExternalTestCluster(Path tempDir, Settings additionalSettings, TransportA
.put("path.home", tempDir)
.put("node.mode", "network").build(); // we require network here!

this.client = TransportClient.builder().settings(clientSettings).build().addTransportAddresses(transportAddresses);
TransportClient.Builder transportClientBuilder = TransportClient.builder().settings(clientSettings);
for (Class<? extends Plugin> pluginClass : pluginClasses) {
transportClientBuilder.addPlugin(pluginClass);
}
this.client = transportClientBuilder.build().addTransportAddresses(transportAddresses);

NodesInfoResponse nodeInfos = this.client.admin().cluster().prepareNodesInfo().clear().setSettings(true).setHttp(true).get();
httpAddresses = new InetSocketAddress[nodeInfos.getNodes().length];
Expand Down

0 comments on commit 1230cb0

Please sign in to comment.