Merge pull request #15966 from s1monw/randomize_mock_plugins
Randomize which MockPlugins are used for IT
This commit is contained in:
commit
1ddfa42c2e
|
@ -22,11 +22,14 @@ package org.elasticsearch.cluster.routing;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.gateway.GatewayAllocator;
|
import org.elasticsearch.gateway.GatewayAllocator;
|
||||||
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.elasticsearch.test.InternalTestCluster;
|
import org.elasticsearch.test.InternalTestCluster;
|
||||||
import org.elasticsearch.test.disruption.NetworkDisconnectPartition;
|
import org.elasticsearch.test.disruption.NetworkDisconnectPartition;
|
||||||
|
import org.elasticsearch.test.transport.MockTransportService;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -41,6 +44,12 @@ import static org.hamcrest.Matchers.equalTo;
|
||||||
@ESIntegTestCase.SuppressLocalMode
|
@ESIntegTestCase.SuppressLocalMode
|
||||||
public class PrimaryAllocationIT extends ESIntegTestCase {
|
public class PrimaryAllocationIT extends ESIntegTestCase {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
||||||
|
// disruption tests need MockTransportService
|
||||||
|
return pluginList(MockTransportService.TestPlugin.class);
|
||||||
|
}
|
||||||
|
|
||||||
public void testDoNotAllowStaleReplicasToBePromotedToPrimary() throws Exception {
|
public void testDoNotAllowStaleReplicasToBePromotedToPrimary() throws Exception {
|
||||||
logger.info("--> starting 3 nodes, 1 master, 2 data");
|
logger.info("--> starting 3 nodes, 1 master, 2 data");
|
||||||
String master = internalCluster().startMasterOnlyNode(Settings.EMPTY);
|
String master = internalCluster().startMasterOnlyNode(Settings.EMPTY);
|
||||||
|
|
|
@ -169,11 +169,13 @@ public class IndexServiceTests extends ESSingleNodeTestCase {
|
||||||
IndexService.BaseAsyncTask task = new IndexService.BaseAsyncTask(indexService, TimeValue.timeValueMillis(1)) {
|
IndexService.BaseAsyncTask task = new IndexService.BaseAsyncTask(indexService, TimeValue.timeValueMillis(1)) {
|
||||||
@Override
|
@Override
|
||||||
protected void runInternal() {
|
protected void runInternal() {
|
||||||
|
final CountDownLatch l1 = latch.get();
|
||||||
|
final CountDownLatch l2 = latch2.get();
|
||||||
count.incrementAndGet();
|
count.incrementAndGet();
|
||||||
assertTrue("generic threadpool is configured", Thread.currentThread().getName().contains("[generic]"));
|
assertTrue("generic threadpool is configured", Thread.currentThread().getName().contains("[generic]"));
|
||||||
latch.get().countDown();
|
l1.countDown();
|
||||||
try {
|
try {
|
||||||
latch2.get().await();
|
l2.await();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
fail("interrupted");
|
fail("interrupted");
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,13 +31,13 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
|
||||||
import org.elasticsearch.test.store.MockFSDirectoryService;
|
import org.elasticsearch.test.store.MockFSDirectoryService;
|
||||||
import org.elasticsearch.test.store.MockFSIndexStore;
|
import org.elasticsearch.test.store.MockFSIndexStore;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
|
||||||
|
@ -46,7 +46,11 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFa
|
||||||
|
|
||||||
public class SearchWithRandomIOExceptionsIT extends ESIntegTestCase {
|
public class SearchWithRandomIOExceptionsIT extends ESIntegTestCase {
|
||||||
|
|
||||||
@TestLogging("action.search.type:TRACE,index.shard:TRACE")
|
@Override
|
||||||
|
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
||||||
|
return pluginList(MockFSIndexStore.TestPlugin.class);
|
||||||
|
}
|
||||||
|
|
||||||
public void testRandomDirectoryIOExceptions() throws IOException, InterruptedException, ExecutionException {
|
public void testRandomDirectoryIOExceptions() throws IOException, InterruptedException, ExecutionException {
|
||||||
String mapping = XContentFactory.jsonBuilder().
|
String mapping = XContentFactory.jsonBuilder().
|
||||||
startObject().
|
startObject().
|
||||||
|
|
|
@ -1799,14 +1799,30 @@ public abstract class ESIntegTestCase extends ESTestCase {
|
||||||
InternalTestCluster.DEFAULT_ENABLE_HTTP_PIPELINING, nodePrefix, mockPlugins);
|
InternalTestCluster.DEFAULT_ENABLE_HTTP_PIPELINING, nodePrefix, mockPlugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the mock plugins the cluster should use. These may be randomly omitted based on the cluster seed. */
|
/** Return the mock plugins the cluster should use */
|
||||||
protected Collection<Class<? extends Plugin>> getMockPlugins() {
|
protected Collection<Class<? extends Plugin>> getMockPlugins() {
|
||||||
return pluginList(MockTransportService.TestPlugin.class,
|
final ArrayList<Class<? extends Plugin>> mocks = new ArrayList<>();
|
||||||
MockFSIndexStore.TestPlugin.class,
|
if (randomBoolean()) { // sometimes run without those completely
|
||||||
NodeMocksPlugin.class,
|
if (randomBoolean()) {
|
||||||
MockEngineFactoryPlugin.class,
|
mocks.add(MockTransportService.TestPlugin.class);
|
||||||
MockSearchService.TestPlugin.class,
|
}
|
||||||
AssertingLocalTransport.TestPlugin.class);
|
if (randomBoolean()) {
|
||||||
|
mocks.add(MockFSIndexStore.TestPlugin.class);
|
||||||
|
}
|
||||||
|
if (randomBoolean()) {
|
||||||
|
mocks.add(NodeMocksPlugin.class);
|
||||||
|
}
|
||||||
|
if (randomBoolean()) {
|
||||||
|
mocks.add(MockEngineFactoryPlugin.class);
|
||||||
|
}
|
||||||
|
if (randomBoolean()) {
|
||||||
|
mocks.add(MockSearchService.TestPlugin.class);
|
||||||
|
}
|
||||||
|
if (randomBoolean()) {
|
||||||
|
mocks.add(AssertingLocalTransport.TestPlugin.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Collections.unmodifiableList(mocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -367,7 +367,7 @@ public final class InternalTestCluster extends TestCluster {
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Collection<Class<? extends Plugin>> getPlugins(long seed) {
|
private Collection<Class<? extends Plugin>> getPlugins() {
|
||||||
Set<Class<? extends Plugin>> plugins = new HashSet<>(nodeConfigurationSource.nodePlugins());
|
Set<Class<? extends Plugin>> plugins = new HashSet<>(nodeConfigurationSource.nodePlugins());
|
||||||
plugins.addAll(mockPlugins);
|
plugins.addAll(mockPlugins);
|
||||||
if (isLocalTransportConfigured() == false) {
|
if (isLocalTransportConfigured() == false) {
|
||||||
|
@ -589,7 +589,7 @@ public final class InternalTestCluster extends TestCluster {
|
||||||
assert Thread.holdsLock(this);
|
assert Thread.holdsLock(this);
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
settings = getSettings(nodeId, seed, settings);
|
settings = getSettings(nodeId, seed, settings);
|
||||||
Collection<Class<? extends Plugin>> plugins = getPlugins(seed);
|
Collection<Class<? extends Plugin>> plugins = getPlugins();
|
||||||
String name = buildNodeName(nodeId);
|
String name = buildNodeName(nodeId);
|
||||||
assert !nodes.containsKey(name);
|
assert !nodes.containsKey(name);
|
||||||
Settings finalSettings = settingsBuilder()
|
Settings finalSettings = settingsBuilder()
|
||||||
|
|
|
@ -51,18 +51,6 @@ public abstract class NodeConfigurationSource {
|
||||||
*/
|
*/
|
||||||
public abstract Settings nodeSettings(int nodeOrdinal);
|
public abstract Settings nodeSettings(int nodeOrdinal);
|
||||||
|
|
||||||
/** Plugins that will be randomly added to the node */
|
|
||||||
public Collection<Class<? extends Plugin>> mockPlugins() {
|
|
||||||
List<Class<? extends Plugin>> plugins = new ArrayList<>();
|
|
||||||
plugins.add(MockTransportService.TestPlugin.class);
|
|
||||||
plugins.add(MockFSIndexStore.TestPlugin.class);
|
|
||||||
plugins.add(NodeMocksPlugin.class);
|
|
||||||
plugins.add(MockEngineFactoryPlugin.class);
|
|
||||||
plugins.add(MockSearchService.TestPlugin.class);
|
|
||||||
plugins.add(AssertingLocalTransport.TestPlugin.class);
|
|
||||||
return plugins;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns plugins that should be loaded on the node */
|
/** Returns plugins that should be loaded on the node */
|
||||||
public Collection<Class<? extends Plugin>> nodePlugins() {
|
public Collection<Class<? extends Plugin>> nodePlugins() {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
Loading…
Reference in New Issue