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

[Tests] Fix expectations around shouldPreFilterSearchShards #55522

Merged
merged 1 commit into from
Apr 21, 2020
Merged
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 @@ -19,28 +19,6 @@

package org.elasticsearch.action.search;

import static org.elasticsearch.test.InternalAggregationTestCase.emptyReduceContextBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.awaitLatch;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.startsWith;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiFunction;
import java.util.function.Function;

import org.apache.lucene.search.TotalHits;
import org.apache.lucene.util.SetOnce;
import org.elasticsearch.Version;
Expand Down Expand Up @@ -101,6 +79,28 @@
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportService;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiFunction;
import java.util.function.Function;

import static org.elasticsearch.test.InternalAggregationTestCase.emptyReduceContextBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.awaitLatch;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.startsWith;

public class TransportSearchActionTests extends ESTestCase {

private final ThreadPool threadPool = new TestThreadPool(getClass().getName());
Expand Down Expand Up @@ -844,7 +844,6 @@ public void testShouldMinimizeRoundtrips() throws Exception {
}
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/55514")
public void testShouldPreFilterSearchShards() {
int numIndices = randomIntBetween(2, 10);
Index[] indices = new Index[numIndices];
Expand All @@ -856,17 +855,17 @@ public void testShouldPreFilterSearchShards() {
{
SearchRequest searchRequest = new SearchRequest();
assertFalse(TransportSearchAction.shouldPreFilterSearchShards(clusterState, searchRequest,
indices, randomIntBetween(2, 127)));
indices, randomIntBetween(2, 128)));
assertFalse(TransportSearchAction.shouldPreFilterSearchShards(clusterState, searchRequest,
indices, randomIntBetween(127, 10000)));
indices, randomIntBetween(129, 10000)));
}
{
SearchRequest searchRequest = new SearchRequest()
.source(new SearchSourceBuilder().query(QueryBuilders.rangeQuery("timestamp")));
assertFalse(TransportSearchAction.shouldPreFilterSearchShards(clusterState, searchRequest,
indices, randomIntBetween(2, 127)));
indices, randomIntBetween(2, 128)));
assertTrue(TransportSearchAction.shouldPreFilterSearchShards(clusterState, searchRequest,
indices, randomIntBetween(127, 10000)));
indices, randomIntBetween(129, 10000)));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not exactly sure whether this should be 129 or 128, the way I read the docs I would understand them to not run pre-filter phase if <=128, but I might be wrong here. Please let me know what you think is right.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at the code it would seem 129, but I would try to run the test with a static value just to be 200% sure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That I already did, I was just wondering what the expectations are of the code should be changed to "<=" in the appropriate place. Thanks.

}
{
SearchRequest searchRequest = new SearchRequest()
Expand All @@ -881,9 +880,9 @@ public void testShouldPreFilterSearchShards() {
.source(new SearchSourceBuilder().sort(SortBuilders.fieldSort("timestamp")))
.scroll("5m");
assertTrue(TransportSearchAction.shouldPreFilterSearchShards(clusterState, searchRequest,
indices, randomIntBetween(2, 127)));
indices, randomIntBetween(2, 128)));
assertTrue(TransportSearchAction.shouldPreFilterSearchShards(clusterState, searchRequest,
indices, randomIntBetween(127, 10000)));
indices, randomIntBetween(129, 10000)));
}
}

Expand Down