From 01bcbd868d2c522b43d1eedcb71f6990659f9a4c Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Wed, 17 May 2017 10:58:50 -0600 Subject: [PATCH] [TEST] Fix TransportReplicationActionTests.testRetryOnReplica for replica request (#24745) * [TEST] Fix TransportReplicationActionTests.testRetryOnReplica for replica request We were improperly testing that it was a `ConcreteShardRequest` instead of a `ConcreteReplicaRequest`. This adds that change and also ensures that the checkpoint is retrievable from the request. * Fix line-length --- .../replication/TransportReplicationActionTests.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java b/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java index b402feb6d81..0f8071cce36 100644 --- a/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java @@ -888,9 +888,10 @@ public class TransportReplicationActionTests extends ESTestCase { final TestAction.ReplicaOperationTransportHandler replicaOperationTransportHandler = action.new ReplicaOperationTransportHandler(); final PlainActionFuture listener = new PlainActionFuture<>(); final Request request = new Request().setShardId(shardId); + final long checkpoint = randomNonNegativeLong(); request.primaryTerm(state.metaData().getIndexSafe(shardId.getIndex()).primaryTerm(shardId.id())); replicaOperationTransportHandler.messageReceived( - new TransportReplicationAction.ConcreteReplicaRequest<>(request, replica.allocationId().getId(), randomNonNegativeLong()), + new TransportReplicationAction.ConcreteReplicaRequest<>(request, replica.allocationId().getId(), checkpoint), createTransportChannel(listener), task); if (listener.isDone()) { listener.get(); // fail with the exception if there @@ -911,7 +912,9 @@ public class TransportReplicationActionTests extends ESTestCase { assertThat(capturedRequests.size(), equalTo(1)); final CapturingTransport.CapturedRequest capturedRequest = capturedRequests.get(0); assertThat(capturedRequest.action, equalTo("testActionWithExceptions[r]")); - assertThat(capturedRequest.request, instanceOf(TransportReplicationAction.ConcreteShardRequest.class)); + assertThat(capturedRequest.request, instanceOf(TransportReplicationAction.ConcreteReplicaRequest.class)); + assertThat(((TransportReplicationAction.ConcreteReplicaRequest) capturedRequest.request).getGlobalCheckpoint(), + equalTo(checkpoint)); assertConcreteShardRequest(capturedRequest.request, request, replica.allocationId()); }