Merge pull request #13222 from martijnvg/tests/external_tests_provide_transport_client_with_plugins

Provide the plugins to transport client communicating with the the external cluster
This commit is contained in:
Martijn van Groningen 2015-08-31 17:06:53 +02:00
commit 1230cb0278
2 changed files with 9 additions and 3 deletions

View File

@ -1739,7 +1739,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
throw new IllegalArgumentException("port is not valid, expected number but was [" + split[1] + "]"); 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() { protected Settings externalClusterClientSettings() {

View File

@ -33,10 +33,12 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.node.internal.InternalSettingsPreparer; import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.plugins.Plugin;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -65,7 +67,7 @@ public final class ExternalTestCluster extends TestCluster {
private final int numDataNodes; private final int numDataNodes;
private final int numMasterAndDataNodes; 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); super(0);
Settings clientSettings = Settings.settingsBuilder() Settings clientSettings = Settings.settingsBuilder()
.put(additionalSettings) .put(additionalSettings)
@ -75,7 +77,11 @@ public final class ExternalTestCluster extends TestCluster {
.put("path.home", tempDir) .put("path.home", tempDir)
.put("node.mode", "network").build(); // we require network here! .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(); NodesInfoResponse nodeInfos = this.client.admin().cluster().prepareNodesInfo().clear().setSettings(true).setHttp(true).get();
httpAddresses = new InetSocketAddress[nodeInfos.getNodes().length]; httpAddresses = new InetSocketAddress[nodeInfos.getNodes().length];