From 182e8115ded245a15cedfdedc9c3966c62f92741 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Thu, 5 Jan 2017 19:12:21 +0100 Subject: [PATCH] [TEST] Fix IndexRecoveryIT.testDisconnectsDuringRecovery The test currently checks that the recovering shard is not failed when it is not a primary relocation that has moved past the finalization step. Checking if it has moved past that step is done by intercepting the request between the replication source and the target and checking if it has seen then WAIT_FOR_CLUSTERSTATE action as this is the next action that is called after finalization. This action can, however, occur only after the shard was already failed, and thus trip the assertion. This commit changes the check to look out for the FINALIZE action, independently of whether it succeeded or not. --- .../elasticsearch/indices/recovery/IndexRecoveryIT.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java b/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java index 6bbccb4cfb7..424edb42e68 100644 --- a/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java +++ b/core/src/test/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java @@ -724,14 +724,14 @@ public class IndexRecoveryIT extends ESIntegTestCase { } }); - final AtomicBoolean seenWaitForClusterState = new AtomicBoolean(); + final AtomicBoolean finalized = new AtomicBoolean(); blueMockTransportService.addDelegate(redMockTransportService, new MockTransportService.DelegateTransport(blueMockTransportService.original()) { @Override protected void sendRequest(Connection connection, long requestId, String action, TransportRequest request, TransportRequestOptions options) throws IOException { logger.info("--> sending request {} on {}", action, connection.getNode()); - if (action.equals(PeerRecoveryTargetService.Actions.WAIT_CLUSTERSTATE)) { - seenWaitForClusterState.set(true); + if (action.equals(PeerRecoveryTargetService.Actions.FINALIZE)) { + finalized.set(true); } super.sendRequest(connection, requestId, action, request, options); } @@ -743,7 +743,7 @@ public class IndexRecoveryIT extends ESIntegTestCase { protected void sendRequest(Connection connection, long requestId, String action, TransportRequest request, TransportRequestOptions options) throws IOException { logger.info("--> sending request {} on {}", action, connection.getNode()); - if (primaryRelocation == false || seenWaitForClusterState.get() == false) { + if ((primaryRelocation && finalized.get()) == false) { assertNotEquals(action, ShardStateAction.SHARD_FAILED_ACTION_NAME); } super.sendRequest(connection, requestId, action, request, options);