[TEST] Test for shard failures, add debug to testProfileMatchesRegular

Unmuting the test and adding some more debug output.  Was not able to
reproduce the prior failure, but it seems possible that the
failure (mismatched counts) could be caused by partial search results
during the test.

The assertions check for shard failures first, because if one of the
two searches is partial the rest of the test will fail.

Next, instead of just checking respective hit counts, we emit the
difference in hits to help identify what went wrong.

Closes #32492
This commit is contained in:
Zachary Tong 2018-08-02 17:16:34 -04:00
parent 9e1e38ff51
commit 080b9f58ea

View File

@ -35,8 +35,10 @@ import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import static org.elasticsearch.search.profile.query.RandomQueryGenerator.randomQueryBuilder; import static org.elasticsearch.search.profile.query.RandomQueryGenerator.randomQueryBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -105,7 +107,6 @@ public class QueryProfilerIT extends ESIntegTestCase {
* search for each query. It then does some basic sanity checking of score and hits * search for each query. It then does some basic sanity checking of score and hits
* to make sure the profiling doesn't interfere with the hits being returned * to make sure the profiling doesn't interfere with the hits being returned
*/ */
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/32492")
public void testProfileMatchesRegular() throws Exception { public void testProfileMatchesRegular() throws Exception {
createIndex("test"); createIndex("test");
ensureGreen(); ensureGreen();
@ -150,6 +151,10 @@ public class QueryProfilerIT extends ESIntegTestCase {
SearchResponse vanillaResponse = responses[0].getResponse(); SearchResponse vanillaResponse = responses[0].getResponse();
SearchResponse profileResponse = responses[1].getResponse(); SearchResponse profileResponse = responses[1].getResponse();
assertThat(vanillaResponse.getFailedShards(), equalTo(0));
assertThat(profileResponse.getFailedShards(), equalTo(0));
assertThat(vanillaResponse.getSuccessfulShards(), equalTo(profileResponse.getSuccessfulShards()));
float vanillaMaxScore = vanillaResponse.getHits().getMaxScore(); float vanillaMaxScore = vanillaResponse.getHits().getMaxScore();
float profileMaxScore = profileResponse.getHits().getMaxScore(); float profileMaxScore = profileResponse.getHits().getMaxScore();
if (Float.isNaN(vanillaMaxScore)) { if (Float.isNaN(vanillaMaxScore)) {
@ -160,10 +165,19 @@ public class QueryProfilerIT extends ESIntegTestCase {
vanillaMaxScore, profileMaxScore, 0.001); vanillaMaxScore, profileMaxScore, 0.001);
} }
assertThat( if (vanillaResponse.getHits().totalHits != profileResponse.getHits().totalHits) {
"Profile totalHits of [" + profileResponse.getHits().getTotalHits() + "] is not close to Vanilla totalHits [" Set<SearchHit> vanillaSet = new HashSet<>(Arrays.asList(vanillaResponse.getHits().getHits()));
+ vanillaResponse.getHits().getTotalHits() + "]", Set<SearchHit> profileSet = new HashSet<>(Arrays.asList(profileResponse.getHits().getHits()));
vanillaResponse.getHits().getTotalHits(), equalTo(profileResponse.getHits().getTotalHits())); if (vanillaResponse.getHits().totalHits > profileResponse.getHits().totalHits) {
vanillaSet.removeAll(profileSet);
fail("Vanilla hits were larger than profile hits. Non-overlapping elements were: "
+ vanillaSet.toString());
} else {
profileSet.removeAll(vanillaSet);
fail("Profile hits were larger than vanilla hits. Non-overlapping elements were: "
+ profileSet.toString());
}
}
SearchHit[] vanillaHits = vanillaResponse.getHits().getHits(); SearchHit[] vanillaHits = vanillaResponse.getHits().getHits();
SearchHit[] profileHits = profileResponse.getHits().getHits(); SearchHit[] profileHits = profileResponse.getHits().getHits();