Skip to content

Commit

Permalink
Add missing test testRecoverFromLocalTranslog now that PR #9399 has b…
Browse files Browse the repository at this point in the history
…een merged
  • Loading branch information
marregui committed Nov 29, 2019
1 parent 785f7a2 commit bf6e5e4
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5256,6 +5256,40 @@ public void testNoOpOnClosingEngine() throws Exception {
}
}

@Test
public void testRecoverFromLocalTranslog() throws Exception {
final AtomicLong globalCheckpoint = new AtomicLong(SequenceNumbers.NO_OPS_PERFORMED);
Path translogPath = createTempDir();
List<Engine.Operation> operations = generateHistoryOnReplica(between(1, 500), randomBoolean(), randomBoolean());
try (Store store = createStore()) {
EngineConfig config = config(defaultSettings, store, translogPath, newMergePolicy(), null, null, globalCheckpoint::get);
final List<DocIdSeqNoAndSource> docs;
try (InternalEngine engine = createEngine(config)) {
for (Engine.Operation op : operations) {
applyOperation(engine, op);
if (randomBoolean()) {
engine.syncTranslog();
globalCheckpoint.set(randomLongBetween(globalCheckpoint.get(), engine.getPersistedLocalCheckpoint()));
}
if (randomInt(100) < 10) {
engine.refresh("test");
}
if (randomInt(100) < 5) {
engine.flush();
}
if (randomInt(100) < 5) {
engine.forceMerge(randomBoolean(), 1, false, false, false);
}
}
docs = getDocIds(engine, true);
}
try (InternalEngine engine = new InternalEngine(config)) {
engine.recoverFromTranslog(translogHandler, Long.MAX_VALUE);
assertThat(getDocIds(engine, randomBoolean()), equalTo(docs));
}
}
}

private Map<BytesRef, DeleteVersionValue> tombstonesInVersionMap(InternalEngine engine) {
return engine.getVersionMap().entrySet().stream()
.filter(e -> e.getValue() instanceof DeleteVersionValue)
Expand Down

0 comments on commit bf6e5e4

Please sign in to comment.