Skip to content

Commit dda56fc

Browse files
authored
Move ESIndexLevelReplicationTestCase to test framework (#31243)
Other components might benefit from the testing infra provided by ESIndexLevelReplicationTestCase. This commit moves it to the test framework.
1 parent c064b50 commit dda56fc

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,6 @@
580580
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]SpanMultiTermQueryBuilderTests.java" checks="LineLength" />
581581
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]SpanNotQueryBuilderTests.java" checks="LineLength" />
582582
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]functionscore[/\\]FunctionScoreTests.java" checks="LineLength" />
583-
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]replication[/\\]ESIndexLevelReplicationTestCase.java" checks="LineLength" />
584583
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]search[/\\]geo[/\\]GeoUtilsTests.java" checks="LineLength" />
585584
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]search[/\\]nested[/\\]AbstractNumberNestedSortingTestCase.java" checks="LineLength" />
586585
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]search[/\\]nested[/\\]DoubleNestedSortingTests.java" checks="LineLength" />

server/src/test/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java renamed to test/framework/src/main/java/org/elasticsearch/index/replication/ESIndexLevelReplicationTestCase.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import org.elasticsearch.action.bulk.BulkItemResponse;
3030
import org.elasticsearch.action.bulk.BulkShardRequest;
3131
import org.elasticsearch.action.bulk.BulkShardResponse;
32+
import org.elasticsearch.action.bulk.MappingUpdatePerformer;
3233
import org.elasticsearch.action.bulk.TransportShardBulkAction;
33-
import org.elasticsearch.action.bulk.TransportShardBulkActionTests;
3434
import org.elasticsearch.action.delete.DeleteRequest;
3535
import org.elasticsearch.action.index.IndexRequest;
3636
import org.elasticsearch.action.resync.ResyncReplicationRequest;
@@ -595,7 +595,8 @@ class IndexingAction extends ReplicationAction<BulkShardRequest, BulkShardReques
595595

596596
@Override
597597
protected PrimaryResult performOnPrimary(IndexShard primary, BulkShardRequest request) throws Exception {
598-
final TransportWriteAction.WritePrimaryResult<BulkShardRequest, BulkShardResponse> result = executeShardBulkOnPrimary(primary, request);
598+
final TransportWriteAction.WritePrimaryResult<BulkShardRequest, BulkShardResponse>
599+
result = executeShardBulkOnPrimary(primary, request);
599600
return new PrimaryResult(result.replicaRequest(), result.finalResponseIfSuccessful);
600601
}
601602

@@ -605,7 +606,8 @@ protected void performOnReplica(BulkShardRequest request, IndexShard replica) th
605606
}
606607
}
607608

608-
private TransportWriteAction.WritePrimaryResult<BulkShardRequest, BulkShardResponse> executeShardBulkOnPrimary(IndexShard primary, BulkShardRequest request) throws Exception {
609+
private TransportWriteAction.WritePrimaryResult<BulkShardRequest, BulkShardResponse> executeShardBulkOnPrimary(
610+
IndexShard primary, BulkShardRequest request) throws Exception {
609611
for (BulkItemRequest itemRequest : request.items()) {
610612
if (itemRequest.request() instanceof IndexRequest) {
611613
((IndexRequest) itemRequest.request()).process(Version.CURRENT, null, index.getName());
@@ -615,8 +617,8 @@ private TransportWriteAction.WritePrimaryResult<BulkShardRequest, BulkShardRespo
615617
primary.acquirePrimaryOperationPermit(permitAcquiredFuture, ThreadPool.Names.SAME, request);
616618
final TransportWriteAction.WritePrimaryResult<BulkShardRequest, BulkShardResponse> result;
617619
try (Releasable ignored = permitAcquiredFuture.actionGet()) {
618-
result = TransportShardBulkAction.performOnPrimary(request, primary, null, System::currentTimeMillis,
619-
new TransportShardBulkActionTests.NoopMappingUpdatePerformer());
620+
MappingUpdatePerformer noopMappingUpdater = (update, shardId, type) -> { };
621+
result = TransportShardBulkAction.performOnPrimary(request, primary, null, System::currentTimeMillis, noopMappingUpdater);
620622
}
621623
TransportWriteActionTestHelper.performPostWriteActions(primary, request, result.location, logger);
622624
return result;
@@ -629,9 +631,11 @@ BulkShardRequest executeReplicationRequestOnPrimary(IndexShard primary, Request
629631
return executeShardBulkOnPrimary(primary, bulkShardRequest).replicaRequest();
630632
}
631633

632-
private void executeShardBulkOnReplica(BulkShardRequest request, IndexShard replica, long operationPrimaryTerm, long globalCheckpointOnPrimary) throws Exception {
634+
private void executeShardBulkOnReplica(BulkShardRequest request, IndexShard replica, long operationPrimaryTerm,
635+
long globalCheckpointOnPrimary) throws Exception {
633636
final PlainActionFuture<Releasable> permitAcquiredFuture = new PlainActionFuture<>();
634-
replica.acquireReplicaOperationPermit(operationPrimaryTerm, globalCheckpointOnPrimary, permitAcquiredFuture, ThreadPool.Names.SAME, request);
637+
replica.acquireReplicaOperationPermit(
638+
operationPrimaryTerm, globalCheckpointOnPrimary, permitAcquiredFuture, ThreadPool.Names.SAME, request);
635639
final Translog.Location location;
636640
try (Releasable ignored = permitAcquiredFuture.actionGet()) {
637641
location = TransportShardBulkAction.performOnReplica(request, replica);
@@ -695,8 +699,8 @@ protected void performOnReplica(final GlobalCheckpointSyncAction.Request request
695699

696700
class ResyncAction extends ReplicationAction<ResyncReplicationRequest, ResyncReplicationRequest, ResyncReplicationResponse> {
697701

698-
ResyncAction(ResyncReplicationRequest request, ActionListener<ResyncReplicationResponse> listener, ReplicationGroup replicationGroup) {
699-
super(request, listener, replicationGroup, "resync");
702+
ResyncAction(ResyncReplicationRequest request, ActionListener<ResyncReplicationResponse> listener, ReplicationGroup group) {
703+
super(request, listener, group, "resync");
700704
}
701705

702706
@Override

0 commit comments

Comments
 (0)