Skip to content

Commit

Permalink
Fix SourceOnlySnapshotIT (#53462)
Browse files Browse the repository at this point in the history
The tests in this class had been failing for a while, but went unnoticed as not tested by CI (see #53442).

The reason the tests fail is that the can-match phase is smarter now, and filters out access to a non-existing field.

Closes #53442
  • Loading branch information
ywelsch committed Mar 12, 2020
1 parent 176f60f commit 7ba9cf5
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ public void testSnapshotAndRestore() throws Exception {
});
assertTrue(e.toString().contains("_source only indices can't be searched or filtered"));

e = expectThrows(SearchPhaseExecutionException.class, () ->
client().prepareSearch(sourceIdx).setQuery(QueryBuilders.termQuery("field1", "bar")).get());
assertTrue(e.toString().contains("_source only indices can't be searched or filtered"));
// can-match phase pre-filters access to non-existing field
assertEquals(0,
client().prepareSearch(sourceIdx).setQuery(QueryBuilders.termQuery("field1", "bar")).get().getHits().getTotalHits().value);
// make sure deletes do not work
String idToDelete = "" + randomIntBetween(0, builders.length);
expectThrows(ClusterBlockException.class, () -> client().prepareDelete(sourceIdx, "_doc", idToDelete)
Expand All @@ -131,9 +131,9 @@ public void testSnapshotAndRestoreWithNested() throws Exception {
SearchPhaseExecutionException e = expectThrows(SearchPhaseExecutionException.class, () ->
client().prepareSearch(sourceIdx).setQuery(QueryBuilders.idsQuery().addIds("" + randomIntBetween(0, builders.length))).get());
assertTrue(e.toString().contains("_source only indices can't be searched or filtered"));
e = expectThrows(SearchPhaseExecutionException.class, () ->
client().prepareSearch(sourceIdx).setQuery(QueryBuilders.termQuery("field1", "bar")).get());
assertTrue(e.toString().contains("_source only indices can't be searched or filtered"));
// can-match phase pre-filters access to non-existing field
assertEquals(0,
client().prepareSearch(sourceIdx).setQuery(QueryBuilders.termQuery("field1", "bar")).get().getHits().getTotalHits().value);
// make sure deletes do not work
String idToDelete = "" + randomIntBetween(0, builders.length);
expectThrows(ClusterBlockException.class, () -> client().prepareDelete(sourceIdx, "_doc", idToDelete)
Expand Down

0 comments on commit 7ba9cf5

Please sign in to comment.