From de852765d6bd7d06497cb15136c8b61bfa93744c Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Mon, 14 Jan 2019 14:27:26 +0100 Subject: [PATCH] unmuted test Relates to #37014 --- .../java/org/elasticsearch/xpack/CcrIntegTestCase.java | 4 +++- .../org/elasticsearch/xpack/CcrSingleNodeTestCase.java | 6 ++++++ .../elasticsearch/xpack/ccr/LocalIndexFollowingIT.java | 8 +++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java index 05b20050ee3..7af3d690e3a 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java @@ -563,9 +563,11 @@ public abstract class CcrIntegTestCase extends ESTestCase { clusterService.submitStateUpdateTask("remove-ccr-related-metadata", new ClusterStateUpdateTask() { @Override public ClusterState execute(ClusterState currentState) throws Exception { + AutoFollowMetadata empty = + new AutoFollowMetadata(Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap()); ClusterState.Builder newState = ClusterState.builder(currentState); newState.metaData(MetaData.builder(currentState.getMetaData()) - .removeCustom(AutoFollowMetadata.TYPE) + .putCustom(AutoFollowMetadata.TYPE, empty) .removeCustom(PersistentTasksCustomMetaData.TYPE) .build()); return newState.build(); 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 2fb1f868dd7..e77a672f1fd 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 @@ -18,7 +18,9 @@ import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.ccr.CcrSettings; import org.elasticsearch.xpack.ccr.LocalStateCcr; import org.elasticsearch.xpack.core.XPackSettings; +import org.elasticsearch.xpack.core.ccr.AutoFollowStats; import org.elasticsearch.xpack.core.ccr.ShardFollowNodeTaskStatus; +import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction; import org.elasticsearch.xpack.core.ccr.action.PutFollowAction; import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; @@ -79,6 +81,10 @@ public abstract class CcrSingleNodeTestCase extends ESSingleNodeTestCase { assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); } + protected AutoFollowStats getAutoFollowStats() { + return client().execute(CcrStatsAction.INSTANCE, new CcrStatsAction.Request()).actionGet().getAutoFollowStats(); + } + protected ResumeFollowAction.Request getResumeFollowRequest(String followerIndex) { ResumeFollowAction.Request request = new ResumeFollowAction.Request(); request.setFollowerIndex(followerIndex); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/LocalIndexFollowingIT.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/LocalIndexFollowingIT.java index f80fc0c07d9..2c50411971a 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/LocalIndexFollowingIT.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/LocalIndexFollowingIT.java @@ -92,7 +92,6 @@ public class LocalIndexFollowingIT extends CcrSingleNodeTestCase { assertThat(client().admin().indices().prepareExists("follower-index").get().isExists(), equalTo(false)); } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37014") public void testRemoveRemoteConnection() throws Exception { PutAutoFollowPatternAction.Request request = new PutAutoFollowPatternAction.Request(); request.setName("my_pattern"); @@ -101,6 +100,7 @@ public class LocalIndexFollowingIT extends CcrSingleNodeTestCase { request.setFollowIndexNamePattern("copy-{{leader_index}}"); request.setReadPollTimeout(TimeValue.timeValueMillis(10)); assertTrue(client().execute(PutAutoFollowPatternAction.INSTANCE, request).actionGet().isAcknowledged()); + long previousNumberOfSuccessfulFollowedIndices = getAutoFollowStats().getNumberOfSuccessfulFollowIndices(); Settings leaderIndexSettings = Settings.builder() .put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) @@ -111,7 +111,8 @@ public class LocalIndexFollowingIT extends CcrSingleNodeTestCase { client().prepareIndex("logs-20200101", "doc").setSource("{}", XContentType.JSON).get(); assertBusy(() -> { CcrStatsAction.Response response = client().execute(CcrStatsAction.INSTANCE, new CcrStatsAction.Request()).actionGet(); - assertThat(response.getAutoFollowStats().getNumberOfSuccessfulFollowIndices(), equalTo(1L)); + assertThat(response.getAutoFollowStats().getNumberOfSuccessfulFollowIndices(), + equalTo(previousNumberOfSuccessfulFollowedIndices + 1)); assertThat(response.getFollowStats().getStatsResponses().size(), equalTo(1)); assertThat(response.getFollowStats().getStatsResponses().get(0).status().followerGlobalCheckpoint(), equalTo(0L)); }); @@ -127,7 +128,8 @@ public class LocalIndexFollowingIT extends CcrSingleNodeTestCase { client().prepareIndex("logs-20200101", "doc").setSource("{}", XContentType.JSON).get(); assertBusy(() -> { CcrStatsAction.Response response = client().execute(CcrStatsAction.INSTANCE, new CcrStatsAction.Request()).actionGet(); - assertThat(response.getAutoFollowStats().getNumberOfSuccessfulFollowIndices(), equalTo(2L)); + assertThat(response.getAutoFollowStats().getNumberOfSuccessfulFollowIndices(), + equalTo(previousNumberOfSuccessfulFollowedIndices + 2)); FollowStatsAction.StatsRequest statsRequest = new FollowStatsAction.StatsRequest(); statsRequest.setIndices(new String[]{"copy-logs-20200101"});