From e198c58a6b04575a0eadee403a4b92a856eedf02 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Tue, 17 Jun 2014 12:15:50 +0200 Subject: [PATCH] [TEST] Use test.bwc.version if compatibility version is not present --- .../test/ElasticsearchIntegrationTest.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java index 12a178d1a8d..38152262a14 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java @@ -185,7 +185,7 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase */ public static final String TESTS_COMPATIBILITY = "tests.compatibility"; - protected static final Version COMPATIBILITY_VERSION = Version.fromString(System.getProperty(TESTS_COMPATIBILITY)); + protected static final Version COMPATIBILITY_VERSION = Version.fromString(compatibilityVersionProperty()); /** * Threshold at which indexing switches from frequently async to frequently bulk. @@ -300,6 +300,16 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase } } + private Loading randomLoadingValues() { + if (COMPATIBILITY_VERSION.onOrAfter(Version.V_1_2_0)) { + // Loading.EAGER_GLOBAL_ORDINALS was added in 1,2.0 + return randomFrom(Loading.values()); + } else { + return randomFrom(Loading.LAZY, Loading.EAGER); + } + + } + /** * Creates a randomized index template. This template is used to pass in randomized settings on a * per index basis. Allows to enable/disable the randomization for number of shards and replicas @@ -331,7 +341,7 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase .startObject("mapping") .startObject("fielddata") .field(FieldDataType.FORMAT_KEY, randomFrom("paged_bytes", "fst")) // unfortunately doc values only work on not_analyzed fields - .field(Loading.KEY, randomFrom(Loading.values())) + .field(Loading.KEY, randomLoadingValues()) .endObject() .endObject() .endObject() @@ -1490,5 +1500,14 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase public @interface SuiteScopeTest { } + private static String compatibilityVersionProperty() { + final String version = System.getProperty(TESTS_COMPATIBILITY); + if (Strings.hasLength(version)) { + return version; + } + return System.getProperty(TESTS_BACKWARDS_COMPATIBILITY_VERSION); + } + + }