Skip to content

Relax history check in ShardFollowTaskReplicationTests #39162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected WritePrimaryResult<BulkShardOperationsRequest, BulkShardOperationsResp
request.getMaxSeqNoOfUpdatesOrDeletes(), primary, logger);
}

static Translog.Operation rewriteOperationWithPrimaryTerm(Translog.Operation operation, long primaryTerm) {
public static Translog.Operation rewriteOperationWithPrimaryTerm(Translog.Operation operation, long primaryTerm) {
final Translog.Operation operationWithPrimaryTerm;
switch (operation.opType()) {
case INDEX:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -559,11 +560,11 @@ private void assertConsistentHistoryBetweenLeaderAndFollower(ReplicationGroup le
boolean assertMaxSeqNoOfUpdatesOrDeletes) throws Exception {
final List<Tuple<String, Long>> docAndSeqNosOnLeader = getDocIdAndSeqNos(leader.getPrimary()).stream()
.map(d -> Tuple.tuple(d.getId(), d.getSeqNo())).collect(Collectors.toList());
final Set<Tuple<Long, Translog.Operation.Type>> operationsOnLeader = new HashSet<>();
final Map<Long, Translog.Operation> operationsOnLeader = new HashMap<>();
try (Translog.Snapshot snapshot = leader.getPrimary().newChangesSnapshot("test", 0, Long.MAX_VALUE, false)) {
Translog.Operation op;
while ((op = snapshot.next()) != null) {
operationsOnLeader.add(Tuple.tuple(op.seqNo(), op.opType()));
operationsOnLeader.put(op.seqNo(), op);
}
}
for (IndexShard followingShard : follower) {
Expand All @@ -573,14 +574,14 @@ private void assertConsistentHistoryBetweenLeaderAndFollower(ReplicationGroup le
List<Tuple<String, Long>> docAndSeqNosOnFollower = getDocIdAndSeqNos(followingShard).stream()
.map(d -> Tuple.tuple(d.getId(), d.getSeqNo())).collect(Collectors.toList());
assertThat(docAndSeqNosOnFollower, equalTo(docAndSeqNosOnLeader));
final Set<Tuple<Long, Translog.Operation.Type>> operationsOnFollower = new HashSet<>();
try (Translog.Snapshot snapshot = followingShard.newChangesSnapshot("test", 0, Long.MAX_VALUE, false)) {
Translog.Operation op;
while ((op = snapshot.next()) != null) {
operationsOnFollower.add(Tuple.tuple(op.seqNo(), op.opType()));
Translog.Operation leaderOp = operationsOnLeader.get(op.seqNo());
assertThat(TransportBulkShardOperationsAction.rewriteOperationWithPrimaryTerm(op, leaderOp.primaryTerm()),
equalTo(leaderOp));
}
}
assertThat(followingShard.routingEntry().toString(), operationsOnFollower, equalTo(operationsOnLeader));
}
}

Expand Down