[TEST] assign a name to the transport client created within ExternalTestCluster

The transport client created within ExternalTestCluster needs a name that follows our naming convention otherwise the thread leak filter barfs when running tests against an external cluster. Used "transport_client_external_{n}" where n gets incremented every time a new external cluster gets created. Updated thread leak filters rules to ignore threads created by such transport client.
This commit is contained in:
javanna 2014-11-04 17:05:31 +01:00 committed by Luca Cavanna
parent 9ea25df649
commit ab0bee47c5
2 changed files with 7 additions and 7 deletions

View File

@ -21,7 +21,6 @@ package org.elasticsearch.test;
import com.carrotsearch.randomizedtesting.ThreadFilter;
import org.elasticsearch.common.network.MulticastChannel;
import org.elasticsearch.test.hamcrest.RegexMatcher;
import org.elasticsearch.tribe.TribeTests;
import java.util.regex.Pattern;
@ -40,6 +39,7 @@ public final class ElasticsearchThreadFilter implements ThreadFilter {
Pattern.quote(ElasticsearchIntegrationTest.GLOBAL_CLUSTER_NODE_PREFIX) + "|" +
Pattern.quote(ElasticsearchIntegrationTest.SUITE_CLUSTER_NODE_PREFIX) + "|" +
Pattern.quote(ElasticsearchIntegrationTest.TEST_CLUSTER_NODE_PREFIX) + "|" +
Pattern.quote(ExternalTestCluster.EXTERNAL_CLUSTER_PREFIX) + "|" +
Pattern.quote(TribeTests.SECOND_CLUSTER_NODE_PREFIX) + ")"
+ ")\\d+\\]");

View File

@ -28,22 +28,18 @@ import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.breaker.CircuitBreaker;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.discovery.DiscoveryModule;
import org.elasticsearch.env.Environment;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicInteger;
import static junit.framework.Assert.assertFalse;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
@ -54,7 +50,10 @@ import static org.junit.Assert.assertThat;
*/
public final class ExternalTestCluster extends TestCluster {
private final ESLogger logger = Loggers.getLogger(getClass());
private static final ESLogger logger = Loggers.getLogger(ExternalTestCluster.class);
private static final AtomicInteger counter = new AtomicInteger();
public static final String EXTERNAL_CLUSTER_PREFIX = "external_";
private final Client client;
@ -69,6 +68,7 @@ public final class ExternalTestCluster extends TestCluster {
public ExternalTestCluster(TransportAddress... transportAddresses) {
super(0);
Settings clientSettings = ImmutableSettings.settingsBuilder()
.put("name", InternalTestCluster.TRANSPORT_CLIENT_PREFIX + EXTERNAL_CLUSTER_PREFIX + counter.getAndIncrement())
.put("config.ignore_system_properties", true) // prevents any settings to be replaced by system properties.
.put("client.transport.ignore_cluster_name", true)
.put("node.mode", "network").build(); // we require network here!