Fix testCancelRecoveryDuringPhase1 (#50449)
testCancelRecoveryDuringPhase1 uses a mock of IndexShard, which can't create retention leases. We need to stub method createRetentionLease. Relates #50351 Closes #50424
This commit is contained in:
parent
ef467cc6f5
commit
7713221733
|
@ -558,7 +558,7 @@ public class RecoverySourceHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createRetentionLease(final long startingSeqNo, ActionListener<RetentionLease> listener) {
|
void createRetentionLease(final long startingSeqNo, ActionListener<RetentionLease> listener) {
|
||||||
runUnderPrimaryPermit(() -> {
|
runUnderPrimaryPermit(() -> {
|
||||||
// Clone the peer recovery retention lease belonging to the source shard. We are retaining history between the the local
|
// Clone the peer recovery retention lease belonging to the source shard. We are retaining history between the the local
|
||||||
// checkpoint of the safe commit we're creating and this lease's retained seqno with the retention lock, and by cloning an
|
// checkpoint of the safe commit we're creating and this lease's retained seqno with the retention lock, and by cloning an
|
||||||
|
|
|
@ -64,6 +64,7 @@ import org.elasticsearch.index.mapper.ParsedDocument;
|
||||||
import org.elasticsearch.index.mapper.SeqNoFieldMapper;
|
import org.elasticsearch.index.mapper.SeqNoFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.Uid;
|
import org.elasticsearch.index.mapper.Uid;
|
||||||
import org.elasticsearch.index.seqno.ReplicationTracker;
|
import org.elasticsearch.index.seqno.ReplicationTracker;
|
||||||
|
import org.elasticsearch.index.seqno.RetentionLease;
|
||||||
import org.elasticsearch.index.seqno.RetentionLeases;
|
import org.elasticsearch.index.seqno.RetentionLeases;
|
||||||
import org.elasticsearch.index.seqno.SeqNoStats;
|
import org.elasticsearch.index.seqno.SeqNoStats;
|
||||||
import org.elasticsearch.index.seqno.SequenceNumbers;
|
import org.elasticsearch.index.seqno.SequenceNumbers;
|
||||||
|
@ -629,7 +630,6 @@ public class RecoverySourceHandlerTests extends ESTestCase {
|
||||||
store.close();
|
store.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/50424")
|
|
||||||
public void testCancelRecoveryDuringPhase1() throws Exception {
|
public void testCancelRecoveryDuringPhase1() throws Exception {
|
||||||
Store store = newStore(createTempDir("source"), false);
|
Store store = newStore(createTempDir("source"), false);
|
||||||
IndexShard shard = mock(IndexShard.class);
|
IndexShard shard = mock(IndexShard.class);
|
||||||
|
@ -678,8 +678,16 @@ public class RecoverySourceHandlerTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
final StartRecoveryRequest startRecoveryRequest = getStartRecoveryRequest();
|
||||||
final RecoverySourceHandler handler = new RecoverySourceHandler(
|
final RecoverySourceHandler handler = new RecoverySourceHandler(
|
||||||
shard, recoveryTarget, threadPool, getStartRecoveryRequest(), between(1, 16), between(1, 4));
|
shard, recoveryTarget, threadPool, startRecoveryRequest, between(1, 16), between(1, 4)) {
|
||||||
|
@Override
|
||||||
|
void createRetentionLease(long startingSeqNo, ActionListener<RetentionLease> listener) {
|
||||||
|
final String leaseId = ReplicationTracker.getPeerRecoveryRetentionLeaseId(startRecoveryRequest.targetNode().getId());
|
||||||
|
listener.onResponse(new RetentionLease(leaseId, startingSeqNo, threadPool.absoluteTimeInMillis(),
|
||||||
|
ReplicationTracker.PEER_RECOVERY_RETENTION_LEASE_SOURCE));
|
||||||
|
}
|
||||||
|
};
|
||||||
cancelRecovery.set(() -> handler.cancel("test"));
|
cancelRecovery.set(() -> handler.cancel("test"));
|
||||||
final StepListener<RecoverySourceHandler.SendFileResult> phase1Listener = new StepListener<>();
|
final StepListener<RecoverySourceHandler.SendFileResult> phase1Listener = new StepListener<>();
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue