From 48124807d55a2ae057484179bcff9e758ae1f90a Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Thu, 12 Mar 2020 14:14:36 +0100 Subject: [PATCH] Fix SourceOnlySnapshotIT (#53462) 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 --- .../snapshots/SourceOnlySnapshotIT.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/SourceOnlySnapshotIT.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/SourceOnlySnapshotIT.java index 178c3d163c4..5c5a7745d81 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/SourceOnlySnapshotIT.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/SourceOnlySnapshotIT.java @@ -106,9 +106,9 @@ public class SourceOnlySnapshotIT extends ESIntegTestCase { }); 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) @@ -131,9 +131,9 @@ public class SourceOnlySnapshotIT extends ESIntegTestCase { 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)