Skip to content

Commit 8bb703b

Browse files
neetikasinghalbrusic
authored andcommitted
Parameterize tests for concurrent search 3 (opensearch-project#9982)
Signed-off-by: Neetika Singhal <[email protected]> Signed-off-by: Ivan Brusic <[email protected]>
1 parent 6dd5a71 commit 8bb703b

File tree

34 files changed

+595
-40
lines changed

34 files changed

+595
-40
lines changed

modules/analysis-common/src/internalClusterTest/java/org/opensearch/analysis/common/QueryStringWithAnalyzersIT.java

+24-2
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,42 @@
3232

3333
package org.opensearch.analysis.common;
3434

35+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
36+
3537
import org.opensearch.action.search.SearchResponse;
3638
import org.opensearch.common.settings.Settings;
39+
import org.opensearch.common.util.FeatureFlags;
3740
import org.opensearch.index.query.Operator;
3841
import org.opensearch.plugins.Plugin;
39-
import org.opensearch.test.OpenSearchIntegTestCase;
42+
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
4043

4144
import java.util.Arrays;
4245
import java.util.Collection;
4346

4447
import static org.opensearch.index.query.QueryBuilders.queryStringQuery;
48+
import static org.opensearch.search.SearchService.CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING;
4549
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
4650
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount;
4751

48-
public class QueryStringWithAnalyzersIT extends OpenSearchIntegTestCase {
52+
public class QueryStringWithAnalyzersIT extends ParameterizedOpenSearchIntegTestCase {
53+
54+
public QueryStringWithAnalyzersIT(Settings dynamicSettings) {
55+
super(dynamicSettings);
56+
}
57+
58+
@ParametersFactory
59+
public static Collection<Object[]> parameters() {
60+
return Arrays.asList(
61+
new Object[] { Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), false).build() },
62+
new Object[] { Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), true).build() }
63+
);
64+
}
65+
66+
@Override
67+
protected Settings featureFlagSettings() {
68+
return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.CONCURRENT_SEGMENT_SEARCH, "true").build();
69+
}
70+
4971
@Override
5072
protected Collection<Class<? extends Plugin>> nodePlugins() {
5173
return Arrays.asList(CommonAnalysisModulePlugin.class);

modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java

+24-2
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,19 @@
3232

3333
package org.opensearch.analysis.common;
3434

35+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
36+
3537
import org.opensearch.action.search.SearchResponse;
3638
import org.opensearch.common.settings.Settings;
39+
import org.opensearch.common.util.FeatureFlags;
3740
import org.opensearch.common.xcontent.XContentFactory;
3841
import org.opensearch.core.xcontent.XContentBuilder;
3942
import org.opensearch.index.IndexSettings;
4043
import org.opensearch.index.query.Operator;
4144
import org.opensearch.plugins.Plugin;
4245
import org.opensearch.search.builder.SearchSourceBuilder;
4346
import org.opensearch.search.fetch.subphase.highlight.HighlightBuilder;
44-
import org.opensearch.test.OpenSearchIntegTestCase;
47+
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
4548

4649
import java.io.IOException;
4750
import java.util.Arrays;
@@ -55,6 +58,7 @@
5558
import static org.opensearch.index.query.QueryBuilders.matchPhraseQuery;
5659
import static org.opensearch.index.query.QueryBuilders.matchQuery;
5760
import static org.opensearch.index.query.QueryBuilders.termQuery;
61+
import static org.opensearch.search.SearchService.CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING;
5862
import static org.opensearch.search.builder.SearchSourceBuilder.highlight;
5963
import static org.opensearch.search.builder.SearchSourceBuilder.searchSource;
6064
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked;
@@ -64,7 +68,25 @@
6468
import static org.hamcrest.Matchers.equalTo;
6569
import static org.hamcrest.Matchers.startsWith;
6670

67-
public class HighlighterWithAnalyzersTests extends OpenSearchIntegTestCase {
71+
public class HighlighterWithAnalyzersTests extends ParameterizedOpenSearchIntegTestCase {
72+
73+
public HighlighterWithAnalyzersTests(Settings dynamicSettings) {
74+
super(dynamicSettings);
75+
}
76+
77+
@ParametersFactory
78+
public static Collection<Object[]> parameters() {
79+
return Arrays.asList(
80+
new Object[] { Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), false).build() },
81+
new Object[] { Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), true).build() }
82+
);
83+
}
84+
85+
@Override
86+
protected Settings featureFlagSettings() {
87+
return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.CONCURRENT_SEGMENT_SEARCH, "true").build();
88+
}
89+
6890
@Override
6991
protected Collection<Class<? extends Plugin>> nodePlugins() {
7092
return Arrays.asList(CommonAnalysisModulePlugin.class);

modules/geo/src/internalClusterTest/java/org/opensearch/geo/GeoModulePluginIntegTestCase.java

+26-2
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,50 @@
88

99
package org.opensearch.geo;
1010

11+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
12+
13+
import org.opensearch.common.settings.Settings;
14+
import org.opensearch.common.util.FeatureFlags;
1115
import org.opensearch.geometry.utils.StandardValidator;
1216
import org.opensearch.geometry.utils.WellKnownText;
1317
import org.opensearch.index.mapper.GeoShapeFieldMapper;
1418
import org.opensearch.plugins.Plugin;
15-
import org.opensearch.test.OpenSearchIntegTestCase;
19+
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
1620
import org.opensearch.test.TestGeoShapeFieldMapperPlugin;
1721

22+
import java.util.Arrays;
1823
import java.util.Collection;
1924
import java.util.Collections;
2025

26+
import static org.opensearch.search.SearchService.CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING;
27+
2128
/**
2229
* This is the base class for all the Geo related integration tests. Use this class to add the features and settings
2330
* for the test cluster on which integration tests are running.
2431
*/
25-
public abstract class GeoModulePluginIntegTestCase extends OpenSearchIntegTestCase {
32+
public abstract class GeoModulePluginIntegTestCase extends ParameterizedOpenSearchIntegTestCase {
2633

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

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

38+
public GeoModulePluginIntegTestCase(Settings dynamicSettings) {
39+
super(dynamicSettings);
40+
}
41+
42+
@ParametersFactory
43+
public static Collection<Object[]> parameters() {
44+
return Arrays.asList(
45+
new Object[] { Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), false).build() },
46+
new Object[] { Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), true).build() }
47+
);
48+
}
49+
50+
@Override
51+
protected Settings featureFlagSettings() {
52+
return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.CONCURRENT_SEGMENT_SEARCH, "true").build();
53+
}
54+
3155
/**
3256
* Returns a collection of plugins that should be loaded on each node for doing the integration tests. As this
3357
* geo plugin is not getting packaged in a zip, we need to load it before the tests run.

modules/geo/src/internalClusterTest/java/org/opensearch/geo/search/MissingValueIT.java

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import org.opensearch.action.search.SearchResponse;
1212
import org.opensearch.common.geo.GeoPoint;
13+
import org.opensearch.common.settings.Settings;
1314
import org.opensearch.geo.GeoModulePluginIntegTestCase;
1415
import org.opensearch.geo.search.aggregations.common.GeoBoundsHelper;
1516
import org.opensearch.geo.search.aggregations.metrics.GeoBounds;
@@ -43,6 +44,10 @@ public class MissingValueIT extends GeoModulePluginIntegTestCase {
4344
private GeoPoint bottomRight;
4445
private GeoPoint topLeft;
4546

47+
public MissingValueIT(Settings dynamicSettings) {
48+
super(dynamicSettings);
49+
}
50+
4651
@Override
4752
protected void setupSuiteScopeCluster() throws Exception {
4853
assertAcked(

modules/geo/src/internalClusterTest/java/org/opensearch/geo/search/aggregations/bucket/AbstractGeoBucketAggregationIntegTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public abstract class AbstractGeoBucketAggregationIntegTest extends GeoModulePlu
6767

6868
protected final Version version = VersionUtils.randomIndexCompatibleVersion(random());
6969

70+
public AbstractGeoBucketAggregationIntegTest(Settings dynamicSettings) {
71+
super(dynamicSettings);
72+
}
73+
7074
@Override
7175
protected boolean forbidPrivateIndexSettings() {
7276
return false;

modules/geo/src/internalClusterTest/java/org/opensearch/geo/search/aggregations/bucket/GeoHashGridIT.java

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.opensearch.common.geo.GeoBoundingBox;
3636
import org.opensearch.common.geo.GeoPoint;
3737
import org.opensearch.common.geo.GeoShapeDocValue;
38+
import org.opensearch.common.settings.Settings;
3839
import org.opensearch.geo.search.aggregations.bucket.geogrid.GeoGrid;
3940
import org.opensearch.geo.search.aggregations.bucket.geogrid.GeoGridAggregationBuilder;
4041
import org.opensearch.geo.search.aggregations.common.GeoBoundsHelper;
@@ -64,6 +65,10 @@ public class GeoHashGridIT extends AbstractGeoBucketAggregationIntegTest {
6465

6566
private static final String AGG_NAME = "geohashgrid";
6667

68+
public GeoHashGridIT(Settings dynamicSettings) {
69+
super(dynamicSettings);
70+
}
71+
6772
@Override
6873
public void setupSuiteScopeCluster() throws Exception {
6974
Random random = random();

modules/geo/src/internalClusterTest/java/org/opensearch/geo/search/aggregations/bucket/GeoTileGridIT.java

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.opensearch.common.geo.GeoBoundingBox;
1313
import org.opensearch.common.geo.GeoPoint;
1414
import org.opensearch.common.geo.GeoShapeDocValue;
15+
import org.opensearch.common.settings.Settings;
1516
import org.opensearch.geo.search.aggregations.bucket.geogrid.GeoGrid;
1617
import org.opensearch.geo.search.aggregations.bucket.geogrid.GeoGridAggregationBuilder;
1718
import org.opensearch.geo.search.aggregations.common.GeoBoundsHelper;
@@ -38,6 +39,10 @@ public class GeoTileGridIT extends AbstractGeoBucketAggregationIntegTest {
3839

3940
private static final String AGG_NAME = "geotilegrid";
4041

42+
public GeoTileGridIT(Settings dynamicSettings) {
43+
super(dynamicSettings);
44+
}
45+
4146
@Override
4247
public void setupSuiteScopeCluster() throws Exception {
4348
final Random random = random();

modules/geo/src/internalClusterTest/java/org/opensearch/geo/search/aggregations/bucket/ShardReduceIT.java

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import org.opensearch.action.index.IndexRequestBuilder;
1212
import org.opensearch.action.search.SearchResponse;
13+
import org.opensearch.common.settings.Settings;
1314
import org.opensearch.geo.GeoModulePluginIntegTestCase;
1415
import org.opensearch.geo.search.aggregations.bucket.geogrid.GeoGrid;
1516
import org.opensearch.geo.tests.common.AggregationBuilders;
@@ -34,6 +35,10 @@
3435
@OpenSearchIntegTestCase.SuiteScopeTestCase
3536
public class ShardReduceIT extends GeoModulePluginIntegTestCase {
3637

38+
public ShardReduceIT(Settings dynamicSettings) {
39+
super(dynamicSettings);
40+
}
41+
3742
private IndexRequestBuilder indexDoc(String date, int value) throws Exception {
3843
return client().prepareIndex("idx")
3944
.setSource(

modules/geo/src/internalClusterTest/java/org/opensearch/geo/search/aggregations/metrics/AbstractGeoAggregatorModulePluginTestCase.java

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ public abstract class AbstractGeoAggregatorModulePluginTestCase extends GeoModul
6565
protected static Map<String, Integer> expectedDocCountsForGeoHash = null;
6666
protected static Map<String, GeoPoint> expectedCentroidsForGeoHash = null;
6767

68+
public AbstractGeoAggregatorModulePluginTestCase(Settings dynamicSettings) {
69+
super(dynamicSettings);
70+
}
71+
6872
@Override
6973
public void setupSuiteScopeCluster() throws Exception {
7074
createIndex(UNMAPPED_IDX_NAME);

modules/geo/src/internalClusterTest/java/org/opensearch/geo/search/aggregations/metrics/GeoBoundsITTestCase.java

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import org.opensearch.action.search.SearchResponse;
3636
import org.opensearch.common.geo.GeoPoint;
37+
import org.opensearch.common.settings.Settings;
3738
import org.opensearch.core.common.util.BigArray;
3839
import org.opensearch.search.aggregations.InternalAggregation;
3940
import org.opensearch.search.aggregations.bucket.global.Global;
@@ -61,6 +62,10 @@
6162
public class GeoBoundsITTestCase extends AbstractGeoAggregatorModulePluginTestCase {
6263
private static final String aggName = "geoBounds";
6364

65+
public GeoBoundsITTestCase(Settings dynamicSettings) {
66+
super(dynamicSettings);
67+
}
68+
6469
public void testSingleValuedField() throws Exception {
6570
SearchResponse response = client().prepareSearch(IDX_NAME)
6671
.addAggregation(geoBounds(aggName).field(SINGLE_VALUED_FIELD_NAME).wrapLongitude(false))

modules/geo/src/internalClusterTest/java/org/opensearch/geo/search/aggregations/metrics/GeoCentroidITTestCase.java

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
import org.opensearch.action.search.SearchResponse;
3636
import org.opensearch.common.geo.GeoPoint;
37+
import org.opensearch.common.settings.Settings;
3738
import org.opensearch.geo.search.aggregations.bucket.geogrid.GeoGrid;
3839
import org.opensearch.geo.tests.common.AggregationBuilders;
3940
import org.opensearch.search.aggregations.metrics.GeoCentroid;
@@ -51,6 +52,10 @@
5152
public class GeoCentroidITTestCase extends AbstractGeoAggregatorModulePluginTestCase {
5253
private static final String aggName = "geoCentroid";
5354

55+
public GeoCentroidITTestCase(Settings dynamicSettings) {
56+
super(dynamicSettings);
57+
}
58+
5459
public void testSingleValueFieldAsSubAggToGeohashGrid() throws Exception {
5560
SearchResponse response = client().prepareSearch(HIGH_CARD_IDX_NAME)
5661
.addAggregation(

modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java

+25-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@
3232

3333
package org.opensearch.script.expression;
3434

35+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
36+
3537
import org.opensearch.action.search.SearchPhaseExecutionException;
3638
import org.opensearch.action.search.SearchRequestBuilder;
3739
import org.opensearch.action.search.SearchResponse;
3840
import org.opensearch.action.search.SearchType;
3941
import org.opensearch.action.update.UpdateRequestBuilder;
4042
import org.opensearch.common.lucene.search.function.CombineFunction;
43+
import org.opensearch.common.settings.Settings;
44+
import org.opensearch.common.util.FeatureFlags;
4145
import org.opensearch.common.xcontent.XContentFactory;
4246
import org.opensearch.core.xcontent.XContentBuilder;
4347
import org.opensearch.index.query.QueryBuilders;
@@ -53,9 +57,10 @@
5357
import org.opensearch.search.aggregations.pipeline.SimpleValue;
5458
import org.opensearch.search.sort.SortBuilders;
5559
import org.opensearch.search.sort.SortOrder;
56-
import org.opensearch.test.OpenSearchIntegTestCase;
60+
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;
5761
import org.opensearch.test.hamcrest.OpenSearchAssertions;
5862

63+
import java.util.Arrays;
5964
import java.util.Collection;
6065
import java.util.Collections;
6166
import java.util.HashMap;
@@ -64,6 +69,7 @@
6469

6570
import static org.opensearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
6671
import static org.opensearch.common.xcontent.XContentFactory.jsonBuilder;
72+
import static org.opensearch.search.SearchService.CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING;
6773
import static org.opensearch.search.aggregations.AggregationBuilders.histogram;
6874
import static org.opensearch.search.aggregations.AggregationBuilders.sum;
6975
import static org.opensearch.search.aggregations.PipelineAggregatorBuilders.bucketScript;
@@ -74,7 +80,24 @@
7480
import static org.hamcrest.Matchers.notNullValue;
7581

7682
// TODO: please convert to unit tests!
77-
public class MoreExpressionIT extends OpenSearchIntegTestCase {
83+
public class MoreExpressionIT extends ParameterizedOpenSearchIntegTestCase {
84+
85+
public MoreExpressionIT(Settings dynamicSettings) {
86+
super(dynamicSettings);
87+
}
88+
89+
@ParametersFactory
90+
public static Collection<Object[]> parameters() {
91+
return Arrays.asList(
92+
new Object[] { Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), false).build() },
93+
new Object[] { Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), true).build() }
94+
);
95+
}
96+
97+
@Override
98+
protected Settings featureFlagSettings() {
99+
return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.CONCURRENT_SEGMENT_SEARCH, "true").build();
100+
}
78101

79102
@Override
80103
protected Collection<Class<? extends Plugin>> nodePlugins() {

0 commit comments

Comments
 (0)