From 35b1b60b164c9c0cf63af12232034d11cccf4eaa Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 18 Dec 2018 10:43:11 +0100 Subject: [PATCH] [TEST] Ensure shard follow tasks have really stopped. Relates to #36696 --- .../org/elasticsearch/xpack/CcrSingleNodeTestCase.java | 9 ++++++--- .../elasticsearch/xpack/ccr/action/FollowStatsIT.java | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrSingleNodeTestCase.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrSingleNodeTestCase.java index 417de7cd985c5..5311f54762be2 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrSingleNodeTestCase.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrSingleNodeTestCase.java @@ -58,10 +58,13 @@ public void setupLocalRemote() { } @After - public void remoteLocalRemote() throws Exception { + public void purgeCCRMetadata() throws Exception { ClusterService clusterService = getInstanceFromNode(ClusterService.class); removeCCRRelatedMetadataFromClusterState(clusterService); + } + @After + public void removeLocalRemote() { ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest(); updateSettingsRequest.transientSettings(Settings.builder().put("cluster.remote.local.seeds", (String) null)); assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); @@ -70,8 +73,8 @@ public void remoteLocalRemote() throws Exception { protected ResumeFollowAction.Request getResumeFollowRequest(String followerIndex) { ResumeFollowAction.Request request = new ResumeFollowAction.Request(); request.setFollowerIndex(followerIndex); - request.setMaxRetryDelay(TimeValue.timeValueMillis(10)); - request.setReadPollTimeout(TimeValue.timeValueMillis(10)); + request.setMaxRetryDelay(TimeValue.timeValueMillis(1)); + request.setReadPollTimeout(TimeValue.timeValueMillis(1)); return request; } diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/FollowStatsIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/FollowStatsIT.java index 42901e2697167..bf6f080099088 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/FollowStatsIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/FollowStatsIT.java @@ -13,11 +13,13 @@ import org.elasticsearch.index.IndexSettings; import org.elasticsearch.persistent.PersistentTasksCustomMetaData; import org.elasticsearch.xpack.CcrSingleNodeTestCase; +import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction; import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction; import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; import java.util.Comparator; +import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; @@ -106,6 +108,12 @@ public void testFollowStatsApiFollowerIndexFiltering() throws Exception { assertAcked(client().execute(PauseFollowAction.INSTANCE, new PauseFollowAction.Request("follower1")).actionGet()); assertAcked(client().execute(PauseFollowAction.INSTANCE, new PauseFollowAction.Request("follower2")).actionGet()); + + assertBusy(() -> { + List responseList = + client().execute(CcrStatsAction.INSTANCE, new CcrStatsAction.Request()).actionGet().getFollowStats().getStatsResponses(); + assertThat(responseList.size(), equalTo(0)); + }); } }