Start Test nodes sometimes without mock modules
We are mocking out some functionality to add assertions etc. or randomize store types. We should randomly run with our defaults to make sure we don't hide any potential problems.
This commit is contained in:
parent
a1e4258b21
commit
11c4218566
1
pom.xml
1
pom.xml
|
@ -427,6 +427,7 @@
|
|||
<tests.integration>${tests.integration}</tests.integration>
|
||||
<tests.cluster_seed>${tests.cluster_seed}</tests.cluster_seed>
|
||||
<tests.client.ratio>${tests.client.ratio}</tests.client.ratio>
|
||||
<tests.enable_mock_modules>${tests.enable_mock_modules}</tests.enable_mock_modules>
|
||||
<tests.rest>${tests.rest}</tests.rest>
|
||||
<tests.rest.suite>${tests.rest.suite}</tests.rest.suite>
|
||||
<tests.rest.spec>${tests.rest.spec}</tests.rest.spec>
|
||||
|
|
|
@ -125,6 +125,8 @@ import static org.hamcrest.Matchers.equalTo;
|
|||
* <ul>
|
||||
* <li>-D{@value #TESTS_CLIENT_RATIO} - a double value in the interval [0..1] which defines the ration between node and transport clients used</li>
|
||||
* <li>-D{@value TestCluster#TESTS_CLUSTER_SEED} - a random seed used to initialize the clusters random context.
|
||||
* <li>-D{@value TestCluster#TESTS_ENABLE_MOCK_MODULES} - a boolean value to enable or disable mock modules. This is
|
||||
* useful to test the system without asserting modules that to make sure they don't hide any bugs in production.</li>
|
||||
* <li>-D{@value #INDEX_SEED_SETTING} - a random seed used to initialize the index random context.
|
||||
* </ul>
|
||||
* </p>
|
||||
|
|
|
@ -62,7 +62,10 @@ import java.util.*;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static com.carrotsearch.randomizedtesting.RandomizedTest.systemPropertyAsBoolean;
|
||||
import static com.google.common.collect.Maps.newTreeMap;
|
||||
import static org.apache.lucene.util.LuceneTestCase.rarely;
|
||||
import static org.apache.lucene.util.LuceneTestCase.usually;
|
||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
|
||||
|
||||
|
@ -91,6 +94,13 @@ public final class TestCluster implements Iterable<Client> {
|
|||
*/
|
||||
public static final String TESTS_CLUSTER_SEED = "tests.cluster_seed";
|
||||
|
||||
/**
|
||||
* Key used to set the shared cluster random seed via the commandline -D{@value #TESTS_CLUSTER_SEED}
|
||||
*/
|
||||
public static final String TESTS_ENABLE_MOCK_MODULES = "tests.enable_mock_modules";
|
||||
|
||||
private static final boolean ENABLE_MOCK_MODULES = systemPropertyAsBoolean(TESTS_ENABLE_MOCK_MODULES, true);
|
||||
|
||||
private static long clusterSeed() {
|
||||
String property = System.getProperty(TESTS_CLUSTER_SEED);
|
||||
if (!Strings.hasLength(property)) {
|
||||
|
@ -191,18 +201,19 @@ public final class TestCluster implements Iterable<Client> {
|
|||
Builder builder = ImmutableSettings.settingsBuilder()
|
||||
/* use RAM directories in 10% of the runs */
|
||||
//.put("index.store.type", random.nextInt(10) == 0 ? MockRamIndexStoreModule.class.getName() : MockFSIndexStoreModule.class.getName())
|
||||
// TODO we should run without those mock modules once in a while to make sure we don't hide any bugs in the actual impl.
|
||||
.put("index.store.type", MockFSIndexStoreModule.class.getName()) // no RAM dir for now!
|
||||
.put(IndexEngineModule.EngineSettings.ENGINE_TYPE, MockEngineModule.class.getName())
|
||||
.put("cluster.name", clusterName)
|
||||
// decrease the routing schedule so new nodes will be added quickly - some random value between 30 and 80 ms
|
||||
.put("cluster.routing.schedule", (30 + random.nextInt(50)) + "ms")
|
||||
// default to non gateway
|
||||
.put("gateway.type", "none");
|
||||
if (ENABLE_MOCK_MODULES && usually(random)) {
|
||||
builder.put("index.store.type", MockFSIndexStoreModule.class.getName()); // no RAM dir for now!
|
||||
builder.put(IndexEngineModule.EngineSettings.ENGINE_TYPE, MockEngineModule.class.getName());
|
||||
}
|
||||
if (isLocalTransportConfigured()) {
|
||||
builder.put(TransportModule.TRANSPORT_TYPE_KEY, AssertingLocalTransportModule.class.getName());
|
||||
} else {
|
||||
builder.put(Transport.TransportSettings.TRANSPORT_TCP_COMPRESS, random.nextInt(10) == 0);
|
||||
builder.put(Transport.TransportSettings.TRANSPORT_TCP_COMPRESS, rarely(random));
|
||||
}
|
||||
builder.put("type", RandomPicks.randomFrom(random, CacheRecycler.Type.values()));
|
||||
return builder.build();
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.elasticsearch.common.logging.ESLogger;
|
|||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||
import org.elasticsearch.test.ElasticsearchTestCase;
|
||||
import org.elasticsearch.test.TestCluster;
|
||||
import org.junit.internal.AssumptionViolatedException;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.notification.Failure;
|
||||
|
@ -111,7 +112,7 @@ public class ReproduceInfoPrinter extends RunListener {
|
|||
}
|
||||
|
||||
public ReproduceErrorMessageBuilder appendESProperties() {
|
||||
appendProperties("es.logger.level", "es.node.mode", "es.node.local");
|
||||
appendProperties("es.logger.level", "es.node.mode", "es.node.local", TestCluster.TESTS_ENABLE_MOCK_MODULES);
|
||||
|
||||
if (System.getProperty("tests.jvm.argline") != null && !System.getProperty("tests.jvm.argline").isEmpty()) {
|
||||
appendOpt("tests.jvm.argline", "\"" + System.getProperty("tests.jvm.argline") + "\"");
|
||||
|
|
Loading…
Reference in New Issue