From 38a1d4fcdbaefa2ef290d3495a114763b4187c4f Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Mon, 10 Dec 2018 13:15:15 +0100 Subject: [PATCH] re-enabled test with added logging to have more info when it fails. --- .../java/org/elasticsearch/client/CCRIT.java | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java index 0c36f5d5865..90799522372 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java @@ -20,6 +20,7 @@ package org.elasticsearch.client; import org.apache.http.util.EntityUtils; +import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse; import org.elasticsearch.action.admin.indices.close.CloseIndexRequest; @@ -36,6 +37,7 @@ import org.elasticsearch.client.ccr.FollowStatsRequest; import org.elasticsearch.client.ccr.FollowStatsResponse; import org.elasticsearch.client.ccr.GetAutoFollowPatternRequest; import org.elasticsearch.client.ccr.GetAutoFollowPatternResponse; +import org.elasticsearch.client.ccr.IndicesFollowStats; import org.elasticsearch.client.ccr.IndicesFollowStats.ShardFollowStats; import org.elasticsearch.client.ccr.PauseFollowRequest; import org.elasticsearch.client.ccr.PutAutoFollowPatternRequest; @@ -85,7 +87,6 @@ public class CCRIT extends ESRestHighLevelClientTestCase { }); } - @AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/issues/36339") public void testIndexFollowing() throws Exception { CcrClient ccrClient = highLevelClient().ccr(); @@ -109,21 +110,33 @@ public class CCRIT extends ESRestHighLevelClientTestCase { SearchResponse leaderSearchResponse = highLevelClient().search(leaderSearchRequest, RequestOptions.DEFAULT); assertThat(leaderSearchResponse.getHits().getTotalHits().value, equalTo(1L)); - assertBusy(() -> { - FollowStatsRequest followStatsRequest = new FollowStatsRequest("follower"); - FollowStatsResponse followStatsResponse = - execute(followStatsRequest, ccrClient::getFollowStats, ccrClient::getFollowStatsAsync); - List shardFollowStats = followStatsResponse.getIndicesFollowStats().getShardFollowStats("follower"); - long followerGlobalCheckpoint = shardFollowStats.stream() - .mapToLong(ShardFollowStats::getFollowerGlobalCheckpoint) - .max() - .getAsLong(); - assertThat(followerGlobalCheckpoint, equalTo(0L)); + try { + assertBusy(() -> { + FollowStatsRequest followStatsRequest = new FollowStatsRequest("follower"); + FollowStatsResponse followStatsResponse = + execute(followStatsRequest, ccrClient::getFollowStats, ccrClient::getFollowStatsAsync); + List shardFollowStats = followStatsResponse.getIndicesFollowStats().getShardFollowStats("follower"); + long followerGlobalCheckpoint = shardFollowStats.stream() + .mapToLong(ShardFollowStats::getFollowerGlobalCheckpoint) + .max() + .getAsLong(); + assertThat(followerGlobalCheckpoint, equalTo(0L)); - SearchRequest followerSearchRequest = new SearchRequest("follower"); - SearchResponse followerSearchResponse = highLevelClient().search(followerSearchRequest, RequestOptions.DEFAULT); - assertThat(followerSearchResponse.getHits().getTotalHits().value, equalTo(1L)); - }); + SearchRequest followerSearchRequest = new SearchRequest("follower"); + SearchResponse followerSearchResponse = highLevelClient().search(followerSearchRequest, RequestOptions.DEFAULT); + assertThat(followerSearchResponse.getHits().getTotalHits().value, equalTo(1L)); + }); + } catch (Exception e) { + IndicesFollowStats followStats = ccrClient.getCcrStats(new CcrStatsRequest(), RequestOptions.DEFAULT).getIndicesFollowStats(); + for (Map.Entry> entry : followStats.getShardFollowStats().entrySet()) { + for (ShardFollowStats shardFollowStats : entry.getValue()) { + if (shardFollowStats.getFatalException() != null) { + logger.warn(new ParameterizedMessage("fatal shard follow exception {}", shardFollowStats.getShardId()), + shardFollowStats.getFatalException()); + } + } + } + } PauseFollowRequest pauseFollowRequest = new PauseFollowRequest("follower"); AcknowledgedResponse pauseFollowResponse = execute(pauseFollowRequest, ccrClient::pauseFollow, ccrClient::pauseFollowAsync);