From 864e9d875d43a1bcc1c23427acc25dded1330b7f Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Fri, 7 Feb 2020 18:57:52 -0500 Subject: [PATCH] Bubble up exception in follow task in ccr tests (#52085) It's perfectly fine if a bulk request on the follower hits IndexShardClosedException in some CCR tests because we sometimes close some follower shards while the follow-task is replicating operations. Instead of failing the test immediately, this commit bubbles up that failure to the shard follow task. Closes #52052 --- .../xpack/ccr/action/ShardFollowTaskReplicationTests.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java index c0b71f6de07..7c5543da655 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskReplicationTests.java @@ -126,6 +126,7 @@ public class ShardFollowTaskReplicationTests extends ESIndexLevelReplicationTest equalTo(leaderGroup.getPrimary().getLastKnownGlobalCheckpoint())); followerGroup.assertAllEqual(indexedDocIds.size() - deleteDocIds.size()); }); + assertNull(shardFollowTask.getStatus().getFatalException()); shardFollowTask.markAsCompleted(); assertConsistentHistoryBetweenLeaderAndFollower(leaderGroup, followerGroup, true); } @@ -170,6 +171,7 @@ public class ShardFollowTaskReplicationTests extends ESIndexLevelReplicationTest assertThat(shardFollowTask.getFailure(), nullValue()); int expectedDoc = docCount; assertBusy(() -> followerGroup.assertAllEqual(expectedDoc)); + assertNull(shardFollowTask.getStatus().getFatalException()); shardFollowTask.markAsCompleted(); assertConsistentHistoryBetweenLeaderAndFollower(leaderGroup, followerGroup, hasPromotion == false); } @@ -325,6 +327,7 @@ public class ShardFollowTaskReplicationTests extends ESIndexLevelReplicationTest equalTo(leadingPrimary.getLastKnownGlobalCheckpoint())); assertConsistentHistoryBetweenLeaderAndFollower(leaderGroup, followerGroup, true); }); + assertNull(shardFollowTask.getStatus().getFatalException()); } finally { shardFollowTask.markAsCompleted(); } @@ -398,6 +401,7 @@ public class ShardFollowTaskReplicationTests extends ESIndexLevelReplicationTest follower.recoverReplica(follower.addReplica()); } assertBusy(() -> assertConsistentHistoryBetweenLeaderAndFollower(leader, follower, false)); + assertNull(followTask.getStatus().getFatalException()); followTask.markAsCompleted(); } } @@ -679,7 +683,7 @@ public class ShardFollowTaskReplicationTests extends ESIndexLevelReplicationTest request.getOperations(), request.getMaxSeqNoOfUpdatesOrDeletes(), primary, logger); TransportWriteActionTestHelper.performPostWriteActions(primary, request, ccrResult.location, logger); } catch (InterruptedException | ExecutionException | IOException e) { - throw new AssertionError(e); + throw new RuntimeException(e); } listener.onResponse(new PrimaryResult(ccrResult.replicaRequest(), ccrResult.finalResponseIfSuccessful)); }