Simplify "refresh" calls. (#53385) (#53393)

This commit is contained in:
Przemysław Witek 2020-03-11 12:26:11 +01:00 committed by GitHub
parent cc7751eb16
commit 063957b7d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 17 deletions

View File

@ -9,7 +9,6 @@ import org.apache.logging.log4j.LogManager;
import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.MachineLearning;
@ -81,7 +80,7 @@ public class CategorizationIT extends MlNativeAutodetectIntegTestCase {
public void tearDownData() { public void tearDownData() {
cleanUp(); cleanUp();
client().admin().indices().prepareDelete(DATA_INDEX).get(); 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 { public void testBasicCategorization() throws Exception {

View File

@ -10,7 +10,6 @@ import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.action.update.UpdateAction; import org.elasticsearch.action.update.UpdateAction;
import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.action.update.UpdateRequest;
@ -167,7 +166,7 @@ public class DeleteExpiredDataIT extends MlNativeAutodetectIntegTestCase {
} }
// Refresh to ensure the snapshot timestamp updates are visible // 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) // 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 // 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(); client().execute(UpdateModelSnapshotAction.INSTANCE, request).get();
} }
// We need to refresh to ensure the updates are visible // We need to refresh to ensure the updates are visible
client().admin().indices().prepareRefresh("*").setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN).get(); refresh("*");
} }
} }

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.ml.integration; package org.elasticsearch.xpack.ml.integration;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest; import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequest;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.Client; import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterModule; import org.elasticsearch.cluster.ClusterModule;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
@ -132,7 +131,7 @@ abstract class MlNativeIntegTestCase extends ESIntegTestCase {
new DeleteExpiredDataAction.Request()).get(); new DeleteExpiredDataAction.Request()).get();
// We need to refresh to ensure the deletion is visible // 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; return response;
} }

View File

@ -165,7 +165,7 @@ public class BasicDistributedJobsIT extends BaseMlIntegTestCase {
indexRequest = new IndexRequest("data", "type"); indexRequest = new IndexRequest("data", "type");
indexRequest.source("time", 1407083600L); indexRequest.source("time", 1407083600L);
client().index(indexRequest).get(); client().index(indexRequest).get();
refresh("*", ".ml-*"); refresh("*");
Job.Builder job = createScheduledJob("job_id"); Job.Builder job = createScheduledJob("job_id");
PutJobAction.Request putJobRequest = new PutJobAction.Request(job); PutJobAction.Request putJobRequest = new PutJobAction.Request(job);

View File

@ -111,7 +111,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.refresh: indices.refresh:
index: ["*",".ml-*"] expand_wildcards: all
- do: - do:
headers: headers:
@ -464,7 +464,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.refresh: indices.refresh:
index: ["*",".ml-*"] expand_wildcards: all
- do: - do:
headers: headers:
@ -514,7 +514,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.refresh: indices.refresh:
index: ["*",".ml-*"] expand_wildcards: all
- do: - do:
ml.delete_job: ml.delete_job:
@ -607,7 +607,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.refresh: indices.refresh:
index: ["*",".ml-*"] expand_wildcards: all
- do: - do:
ml.delete_job: ml.delete_job:
@ -685,7 +685,7 @@ setup:
headers: headers:
Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser Authorization: "Basic eF9wYWNrX3Jlc3RfdXNlcjp4LXBhY2stdGVzdC1wYXNzd29yZA==" # run as x_pack_rest_user, i.e. the test setup superuser
indices.refresh: indices.refresh:
index: ["*",".ml-*"] expand_wildcards: all
- do: - do:
headers: headers:

View File

@ -471,7 +471,7 @@
- do: - do:
indices.refresh: indices.refresh:
index: ["*",".ml-*"] expand_wildcards: all
- do: - do:
catch: /Invalid update value for analysis_limits[:] model_memory_limit cannot be decreased below current usage; current usage \[9mb\], update had \[5mb\]/ 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: - do:
indices.refresh: indices.refresh:
index: ["*",".ml-*"] expand_wildcards: all
- do: - do:
catch: /status_exception/ catch: /status_exception/
@ -956,7 +956,7 @@
- do: - do:
indices.refresh: indices.refresh:
index: ["*",".ml-*"] expand_wildcards: all
- do: - do:
catch: /status_exception/ catch: /status_exception/
@ -994,7 +994,7 @@
- do: - do:
indices.refresh: indices.refresh:
index: ["*",".ml-*"] expand_wildcards: all
- do: - do:
catch: /status_exception/ catch: /status_exception/