Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

### Changed
- Add instrumentation in rest and network layer. ([#9415](https://github.com/opensearch-project/OpenSearch/pull/9415))
- Allow parameterization of tests with OpenSearchIntegTestCase.SuiteScopeTestCase annotation ([#9916](https://github.com/opensearch-project/OpenSearch/pull/9916))

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@

package org.opensearch.search.aggregations;

import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;

import org.opensearch.action.search.SearchResponse;
import org.opensearch.common.geo.GeoPoint;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.search.aggregations.bucket.histogram.DateHistogramInterval;
import org.opensearch.search.aggregations.bucket.histogram.Histogram;
import org.opensearch.search.aggregations.bucket.terms.Terms;
Expand All @@ -43,7 +47,12 @@
import org.opensearch.search.aggregations.metrics.Percentiles;
import org.opensearch.search.aggregations.metrics.Stats;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.opensearch.test.ParameterizedOpenSearchIntegTestCase;

import java.util.Arrays;
import java.util.Collection;

import static org.opensearch.search.SearchService.CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING;
import static org.opensearch.search.aggregations.AggregationBuilders.cardinality;
import static org.opensearch.search.aggregations.AggregationBuilders.dateHistogram;
import static org.opensearch.search.aggregations.AggregationBuilders.geoCentroid;
Expand All @@ -56,7 +65,24 @@
import static org.hamcrest.Matchers.closeTo;

@OpenSearchIntegTestCase.SuiteScopeTestCase
public class MissingValueIT extends OpenSearchIntegTestCase {
public class MissingValueIT extends ParameterizedOpenSearchIntegTestCase {

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

@ParametersFactory
public static Collection<Object[]> parameters() {
return Arrays.asList(
new Object[] { Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), false).build() },
new Object[] { Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), true).build() }
);
}

@Override
protected Settings featureFlagSettings() {
return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.CONCURRENT_SEGMENT_SEARCH, "true").build();
}

@Override
protected int maximumNumberOfShards() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2365,8 +2365,12 @@ private static void initializeSuiteScope() throws Exception {
*/
assert INSTANCE == null;
if (isSuiteScopedTest(targetClass)) {
// note we need to do this this way to make sure this is reproducible
INSTANCE = (OpenSearchIntegTestCase) targetClass.getConstructor().newInstance();
// note we need to do this way to make sure this is reproducible
if (isSuiteScopedTestParameterized(targetClass)) {
INSTANCE = (OpenSearchIntegTestCase) targetClass.getConstructor(Settings.class).newInstance(Settings.EMPTY);
} else {
INSTANCE = (OpenSearchIntegTestCase) targetClass.getConstructor().newInstance();
}
boolean success = false;
try {
INSTANCE.printTestMessage("setup");
Expand Down Expand Up @@ -2461,6 +2465,16 @@ private static boolean isSuiteScopedTest(Class<?> clazz) {
return clazz.getAnnotation(SuiteScopeTestCase.class) != null;
}

/*
* For tests defined with, SuiteScopeTestCase return true if the
* class has a constructor that takes a single Settings parameter
* */
private static boolean isSuiteScopedTestParameterized(Class<?> clazz) {
return Arrays.stream(clazz.getConstructors())
.filter(x -> x.getParameterTypes().length == 1)
.anyMatch(x -> x.getParameterTypes()[0].equals(Settings.class));
}

/**
* If a test is annotated with {@link SuiteScopeTestCase}
* the checks and modifications that are applied to the used test cluster are only done after all tests
Expand Down