From 063957b7d8bffb97a9aac4a2f15d527c7fcec3cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Witek?= Date: Wed, 11 Mar 2020 12:26:11 +0100 Subject: [PATCH] Simplify "refresh" calls. (#53385) (#53393) --- .../xpack/ml/integration/CategorizationIT.java | 3 +-- .../xpack/ml/integration/DeleteExpiredDataIT.java | 5 ++--- .../xpack/ml/integration/MlNativeIntegTestCase.java | 3 +-- .../xpack/ml/integration/BasicDistributedJobsIT.java | 2 +- .../resources/rest-api-spec/test/ml/index_layout.yml | 10 +++++----- .../test/resources/rest-api-spec/test/ml/jobs_crud.yml | 8 ++++---- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/CategorizationIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/CategorizationIT.java index f0c9e9ae4b1..3ca921ddc0e 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/CategorizationIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/CategorizationIT.java @@ -9,7 +9,6 @@ import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.index.IndexRequest; -import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.xpack.ml.MachineLearning; @@ -81,7 +80,7 @@ public class CategorizationIT extends MlNativeAutodetectIntegTestCase { public void tearDownData() { cleanUp(); client().admin().indices().prepareDelete(DATA_INDEX).get(); - client().admin().indices().prepareRefresh("*").setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN).get(); + refresh("*"); } public void testBasicCategorization() throws Exception { diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java index 5ce22d4604d..e08fe08dad5 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java @@ -10,7 +10,6 @@ import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.action.update.UpdateAction; import org.elasticsearch.action.update.UpdateRequest; @@ -167,7 +166,7 @@ public class DeleteExpiredDataIT extends MlNativeAutodetectIntegTestCase { } // Refresh to ensure the snapshot timestamp updates are visible - client().admin().indices().prepareRefresh("*").setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN).get(); + refresh("*"); // We need to wait a second to ensure the second time around model snapshots will have a different ID (it depends on epoch seconds) // FIXME it would be better to wait for something concrete instead of wait for time to elapse @@ -298,6 +297,6 @@ public class DeleteExpiredDataIT extends MlNativeAutodetectIntegTestCase { client().execute(UpdateModelSnapshotAction.INSTANCE, request).get(); } // We need to refresh to ensure the updates are visible - client().admin().indices().prepareRefresh("*").setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN).get(); + refresh("*"); } } diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeIntegTestCase.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeIntegTestCase.java index dffb4ca073e..8cfc4b16124 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeIntegTestCase.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/MlNativeIntegTestCase.java @@ -6,7 +6,6 @@ package org.elasticsearch.xpack.ml.integration; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest; -import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterModule; import org.elasticsearch.cluster.ClusterState; @@ -132,7 +131,7 @@ abstract class MlNativeIntegTestCase extends ESIntegTestCase { new DeleteExpiredDataAction.Request()).get(); // We need to refresh to ensure the deletion is visible - client().admin().indices().prepareRefresh("*").setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN).get(); + refresh("*"); return response; } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java index eed8d9a1d9f..4cc68329cf4 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java @@ -165,7 +165,7 @@ public class BasicDistributedJobsIT extends BaseMlIntegTestCase { indexRequest = new IndexRequest("data", "type"); indexRequest.source("time", 1407083600L); client().index(indexRequest).get(); - refresh("*", ".ml-*"); + refresh("*"); Job.Builder job = createScheduledJob("job_id"); PutJobAction.Request putJobRequest = new PutJobAction.Request(job); diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/index_layout.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/index_layout.yml index 28ef4918236..6774ae8b455 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/index_layout.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/index_layout.yml @@ -111,7 +111,7 @@ setup: headers: Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser indices.refresh: - index: ["*",".ml-*"] + expand_wildcards: all - do: headers: @@ -464,7 +464,7 @@ setup: headers: Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser indices.refresh: - index: ["*",".ml-*"] + expand_wildcards: all - do: headers: @@ -514,7 +514,7 @@ setup: headers: Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser indices.refresh: - index: ["*",".ml-*"] + expand_wildcards: all - do: ml.delete_job: @@ -607,7 +607,7 @@ setup: headers: Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser indices.refresh: - index: ["*",".ml-*"] + expand_wildcards: all - do: ml.delete_job: @@ -685,7 +685,7 @@ setup: headers: Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser indices.refresh: - index: ["*",".ml-*"] + expand_wildcards: all - do: headers: diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/jobs_crud.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/jobs_crud.yml index a5242b5062e..445ab11b042 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/jobs_crud.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/ml/jobs_crud.yml @@ -471,7 +471,7 @@ - do: indices.refresh: - index: ["*",".ml-*"] + expand_wildcards: all - do: catch: /Invalid update value for analysis_limits[:] model_memory_limit cannot be decreased below current usage; current usage \[9mb\], update had \[5mb\]/ @@ -928,7 +928,7 @@ - do: indices.refresh: - index: ["*",".ml-*"] + expand_wildcards: all - do: catch: /status_exception/ @@ -956,7 +956,7 @@ - do: indices.refresh: - index: ["*",".ml-*"] + expand_wildcards: all - do: catch: /status_exception/ @@ -994,7 +994,7 @@ - do: indices.refresh: - index: ["*",".ml-*"] + expand_wildcards: all - do: catch: /status_exception/