[TEST] Set required euery on delete-by-query request

Original commit: elastic/x-pack-elasticsearch@b9b6234f3d
This commit is contained in:
Dimitrios Athanasiou 2017-03-28 17:14:47 +01:00
parent 7eece908b2
commit 991e5d8833
1 changed files with 13 additions and 3 deletions

View File

@ -9,6 +9,7 @@ import org.elasticsearch.action.bulk.byscroll.BulkByScrollResponse;
import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.reindex.DeleteByQueryAction; import org.elasticsearch.index.reindex.DeleteByQueryAction;
import org.elasticsearch.index.reindex.ReindexAction; import org.elasticsearch.index.reindex.ReindexAction;
import org.elasticsearch.index.reindex.ReindexPlugin; import org.elasticsearch.index.reindex.ReindexPlugin;
@ -48,14 +49,23 @@ public class ReindexWithSecurityIT extends SecurityIntegTestCase {
public void testDeleteByQuery() { public void testDeleteByQuery() {
createIndicesWithRandomAliases("test1", "test2", "test3"); createIndicesWithRandomAliases("test1", "test2", "test3");
BulkByScrollResponse response = DeleteByQueryAction.INSTANCE.newRequestBuilder(client()).source("test1", "test2").get(); BulkByScrollResponse response = DeleteByQueryAction.INSTANCE.newRequestBuilder(client())
.source("test1", "test2")
.filter(QueryBuilders.matchAllQuery())
.get();
assertNotNull(response); assertNotNull(response);
response = DeleteByQueryAction.INSTANCE.newRequestBuilder(client()).source("test*").get(); response = DeleteByQueryAction.INSTANCE.newRequestBuilder(client())
.source("test*")
.filter(QueryBuilders.matchAllQuery())
.get();
assertNotNull(response); assertNotNull(response);
IndexNotFoundException e = expectThrows(IndexNotFoundException.class, IndexNotFoundException e = expectThrows(IndexNotFoundException.class,
() -> DeleteByQueryAction.INSTANCE.newRequestBuilder(client()).source("test1", "index1").get()); () -> DeleteByQueryAction.INSTANCE.newRequestBuilder(client())
.source("test1", "index1")
.filter(QueryBuilders.matchAllQuery())
.get());
assertEquals("no such index", e.getMessage()); assertEquals("no such index", e.getMessage());
} }