mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 17:38:44 +00:00
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.
This commit is contained in:
parent
c064b507df
commit
dda56fc0fc
@ -580,7 +580,6 @@
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]SpanMultiTermQueryBuilderTests.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]SpanNotQueryBuilderTests.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]query[/\\]functionscore[/\\]FunctionScoreTests.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]replication[/\\]ESIndexLevelReplicationTestCase.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]search[/\\]geo[/\\]GeoUtilsTests.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]search[/\\]nested[/\\]AbstractNumberNestedSortingTestCase.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]search[/\\]nested[/\\]DoubleNestedSortingTests.java" checks="LineLength" />
|
||||
|
@ -29,8 +29,8 @@ import org.elasticsearch.action.bulk.BulkItemRequest;
|
||||
import org.elasticsearch.action.bulk.BulkItemResponse;
|
||||
import org.elasticsearch.action.bulk.BulkShardRequest;
|
||||
import org.elasticsearch.action.bulk.BulkShardResponse;
|
||||
import org.elasticsearch.action.bulk.MappingUpdatePerformer;
|
||||
import org.elasticsearch.action.bulk.TransportShardBulkAction;
|
||||
import org.elasticsearch.action.bulk.TransportShardBulkActionTests;
|
||||
import org.elasticsearch.action.delete.DeleteRequest;
|
||||
import org.elasticsearch.action.index.IndexRequest;
|
||||
import org.elasticsearch.action.resync.ResyncReplicationRequest;
|
||||
@ -595,7 +595,8 @@ public abstract class ESIndexLevelReplicationTestCase extends IndexShardTestCase
|
||||
|
||||
@Override
|
||||
protected PrimaryResult performOnPrimary(IndexShard primary, BulkShardRequest request) throws Exception {
|
||||
final TransportWriteAction.WritePrimaryResult<BulkShardRequest, BulkShardResponse> result = executeShardBulkOnPrimary(primary, request);
|
||||
final TransportWriteAction.WritePrimaryResult<BulkShardRequest, BulkShardResponse>
|
||||
result = executeShardBulkOnPrimary(primary, request);
|
||||
return new PrimaryResult(result.replicaRequest(), result.finalResponseIfSuccessful);
|
||||
}
|
||||
|
||||
@ -605,7 +606,8 @@ public abstract class ESIndexLevelReplicationTestCase extends IndexShardTestCase
|
||||
}
|
||||
}
|
||||
|
||||
private TransportWriteAction.WritePrimaryResult<BulkShardRequest, BulkShardResponse> executeShardBulkOnPrimary(IndexShard primary, BulkShardRequest request) throws Exception {
|
||||
private TransportWriteAction.WritePrimaryResult<BulkShardRequest, BulkShardResponse> executeShardBulkOnPrimary(
|
||||
IndexShard primary, BulkShardRequest request) throws Exception {
|
||||
for (BulkItemRequest itemRequest : request.items()) {
|
||||
if (itemRequest.request() instanceof IndexRequest) {
|
||||
((IndexRequest) itemRequest.request()).process(Version.CURRENT, null, index.getName());
|
||||
@ -615,8 +617,8 @@ public abstract class ESIndexLevelReplicationTestCase extends IndexShardTestCase
|
||||
primary.acquirePrimaryOperationPermit(permitAcquiredFuture, ThreadPool.Names.SAME, request);
|
||||
final TransportWriteAction.WritePrimaryResult<BulkShardRequest, BulkShardResponse> result;
|
||||
try (Releasable ignored = permitAcquiredFuture.actionGet()) {
|
||||
result = TransportShardBulkAction.performOnPrimary(request, primary, null, System::currentTimeMillis,
|
||||
new TransportShardBulkActionTests.NoopMappingUpdatePerformer());
|
||||
MappingUpdatePerformer noopMappingUpdater = (update, shardId, type) -> { };
|
||||
result = TransportShardBulkAction.performOnPrimary(request, primary, null, System::currentTimeMillis, noopMappingUpdater);
|
||||
}
|
||||
TransportWriteActionTestHelper.performPostWriteActions(primary, request, result.location, logger);
|
||||
return result;
|
||||
@ -629,9 +631,11 @@ public abstract class ESIndexLevelReplicationTestCase extends IndexShardTestCase
|
||||
return executeShardBulkOnPrimary(primary, bulkShardRequest).replicaRequest();
|
||||
}
|
||||
|
||||
private void executeShardBulkOnReplica(BulkShardRequest request, IndexShard replica, long operationPrimaryTerm, long globalCheckpointOnPrimary) throws Exception {
|
||||
private void executeShardBulkOnReplica(BulkShardRequest request, IndexShard replica, long operationPrimaryTerm,
|
||||
long globalCheckpointOnPrimary) throws Exception {
|
||||
final PlainActionFuture<Releasable> permitAcquiredFuture = new PlainActionFuture<>();
|
||||
replica.acquireReplicaOperationPermit(operationPrimaryTerm, globalCheckpointOnPrimary, permitAcquiredFuture, ThreadPool.Names.SAME, request);
|
||||
replica.acquireReplicaOperationPermit(
|
||||
operationPrimaryTerm, globalCheckpointOnPrimary, permitAcquiredFuture, ThreadPool.Names.SAME, request);
|
||||
final Translog.Location location;
|
||||
try (Releasable ignored = permitAcquiredFuture.actionGet()) {
|
||||
location = TransportShardBulkAction.performOnReplica(request, replica);
|
||||
@ -695,8 +699,8 @@ public abstract class ESIndexLevelReplicationTestCase extends IndexShardTestCase
|
||||
|
||||
class ResyncAction extends ReplicationAction<ResyncReplicationRequest, ResyncReplicationRequest, ResyncReplicationResponse> {
|
||||
|
||||
ResyncAction(ResyncReplicationRequest request, ActionListener<ResyncReplicationResponse> listener, ReplicationGroup replicationGroup) {
|
||||
super(request, listener, replicationGroup, "resync");
|
||||
ResyncAction(ResyncReplicationRequest request, ActionListener<ResyncReplicationResponse> listener, ReplicationGroup group) {
|
||||
super(request, listener, group, "resync");
|
||||
}
|
||||
|
||||
@Override
|
Loading…
x
Reference in New Issue
Block a user