Skip to content

Commit

Permalink
Add base class for parameterizing the search based tests
Browse files Browse the repository at this point in the history
Signed-off-by: Neetika Singhal <[email protected]>
  • Loading branch information
neetikasinghal committed Aug 3, 2023
1 parent 8afb22a commit 110efe1
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 55 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Create separate SourceLookup instance per segment slice in SignificantTextAggregatorFactory ([#8807](https://github.com/opensearch-project/OpenSearch/pull/8807))
- Add support for aggregation profiler with concurrent aggregation ([#8801](https://github.com/opensearch-project/OpenSearch/pull/8801))
- [Remove] Deprecated Fractional ByteSizeValue support #9005 ([#9005](https://github.com/opensearch-project/OpenSearch/pull/9005))
- Add base class for parameterizing the search based tests

### Deprecated

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.opensearch.search.lookup.LeafFieldsLookup;
import org.opensearch.tasks.TaskCancelledException;
import org.opensearch.tasks.TaskInfo;
import org.opensearch.test.ConcurrentSearchIntegTestCase;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.opensearch.transport.TransportException;

Expand All @@ -86,12 +87,16 @@
import static org.hamcrest.Matchers.notNullValue;

@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE)
public class SearchCancellationIT extends OpenSearchIntegTestCase {
public class SearchCancellationIT extends ConcurrentSearchIntegTestCase {

private TimeValue requestCancellationTimeout = TimeValue.timeValueSeconds(1);
private TimeValue clusterCancellationTimeout = TimeValue.timeValueMillis(1500);
private TimeValue keepAlive = TimeValue.timeValueSeconds(5);

public SearchCancellationIT(TestParameters testParameters) {
super(testParameters);
}

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(ScriptedBlockPlugin.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.opensearch.script.MockScriptPlugin;
import org.opensearch.script.Script;
import org.opensearch.script.ScriptType;
import org.opensearch.test.ConcurrentSearchIntegTestCase;
import org.opensearch.test.OpenSearchIntegTestCase;

import java.util.Collection;
Expand All @@ -53,7 +54,11 @@
import static org.opensearch.search.SearchTimeoutIT.ScriptedTimeoutPlugin.SCRIPT_NAME;

@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE)
public class SearchTimeoutIT extends OpenSearchIntegTestCase {
public class SearchTimeoutIT extends ConcurrentSearchIntegTestCase {

public SearchTimeoutIT(TestParameters testParameters) {
super(testParameters);
}

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.test;

import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.junit.Before;
import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
import org.opensearch.common.settings.FeatureFlagSettings;
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.FeatureFlags;

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

import static org.opensearch.search.SearchService.CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING;

public class ConcurrentSearchIntegTestCase extends OpenSearchIntegTestCase {

protected final TestParameters testParameters;
@ParametersFactory
public static Collection<Object[]> parameters() {
return Arrays.asList(
new Object[] {new TestParameters(true)},
new Object[] {new TestParameters(false)}
);
}
public ConcurrentSearchIntegTestCase(TestParameters testParameters) {
this.testParameters = testParameters;
}

@Before
void beforeTests() {
ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin()
.cluster()
.prepareUpdateSettings()
.setPersistentSettings(Settings.builder().put(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey(), testParameters.isConcurrentSearchSettingVal())).get();
assertEquals(String.valueOf(testParameters.isConcurrentSearchSettingVal()), clusterUpdateSettingsResponse.getPersistentSettings().get(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey()));
}

// TODO: remove the function once the concurrent search experimental flag is removed
@Override
protected Settings featureFlagSettings() {
Settings.Builder featureSettings = Settings.builder();
for (Setting builtInFlag : FeatureFlagSettings.BUILT_IN_FEATURE_FLAGS) {
featureSettings.put(builtInFlag.getKey(), builtInFlag.getDefaultRaw(Settings.EMPTY));
}
featureSettings.put(FeatureFlags.CONCURRENT_SEGMENT_SEARCH, true);
return featureSettings.build();
}

public static class TestParameters {
private final boolean concurrentSearchSettingVal;

public TestParameters(boolean concurrentSearchSettingVal) {
this.concurrentSearchSettingVal = concurrentSearchSettingVal;
}

public boolean isConcurrentSearchSettingVal() {
return concurrentSearchSettingVal;
}
}
}

0 comments on commit 110efe1

Please sign in to comment.