Add ability to run certain packages with assertions disabled
Test can be run with `-Dtests.assertion.disabled=org.elasticsearch` to run the tests without assertions to make sure assertions don't hide any assignements etc. that introduce bugs in production.
This commit is contained in:
parent
e6e1a3463a
commit
e7a84d744a
4
pom.xml
4
pom.xml
|
@ -378,7 +378,8 @@
|
|||
<report-execution-times file="${basedir}/.local-execution-hints.log"/>
|
||||
</listeners>
|
||||
<assertions>
|
||||
<enable/>
|
||||
<enable />
|
||||
<disable package="${tests.assertion.disabled}"/> <!-- pass org.elasticsearch to run without assertions -->
|
||||
</assertions>
|
||||
<parallelism>${tests.jvms}</parallelism>
|
||||
<balancers>
|
||||
|
@ -429,6 +430,7 @@
|
|||
<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.assertion.disabled>${tests.assertion.disabled}</tests.assertion.disabled>
|
||||
<tests.rest>${tests.rest}</tests.rest>
|
||||
<tests.rest.suite>${tests.rest.suite}</tests.rest.suite>
|
||||
<tests.rest.spec>${tests.rest.spec}</tests.rest.spec>
|
||||
|
|
|
@ -32,6 +32,7 @@ public class HppcMapsTests extends ElasticsearchTestCase {
|
|||
|
||||
@Test
|
||||
public void testIntersection() throws Exception {
|
||||
assumeTrue(ASSERTIONS_ENABLED);
|
||||
ObjectOpenHashSet<String> set1 = ObjectOpenHashSet.from("1", "2", "3");
|
||||
ObjectOpenHashSet<String> set2 = ObjectOpenHashSet.from("1", "2", "3");
|
||||
List<String> values = toList(HppcMaps.intersection(set1, set2));
|
||||
|
|
|
@ -224,6 +224,7 @@ public class SimpleIdCacheTests extends ElasticsearchTestCase {
|
|||
|
||||
@Test(expected = AssertionError.class)
|
||||
public void testRefresh_tripAssert() throws Exception {
|
||||
assumeTrue(ASSERTIONS_ENABLED);
|
||||
SimpleIdCache idCache = createSimpleIdCache(Tuple.tuple("child", "parent"));
|
||||
IndexWriter writer = createIndexWriter();
|
||||
// Begins with parent, ends with child docs
|
||||
|
|
|
@ -65,6 +65,13 @@ public abstract class ElasticsearchTestCase extends AbstractRandomizedTest {
|
|||
|
||||
public static final String CHILD_VM_ID = System.getProperty("junit4.childvm.id", "" + System.currentTimeMillis());
|
||||
|
||||
public static final boolean ASSERTIONS_ENABLED;
|
||||
static {
|
||||
boolean enabled = false;
|
||||
assert enabled = true;
|
||||
ASSERTIONS_ENABLED = enabled;
|
||||
}
|
||||
|
||||
public static boolean awaitBusy(Predicate<?> breakPredicate) throws InterruptedException {
|
||||
return awaitBusy(breakPredicate, 10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
|
|
@ -112,8 +112,8 @@ public class ReproduceInfoPrinter extends RunListener {
|
|||
}
|
||||
|
||||
public ReproduceErrorMessageBuilder appendESProperties() {
|
||||
appendProperties("es.logger.level", "es.node.mode", "es.node.local", TestCluster.TESTS_ENABLE_MOCK_MODULES);
|
||||
|
||||
appendProperties("es.logger.level", "es.node.mode", "es.node.local", TestCluster.TESTS_ENABLE_MOCK_MODULES,
|
||||
"tests.assertion.disabled");
|
||||
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