[Tests] verifyThreadNames should account for new threads of shared cluster
The verifyThreadNames starts a node and checks that all new threads on the JVM are properly named. The current test uses the name of the new node which sometimes fails because our shared cluster spawns a new thread which is properly named but for not for the new name. The commits relaxes the requirement of the test and on verify the threads are properly named (but not necessarily of the new node)
This commit is contained in:
parent
45f062792c
commit
06fb9ff761
|
@ -97,9 +97,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.frequently;
|
||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.isNightly;
|
||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsBoolean;
|
||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.*;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.apache.lucene.util.LuceneTestCase.rarely;
|
||||
import static org.apache.lucene.util.LuceneTestCase.usually;
|
||||
|
@ -139,7 +137,10 @@ public final class InternalTestCluster extends TestCluster {
|
|||
*/
|
||||
public static final String SETTING_CLUSTER_NODE_SEED = "test.cluster.node.seed";
|
||||
|
||||
private static final String NODE_PREFIX = "node_";
|
||||
/**
|
||||
* All nodes started by the cluster will have their name set to NODE_PREFIX followed by a positive number
|
||||
*/
|
||||
public static final String NODE_PREFIX = "node_";
|
||||
|
||||
private static final boolean ENABLE_MOCK_MODULES = systemPropertyAsBoolean(TESTS_ENABLE_MOCK_MODULES, true);
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
|||
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope;
|
||||
import org.elasticsearch.test.ElasticsearchSingleNodeTest;
|
||||
import org.elasticsearch.test.InternalTestCluster;
|
||||
import org.elasticsearch.test.hamcrest.RegexMatcher;
|
||||
import org.elasticsearch.threadpool.ThreadPool.Names;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -46,6 +47,7 @@ import java.lang.management.ThreadMXBean;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
|
@ -113,7 +115,8 @@ public class SimpleThreadPoolTests extends ElasticsearchIntegrationTest {
|
|||
|| threadName.contains("Keep-Alive-Timer")) {
|
||||
continue;
|
||||
}
|
||||
assertThat(threadName, anyOf(containsString("[" + node + "]"), containsString("[" + InternalTestCluster.TRANSPORT_CLIENT_PREFIX + node + "]")));
|
||||
String nodePrefix = "(" + Pattern.quote(InternalTestCluster.TRANSPORT_CLIENT_PREFIX) + ")?" + Pattern.quote(InternalTestCluster.NODE_PREFIX);
|
||||
assertThat(threadName, RegexMatcher.matches("\\[" + nodePrefix + "\\d+\\]"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue