[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
This commit is contained in:
Lee Hinman 2017-05-17 10:58:50 -06:00 committed by GitHub
parent 2ccc223ff7
commit 01bcbd868d
1 changed files with 5 additions and 2 deletions

View File

@ -888,9 +888,10 @@ public class TransportReplicationActionTests extends ESTestCase {
final TestAction.ReplicaOperationTransportHandler replicaOperationTransportHandler = action.new ReplicaOperationTransportHandler(); final TestAction.ReplicaOperationTransportHandler replicaOperationTransportHandler = action.new ReplicaOperationTransportHandler();
final PlainActionFuture<TestResponse> listener = new PlainActionFuture<>(); final PlainActionFuture<TestResponse> listener = new PlainActionFuture<>();
final Request request = new Request().setShardId(shardId); final Request request = new Request().setShardId(shardId);
final long checkpoint = randomNonNegativeLong();
request.primaryTerm(state.metaData().getIndexSafe(shardId.getIndex()).primaryTerm(shardId.id())); request.primaryTerm(state.metaData().getIndexSafe(shardId.getIndex()).primaryTerm(shardId.id()));
replicaOperationTransportHandler.messageReceived( replicaOperationTransportHandler.messageReceived(
new TransportReplicationAction.ConcreteReplicaRequest<>(request, replica.allocationId().getId(), randomNonNegativeLong()), new TransportReplicationAction.ConcreteReplicaRequest<>(request, replica.allocationId().getId(), checkpoint),
createTransportChannel(listener), task); createTransportChannel(listener), task);
if (listener.isDone()) { if (listener.isDone()) {
listener.get(); // fail with the exception if there listener.get(); // fail with the exception if there
@ -911,7 +912,9 @@ public class TransportReplicationActionTests extends ESTestCase {
assertThat(capturedRequests.size(), equalTo(1)); assertThat(capturedRequests.size(), equalTo(1));
final CapturingTransport.CapturedRequest capturedRequest = capturedRequests.get(0); final CapturingTransport.CapturedRequest capturedRequest = capturedRequests.get(0);
assertThat(capturedRequest.action, equalTo("testActionWithExceptions[r]")); 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()); assertConcreteShardRequest(capturedRequest.request, request, replica.allocationId());
} }