Skip to content

Commit

Permalink
Extract cluster management for integration tests into JUnit test rule…
Browse files Browse the repository at this point in the history
… out of OpenSearchIntegTestCase (opensearch-project#11877)

* Extract cluster management for integration tests into JUnit test rule out of OpenSearchIntegTestCase

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>

* Branched off parametrized tests into static / dynamic settings flavors

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>

* Address code review comments

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>

* Refactor internalCluster() method to return an Optional value

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>

* Address code review comments

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>

---------

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
reta committed Jan 18, 2024
1 parent 6dee955 commit c267c5a
Show file tree
Hide file tree
Showing 157 changed files with 1,068 additions and 829 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Use slice_size == shard_size heuristic in terms aggs for concurrent segment search and properly calculate the doc_count_error ([#11732](https://github.com/opensearch-project/OpenSearch/pull/11732))
- Added Support for dynamically adding SearchRequestOperationsListeners with SearchRequestOperationsCompositeListenerFactory ([#11526](https://github.com/opensearch-project/OpenSearch/pull/11526))
- Ensure Jackson default maximums introduced in 2.16.0 do not conflict with OpenSearch settings ([#11890](https://github.com/opensearch-project/OpenSearch/pull/11890))
- Extract cluster management for integration tests into JUnit test rule out of OpenSearchIntegTestCase ([#11877](https://github.com/opensearch-project/OpenSearch/pull/11877))

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.index.query.Operator;
import org.opensearch.plugins.Plugin;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;

import java.util.Arrays;
import java.util.Collection;
Expand All @@ -49,10 +49,10 @@
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount;

public class QueryStringWithAnalyzersIT extends ParameterizedOpenSearchIntegTestCase {
public class QueryStringWithAnalyzersIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {

public QueryStringWithAnalyzersIT(Settings dynamicSettings) {
super(dynamicSettings);
public QueryStringWithAnalyzersIT(Settings staticSettings) {
super(staticSettings);
}

@ParametersFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import org.opensearch.plugins.Plugin;
import org.opensearch.search.builder.SearchSourceBuilder;
import org.opensearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;

import java.io.IOException;
import java.util.Arrays;
Expand All @@ -68,10 +68,10 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.startsWith;

public class HighlighterWithAnalyzersTests extends ParameterizedOpenSearchIntegTestCase {
public class HighlighterWithAnalyzersTests extends ParameterizedStaticSettingsOpenSearchIntegTestCase {

public HighlighterWithAnalyzersTests(Settings dynamicSettings) {
super(dynamicSettings);
public HighlighterWithAnalyzersTests(Settings staticSettings) {
super(staticSettings);
}

@ParametersFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.opensearch.geometry.utils.WellKnownText;
import org.opensearch.index.mapper.GeoShapeFieldMapper;
import org.opensearch.plugins.Plugin;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;
import org.opensearch.test.TestGeoShapeFieldMapperPlugin;

import java.util.Arrays;
Expand All @@ -29,14 +29,14 @@
* This is the base class for all the Geo related integration tests. Use this class to add the features and settings
* for the test cluster on which integration tests are running.
*/
public abstract class GeoModulePluginIntegTestCase extends ParameterizedOpenSearchIntegTestCase {
public abstract class GeoModulePluginIntegTestCase extends ParameterizedStaticSettingsOpenSearchIntegTestCase {

protected static final double GEOHASH_TOLERANCE = 1E-5D;

protected static final WellKnownText WKT = new WellKnownText(true, new StandardValidator(true));

public GeoModulePluginIntegTestCase(Settings dynamicSettings) {
super(dynamicSettings);
public GeoModulePluginIntegTestCase(Settings staticSettings) {
super(staticSettings);
}

@ParametersFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public class MissingValueIT extends GeoModulePluginIntegTestCase {
private GeoPoint bottomRight;
private GeoPoint topLeft;

public MissingValueIT(Settings dynamicSettings) {
super(dynamicSettings);
public MissingValueIT(Settings staticSettings) {
super(staticSettings);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import org.opensearch.search.aggregations.pipeline.SimpleValue;
import org.opensearch.search.sort.SortBuilders;
import org.opensearch.search.sort.SortOrder;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;
import org.opensearch.test.hamcrest.OpenSearchAssertions;

import java.util.Arrays;
Expand All @@ -80,10 +80,10 @@
import static org.hamcrest.Matchers.notNullValue;

// TODO: please convert to unit tests!
public class MoreExpressionIT extends ParameterizedOpenSearchIntegTestCase {
public class MoreExpressionIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {

public MoreExpressionIT(Settings dynamicSettings) {
super(dynamicSettings);
public MoreExpressionIT(Settings staticSettings) {
super(staticSettings);
}

@ParametersFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.opensearch.script.ScriptType;
import org.opensearch.search.aggregations.AggregationBuilders;
import org.opensearch.search.builder.SearchSourceBuilder;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;

import java.io.IOException;
import java.util.Arrays;
Expand All @@ -54,10 +54,10 @@
import static org.hamcrest.Matchers.containsString;

//TODO: please convert to unit tests!
public class StoredExpressionIT extends ParameterizedOpenSearchIntegTestCase {
public class StoredExpressionIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {

public StoredExpressionIT(Settings dynamicSettings) {
super(dynamicSettings);
public StoredExpressionIT(Settings staticSettings) {
super(staticSettings);
}

@ParametersFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.opensearch.index.IndexNotFoundException;
import org.opensearch.plugins.Plugin;
import org.opensearch.script.ScriptType;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;

import java.util.Arrays;
import java.util.Collection;
Expand All @@ -58,10 +58,10 @@
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.core.Is.is;

public class MultiSearchTemplateIT extends ParameterizedOpenSearchIntegTestCase {
public class MultiSearchTemplateIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {

public MultiSearchTemplateIT(Settings dynamicSettings) {
super(dynamicSettings);
public MultiSearchTemplateIT(Settings staticSettings) {
super(staticSettings);
}

@ParametersFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.opensearch.plugins.Plugin;
import org.opensearch.test.InternalSettingsPlugin;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;

import java.io.IOException;
import java.util.Arrays;
Expand All @@ -51,10 +51,10 @@
import java.util.Map;

@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE)
public abstract class ParentChildTestCase extends ParameterizedOpenSearchIntegTestCase {
public abstract class ParentChildTestCase extends ParameterizedStaticSettingsOpenSearchIntegTestCase {

public ParentChildTestCase(Settings dynamicSettings) {
super(dynamicSettings);
public ParentChildTestCase(Settings staticSettings) {
super(staticSettings);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import org.opensearch.plugins.Plugin;
import org.opensearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.opensearch.search.sort.SortOrder;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;

import java.io.IOException;
import java.util.Arrays;
Expand Down Expand Up @@ -90,10 +90,10 @@
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.IsNull.notNullValue;

public class PercolatorQuerySearchIT extends ParameterizedOpenSearchIntegTestCase {
public class PercolatorQuerySearchIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {

public PercolatorQuerySearchIT(Settings dynamicSettings) {
super(dynamicSettings);
public PercolatorQuerySearchIT(Settings staticSettings) {
super(staticSettings);
}

@ParametersFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import org.opensearch.indices.IndexClosedException;
import org.opensearch.plugins.Plugin;
import org.opensearch.search.builder.SearchSourceBuilder;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;
import org.junit.Before;

import java.util.ArrayList;
Expand All @@ -62,14 +62,14 @@
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
import static org.hamcrest.Matchers.instanceOf;

public class RankEvalRequestIT extends ParameterizedOpenSearchIntegTestCase {
public class RankEvalRequestIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {

private static final String TEST_INDEX = "test";
private static final String INDEX_ALIAS = "alias0";
private static final int RELEVANT_RATING_1 = 1;

public RankEvalRequestIT(Settings dynamicSettings) {
super(dynamicSettings);
public RankEvalRequestIT(Settings staticSettings) {
super(staticSettings);
}

@ParametersFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
import org.opensearch.tasks.TaskInfo;
import org.opensearch.tasks.TaskManager;
import org.opensearch.test.InternalTestCluster;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportException;
import org.opensearch.transport.TransportResponseHandler;
Expand Down Expand Up @@ -99,16 +99,16 @@
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.instanceOf;

public class CancellableTasksIT extends ParameterizedOpenSearchIntegTestCase {
public class CancellableTasksIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {

static int idGenerator = 0;
static final Map<TestRequest, CountDownLatch> beforeSendLatches = ConcurrentCollections.newConcurrentMap();
static final Map<TestRequest, CountDownLatch> arrivedLatches = ConcurrentCollections.newConcurrentMap();
static final Map<TestRequest, CountDownLatch> beforeExecuteLatches = ConcurrentCollections.newConcurrentMap();
static final Map<TestRequest, CountDownLatch> completedLatches = ConcurrentCollections.newConcurrentMap();

public CancellableTasksIT(Settings dynamicSettings) {
super(dynamicSettings);
public CancellableTasksIT(Settings staticSettings) {
super(staticSettings);
}

@ParametersFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@

public class GetTermVectorsIT extends AbstractTermVectorsTestCase {

public GetTermVectorsIT(Settings dynamicSettings) {
super(dynamicSettings);
public GetTermVectorsIT(Settings staticSettings) {
super(staticSettings);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
import static org.hamcrest.Matchers.nullValue;

public class MultiTermVectorsIT extends AbstractTermVectorsTestCase {
public MultiTermVectorsIT(Settings dynamicSettings) {
super(dynamicSettings);
public MultiTermVectorsIT(Settings staticSettings) {
super(staticSettings);
}

public void testDuelESLucene() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;

import java.io.IOException;
import java.util.Arrays;
Expand All @@ -51,11 +51,11 @@
import static org.opensearch.search.SearchService.CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING;
import static org.hamcrest.Matchers.containsString;

public class IndexSortIT extends ParameterizedOpenSearchIntegTestCase {
public class IndexSortIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {
private static final XContentBuilder TEST_MAPPING = createTestMapping();

public IndexSortIT(Settings dynamicSettings) {
super(dynamicSettings);
public IndexSortIT(Settings staticSettings) {
super(staticSettings);
}

@ParametersFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.index.query.MatchPhraseQueryBuilder;
import org.opensearch.index.search.MatchQuery.ZeroTermsQuery;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;
import org.junit.Before;

import java.util.ArrayList;
Expand All @@ -55,12 +55,12 @@
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount;

public class MatchPhraseQueryIT extends ParameterizedOpenSearchIntegTestCase {
public class MatchPhraseQueryIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {

private static final String INDEX = "test";

public MatchPhraseQueryIT(Settings dynamicSettings) {
super(dynamicSettings);
public MatchPhraseQueryIT(Settings staticSettings) {
super(staticSettings);
}

@ParametersFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.opensearch.search.suggest.phrase.PhraseSuggestionBuilder;
import org.opensearch.search.suggest.term.TermSuggestionBuilder;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;

import java.util.Arrays;
import java.util.Collection;
Expand All @@ -68,10 +68,10 @@
import static org.hamcrest.Matchers.lessThanOrEqualTo;

@OpenSearchIntegTestCase.ClusterScope(minNumDataNodes = 2)
public class SuggestStatsIT extends ParameterizedOpenSearchIntegTestCase {
public class SuggestStatsIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {

public SuggestStatsIT(Settings dynamicSettings) {
super(dynamicSettings);
public SuggestStatsIT(Settings staticSettings) {
super(staticSettings);
}

@ParametersFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import org.opensearch.search.aggregations.bucket.histogram.DateHistogramInterval;
import org.opensearch.search.aggregations.bucket.histogram.Histogram;
import org.opensearch.search.aggregations.bucket.histogram.Histogram.Bucket;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;
import org.opensearch.test.hamcrest.OpenSearchAssertions;

import java.time.ZoneId;
Expand All @@ -69,7 +69,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;

public class IndicesRequestCacheIT extends ParameterizedOpenSearchIntegTestCase {
public class IndicesRequestCacheIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {
public IndicesRequestCacheIT(Settings settings) {
super(settings);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
import org.opensearch.search.SearchService;
import org.opensearch.search.sort.SortOrder;
import org.opensearch.test.OpenSearchIntegTestCase.ClusterScope;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedStaticSettingsOpenSearchIntegTestCase;
import org.junit.After;
import org.junit.Before;

Expand Down Expand Up @@ -94,9 +94,9 @@
* Integration tests for InternalCircuitBreakerService
*/
@ClusterScope(scope = TEST, numClientNodes = 0, maxNumDataNodes = 1)
public class CircuitBreakerServiceIT extends ParameterizedOpenSearchIntegTestCase {
public CircuitBreakerServiceIT(Settings dynamicSettings) {
super(dynamicSettings);
public class CircuitBreakerServiceIT extends ParameterizedStaticSettingsOpenSearchIntegTestCase {
public CircuitBreakerServiceIT(Settings staticSettings) {
super(staticSettings);
}

@ParametersFactory
Expand Down
Loading

0 comments on commit c267c5a

Please sign in to comment.