From 8d23827c76e3de5c6f8134f27f25a138eaaef44d Mon Sep 17 00:00:00 2001 From: Fabrizio Fortino Date: Fri, 29 Nov 2024 09:33:27 +0100 Subject: [PATCH 1/2] OAK-11289: remove remaining elastiknn references in test --- .../oak/plugins/index/elastic/ElasticTestUtils.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticTestUtils.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticTestUtils.java index d7aab484ef8..b3c44d91de5 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticTestUtils.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticTestUtils.java @@ -20,17 +20,6 @@ public final class ElasticTestUtils { - // Set this connection string as - // ://:?key_id=<>,key_secret=<> - // key_id and key_secret are optional in case the ES server - // needs authentication - // Do not set this if docker is running and you want to run the tests on docker instead. - public static final String ELASTIC_CONNECTION_STRING = System.getProperty("elasticConnectionString"); - - public static final String ELASTIC_DOCKER_IMAGE_VERSION = System.getProperty("elasticDockerImageVersion"); - public static final String ELASTIC_KNN_PLUGIN_URI_KEY = "elasticKnnPluginUri"; - public static final String ELASTIC_KNN_PLUGIN_URI = System.getProperty(ELASTIC_KNN_PLUGIN_URI_KEY); - public static String randomString(int size) { return randomString(new Random(42), size); } From b39313ef5976b0eab04c516d5073a622dbcb5671 Mon Sep 17 00:00:00 2001 From: Fabrizio Fortino Date: Fri, 29 Nov 2024 09:33:56 +0100 Subject: [PATCH 2/2] OAK-11289: simplified ElasticConnectionRule creation --- .../plugins/index/elastic/ElasticConnectionRule.java | 11 +++++++++++ .../index/elastic/ElasticDynamicBoostTest.java | 3 +-- .../oak/plugins/index/elastic/ElasticExcerptTest.java | 4 +--- .../oak/plugins/index/elastic/ElasticFacetTest.java | 3 +-- .../index/elastic/ElasticFullTextAnalyzerTest.java | 3 +-- .../index/elastic/ElasticFullTextIndexTest.java | 3 +-- .../index/elastic/ElasticFunctionIndexCommonTest.java | 3 +-- .../index/elastic/ElasticIndexAggregation2Test.java | 3 +-- .../index/elastic/ElasticIndexAggregationTest.java | 3 +-- ...exAndTraversalQueriesSimilarResultsCommonTest.java | 3 +-- .../ElasticIndexDescendantSpellcheckCommonTest.java | 3 +-- .../ElasticIndexDescendantSuggestionCommonTest.java | 3 +-- .../elastic/ElasticIndexExclusionQueryCommonTest.java | 3 +-- .../elastic/ElasticIndexImproperUsageCommonTest.java | 3 +-- .../ElasticIndexPathRestrictionCommonTest.java | 5 +---- .../index/elastic/ElasticIndexPlannerCommonTest.java | 3 +-- .../elastic/ElasticIndexProviderServiceTest.java | 2 +- .../index/elastic/ElasticIndexQueryCommonTest.java | 3 +-- .../ElasticIndexQuerySQL2OptimisationCommonTest.java | 7 ++----- .../elastic/ElasticIndexSuggestionCommonTest.java | 3 +-- .../oak/plugins/index/elastic/ElasticOrderByTest.java | 3 +-- .../index/elastic/ElasticPropertyIndexCommonTest.java | 3 +-- .../oak/plugins/index/elastic/ElasticReindexTest.java | 3 +-- .../index/elastic/ElasticSpellcheckCommonTest.java | 3 +-- .../ElasticStrictPathRestrictionEnableCommonTest.java | 3 +-- .../oak/plugins/index/elastic/ElasticTestServer.java | 6 ++---- 26 files changed, 38 insertions(+), 57 deletions(-) diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticConnectionRule.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticConnectionRule.java index d47210d8f46..499404aded1 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticConnectionRule.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticConnectionRule.java @@ -40,6 +40,13 @@ public class ElasticConnectionRule extends ExternalResource { private static final Logger LOG = LoggerFactory.getLogger(ElasticConnectionRule.class); + // Set this connection string as + // ://:?key_id=<>,key_secret=<> + // key_id and key_secret are optional in case the ES server + // needs authentication + // Do not set this if docker is running and you want to run the tests on docker instead. + private static final String ELASTIC_CONNECTION_STRING = System.getProperty("elasticConnectionString"); + private final String indexPrefix; private static boolean useDocker = false; @@ -47,6 +54,10 @@ public class ElasticConnectionRule extends ExternalResource { private ElasticConnectionModel elasticConnectionModel; + public ElasticConnectionRule() { + this(ELASTIC_CONNECTION_STRING); + } + public ElasticConnectionRule(String elasticConnectionString) { this(elasticConnectionString, "elastic_test_" + diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticDynamicBoostTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticDynamicBoostTest.java index 9fb2172c968..d996da9da0e 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticDynamicBoostTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticDynamicBoostTest.java @@ -28,8 +28,7 @@ public class ElasticDynamicBoostTest extends DynamicBoostCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); public ElasticDynamicBoostTest() { this.indexOptions = new ElasticIndexOptions(); diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticExcerptTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticExcerptTest.java index a1740e07ff6..2d8ddfcad75 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticExcerptTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticExcerptTest.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.jackrabbit.oak.plugins.index.elastic; import org.apache.jackrabbit.oak.api.*; @@ -28,8 +27,7 @@ public class ElasticExcerptTest extends ExcerptTest { @ClassRule - public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule( - ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); public ElasticExcerptTest() { indexOptions = new ElasticIndexOptions(); diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFacetTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFacetTest.java index 9a42b9c21ac..cd6cd3cec42 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFacetTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFacetTest.java @@ -27,8 +27,7 @@ public class ElasticFacetTest extends FacetCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING, "elastic_test_"); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); protected Repository createJcrRepository() { indexOptions = new ElasticIndexOptions(); diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFullTextAnalyzerTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFullTextAnalyzerTest.java index a175a550913..179d48892be 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFullTextAnalyzerTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFullTextAnalyzerTest.java @@ -33,8 +33,7 @@ public class ElasticFullTextAnalyzerTest extends FullTextAnalyzerCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); public ElasticFullTextAnalyzerTest() { this.indexOptions = new ElasticIndexOptions(); diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFullTextIndexTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFullTextIndexTest.java index eab97e65ec3..37885b7502d 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFullTextIndexTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFullTextIndexTest.java @@ -23,8 +23,7 @@ public class ElasticFullTextIndexTest extends FullTextIndexCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); public ElasticFullTextIndexTest() { this.indexOptions = new ElasticIndexOptions(); diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFunctionIndexCommonTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFunctionIndexCommonTest.java index 52a510108bb..423dc86cdaf 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFunctionIndexCommonTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFunctionIndexCommonTest.java @@ -37,8 +37,7 @@ public class ElasticFunctionIndexCommonTest extends FunctionIndexCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule( - ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); public ElasticFunctionIndexCommonTest() { indexOptions = new ElasticIndexOptions(); diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexAggregation2Test.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexAggregation2Test.java index 0d4f1ef33a4..3152438a78b 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexAggregation2Test.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexAggregation2Test.java @@ -43,8 +43,7 @@ public class ElasticIndexAggregation2Test extends IndexAggregation2CommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule( - ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); private final ElasticTestRepositoryBuilder builder; diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexAggregationTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexAggregationTest.java index e8632ed2f3e..174c62c0178 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexAggregationTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexAggregationTest.java @@ -26,8 +26,7 @@ public class ElasticIndexAggregationTest extends IndexAggregationCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule( - ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); public ElasticIndexAggregationTest() { this.indexOptions = new ElasticIndexOptions(); diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexAndTraversalQueriesSimilarResultsCommonTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexAndTraversalQueriesSimilarResultsCommonTest.java index 94eae194cde..f1de7eb2cd6 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexAndTraversalQueriesSimilarResultsCommonTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexAndTraversalQueriesSimilarResultsCommonTest.java @@ -25,8 +25,7 @@ public class ElasticIndexAndTraversalQueriesSimilarResultsCommonTest extends IndexAndTraversalQueriesSimilarResultsCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); public ElasticIndexAndTraversalQueriesSimilarResultsCommonTest() { indexOptions = new ElasticIndexOptions(); diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDescendantSpellcheckCommonTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDescendantSpellcheckCommonTest.java index eb2e0c60fc0..18a653d2e83 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDescendantSpellcheckCommonTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDescendantSpellcheckCommonTest.java @@ -28,8 +28,7 @@ public class ElasticIndexDescendantSpellcheckCommonTest extends IndexDescendantSpellcheckCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); @Override protected Repository createJcrRepository() { diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDescendantSuggestionCommonTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDescendantSuggestionCommonTest.java index 4f40594b8d9..3d6bbf69812 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDescendantSuggestionCommonTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDescendantSuggestionCommonTest.java @@ -26,8 +26,7 @@ public class ElasticIndexDescendantSuggestionCommonTest extends IndexDescendantSuggestionCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); @Override protected Repository createJcrRepository() { diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexExclusionQueryCommonTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexExclusionQueryCommonTest.java index 90ca4023134..027650702bb 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexExclusionQueryCommonTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexExclusionQueryCommonTest.java @@ -25,8 +25,7 @@ public class ElasticIndexExclusionQueryCommonTest extends IndexExclusionQueryCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule( - ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); @Override protected ContentRepository createRepository() { diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexImproperUsageCommonTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexImproperUsageCommonTest.java index 188f5143054..31f910e0ca3 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexImproperUsageCommonTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexImproperUsageCommonTest.java @@ -25,8 +25,7 @@ public class ElasticIndexImproperUsageCommonTest extends IndexImproperUsageCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); @Override protected ContentRepository createRepository() { diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexPathRestrictionCommonTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexPathRestrictionCommonTest.java index c469b3ccb5b..32eac70ec42 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexPathRestrictionCommonTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexPathRestrictionCommonTest.java @@ -34,19 +34,16 @@ import org.junit.Rule; import org.junit.contrib.java.lang.system.ProvideSystemProperty; import org.junit.contrib.java.lang.system.RestoreSystemProperties; -import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.slf4j.event.Level; import java.util.Collection; import java.util.Collections; -@RunWith(Parameterized.class) public class ElasticIndexPathRestrictionCommonTest extends IndexPathRestrictionCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); // Default refresh is 1 minute - so we need to lower that otherwise test would need to wait at least 1 minute // before it can get the estimated doc count from the remote ES index diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexPlannerCommonTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexPlannerCommonTest.java index f96ca353841..516148a5c50 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexPlannerCommonTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexPlannerCommonTest.java @@ -71,8 +71,7 @@ public class ElasticIndexPlannerCommonTest extends IndexPlannerCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); // Default refresh is 1 minute - so we need to lower that otherwise test would need to wait at least 1 minute // before it can get the estimated doc count from the remote ES index diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderServiceTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderServiceTest.java index 9141cb86eb8..8c07f70b87a 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderServiceTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexProviderServiceTest.java @@ -62,7 +62,7 @@ public class ElasticIndexProviderServiceTest { public final OsgiContext context = new OsgiContext(); @ClassRule - public static ElasticConnectionRule elasticRule = new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static ElasticConnectionRule elasticRule = new ElasticConnectionRule(); private final ElasticIndexProviderService service = new ElasticIndexProviderService(); diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexQueryCommonTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexQueryCommonTest.java index e5b25dd063e..caf3cb47395 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexQueryCommonTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexQueryCommonTest.java @@ -32,8 +32,7 @@ public class ElasticIndexQueryCommonTest extends IndexQueryCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); public ElasticIndexQueryCommonTest() { indexOptions = new ElasticIndexOptions(); diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexQuerySQL2OptimisationCommonTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexQuerySQL2OptimisationCommonTest.java index 8590fdc36b9..71ec6738726 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexQuerySQL2OptimisationCommonTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexQuerySQL2OptimisationCommonTest.java @@ -33,16 +33,13 @@ public class ElasticIndexQuerySQL2OptimisationCommonTest extends IndexQuerySQL2OptimisationCommonTest { protected TestRepository repositoryOptionsUtil; - private final ElasticConnection esConnection; private final ElasticIndexTracker indexTracker; - @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); public ElasticIndexQuerySQL2OptimisationCommonTest() { - this.esConnection = elasticRule.useDocker() ? elasticRule.getElasticConnectionForDocker() : + ElasticConnection esConnection = elasticRule.useDocker() ? elasticRule.getElasticConnectionForDocker() : elasticRule.getElasticConnectionFromString(); this.indexTracker = new ElasticIndexTracker(esConnection, new ElasticMetricHandler(StatisticsProvider.NOOP)); this.editorProvider = new ElasticIndexEditorProvider(indexTracker, esConnection, diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexSuggestionCommonTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexSuggestionCommonTest.java index fb336de9641..32e97323eba 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexSuggestionCommonTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexSuggestionCommonTest.java @@ -33,8 +33,7 @@ public class ElasticIndexSuggestionCommonTest extends IndexSuggestionCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); protected Repository createJcrRepository() { indexOptions = new ElasticIndexOptions(); diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticOrderByTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticOrderByTest.java index 980ff6bf542..1aa1e797504 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticOrderByTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticOrderByTest.java @@ -23,8 +23,7 @@ public class ElasticOrderByTest extends OrderByCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); public ElasticOrderByTest() { indexOptions = new ElasticIndexOptions(); diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticPropertyIndexCommonTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticPropertyIndexCommonTest.java index b2c46801ed8..1b6e3856f62 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticPropertyIndexCommonTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticPropertyIndexCommonTest.java @@ -23,8 +23,7 @@ public class ElasticPropertyIndexCommonTest extends PropertyIndexCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); public ElasticPropertyIndexCommonTest() { indexOptions = new ElasticIndexOptions(); diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticReindexTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticReindexTest.java index b3090fe2b30..57e70bd2846 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticReindexTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticReindexTest.java @@ -63,8 +63,7 @@ public class ElasticReindexTest { protected int DEFAULT_ASYNC_INDEXING_TIME_IN_SECONDS = 5; @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); private Session adminSession; private QueryManager qe; diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticSpellcheckCommonTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticSpellcheckCommonTest.java index 523d0a96102..ab396da142a 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticSpellcheckCommonTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticSpellcheckCommonTest.java @@ -36,8 +36,7 @@ public class ElasticSpellcheckCommonTest extends SpellcheckCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); @After public void cleanup() { diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticStrictPathRestrictionEnableCommonTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticStrictPathRestrictionEnableCommonTest.java index 8d633f3ec95..8724936b3e8 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticStrictPathRestrictionEnableCommonTest.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticStrictPathRestrictionEnableCommonTest.java @@ -25,8 +25,7 @@ public class ElasticStrictPathRestrictionEnableCommonTest extends StrictPathRestrictionEnableCommonTest { @ClassRule - public static final ElasticConnectionRule elasticRule = - new ElasticConnectionRule(ElasticTestUtils.ELASTIC_CONNECTION_STRING); + public static final ElasticConnectionRule elasticRule = new ElasticConnectionRule(); @Override protected ContentRepository createRepository() { diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticTestServer.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticTestServer.java index 8c5d77867e9..4efcc665e5e 100644 --- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticTestServer.java +++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticTestServer.java @@ -35,6 +35,7 @@ public class ElasticTestServer implements AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(ElasticTestServer.class); + private static final String ELASTIC_DOCKER_IMAGE_VERSION = System.getProperty("elasticDockerImageVersion"); private static final ElasticTestServer SERVER = new ElasticTestServer(); private static volatile ElasticsearchContainer CONTAINER; @@ -62,10 +63,7 @@ public static synchronized ElasticsearchContainer getESTestServer() { } private synchronized void setup() { - String esDockerImageVersion = ElasticTestUtils.ELASTIC_DOCKER_IMAGE_VERSION; - if (esDockerImageVersion == null) { - esDockerImageVersion = Version.VERSION.toString(); - } + String esDockerImageVersion = ELASTIC_DOCKER_IMAGE_VERSION != null ? ELASTIC_DOCKER_IMAGE_VERSION : Version.VERSION.toString(); LOG.info("Elasticsearch test Docker image version: {}.", esDockerImageVersion); checkIfDockerClientAvailable(); Network network = Network.newNetwork();