Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for concurrent search #11130

Merged
merged 1 commit into from
Nov 14, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public void testInvalidScrollKeepAlive() throws IOException {
* Ensures that we always create and retain search contexts on every target shards for a scroll request
* regardless whether that query can be written to match_no_docs on some target shards or not.
*/
public void testScrollRewrittenToMatchNoDocs() {
public void testScrollRewrittenToMatchNoDocs() throws InterruptedException {
final int numShards = randomIntBetween(3, 5);
assertAcked(
client().admin()
Expand All @@ -746,6 +746,7 @@ public void testScrollRewrittenToMatchNoDocs() {
client().prepareIndex("test").setId("2").setSource("created_date", "2020-01-02").get();
client().prepareIndex("test").setId("3").setSource("created_date", "2020-01-03").get();
client().admin().indices().prepareRefresh("test").get();
indexRandomForConcurrentSearch("test");
SearchResponse resp = null;
try {
int totalHits = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ public void testIssue6614() throws ExecutionException, InterruptedException {
}

public void testTrackScores() throws Exception {
assumeFalse(
"Concurrent search case muted pending fix: https://github.com/opensearch-project/OpenSearch/issues/11189",
internalCluster().clusterService().getClusterSettings().get(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING)
);
assertAcked(client().admin().indices().prepareCreate("test").setMapping("svalue", "type=keyword").get());
ensureGreen();
index(
Expand All @@ -278,6 +282,7 @@ public void testTrackScores() throws Exception {
jsonBuilder().startObject().field("id", "2").field("svalue", "bbb").field("ivalue", 200).field("dvalue", 0.2).endObject()
);
refresh();
indexRandomForConcurrentSearch("test");
Gankris96 marked this conversation as resolved.
Show resolved Hide resolved

SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addSort("svalue", SortOrder.ASC).get();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ public void testDistanceSortingNestedFields() throws Exception {
/**
* Issue 3073
*/
public void testGeoDistanceFilter() throws IOException {
public void testGeoDistanceFilter() throws IOException, InterruptedException {
Version version = VersionUtils.randomIndexCompatibleVersion(random());
Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
double lat = 40.720611;
Expand All @@ -620,6 +620,7 @@ public void testGeoDistanceFilter() throws IOException {
assertAcked(prepareCreate("locations").setSettings(settings).setMapping(mapping));
client().prepareIndex("locations").setId("1").setCreate(true).setSource(source).get();
refresh();
indexRandomForConcurrentSearch("locations");
client().prepareGet("locations", "1").get();

SearchResponse result = client().prepareSearch("locations")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void testPluginSort() throws Exception {
client().prepareIndex("test").setId("3").setSource("field", 0).get();

refresh();
indexRandomForConcurrentSearch("test");

SearchResponse searchResponse = client().prepareSearch("test").addSort(new CustomSortBuilder("field", SortOrder.ASC)).get();
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("3"));
Expand All @@ -80,6 +81,7 @@ public void testPluginSortXContent() throws Exception {
client().prepareIndex("test").setId("3").setSource("field", 0).get();

refresh();
indexRandomForConcurrentSearch("test");

// builder -> json -> builder
SearchResponse searchResponse = client().prepareSearch("test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ protected Settings featureFlagSettings() {
return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.CONCURRENT_SEGMENT_SEARCH, "true").build();
}

public void testSimple() {
public void testSimple() throws InterruptedException {
assertAcked(prepareCreate("test"));
ensureGreen();

client().prepareIndex("test").setId("1").setSource("field", "value").get();
refresh();
indexRandomForConcurrentSearch("test");

SearchResponse response = client().prepareSearch("test").storedFields("_none_").setFetchSource(false).setVersion(true).get();
assertThat(response.getHits().getAt(0).getId(), nullValue());
Expand All @@ -93,12 +94,12 @@ public void testSimple() {
assertThat(response.getHits().getAt(0).getSourceAsString(), nullValue());
}

public void testInnerHits() {
public void testInnerHits() throws InterruptedException {
assertAcked(prepareCreate("test").setMapping("nested", "type=nested"));
ensureGreen();
client().prepareIndex("test").setId("1").setSource("field", "value", "nested", Collections.singletonMap("title", "foo")).get();
refresh();

indexRandomForConcurrentSearch("test");
SearchResponse response = client().prepareSearch("test")
.storedFields("_none_")
.setFetchSource(false)
Expand All @@ -119,12 +120,13 @@ public void testInnerHits() {
assertThat(hits.getAt(0).getSourceAsString(), nullValue());
}

public void testWithRouting() {
public void testWithRouting() throws InterruptedException {
assertAcked(prepareCreate("test"));
ensureGreen();

client().prepareIndex("test").setId("1").setSource("field", "value").setRouting("toto").get();
refresh();
indexRandomForConcurrentSearch("test");

SearchResponse response = client().prepareSearch("test").storedFields("_none_").setFetchSource(false).get();
assertThat(response.getHits().getAt(0).getId(), nullValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ protected Settings featureFlagSettings() {
return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.CONCURRENT_SEGMENT_SEARCH, "true").build();
}

public void testSourceDefaultBehavior() {
public void testSourceDefaultBehavior() throws InterruptedException {
createIndex("test");
ensureGreen();

index("test", "type1", "1", "field", "value");
refresh();
indexRandomForConcurrentSearch("test");

SearchResponse response = client().prepareSearch("test").get();
assertThat(response.getHits().getAt(0).getSourceAsString(), notNullValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ public void testSizeOneShard() throws Exception {
index("test", "type1", Integer.toString(i), "text", "abc" + i);
}
refresh();
indexRandomForConcurrentSearch("test");

SearchResponse search = client().prepareSearch().setQuery(matchQuery("text", "spellchecker")).get();
assertThat("didn't ask for suggestions but got some", search.getSuggest(), nullValue());
Expand Down
Loading