diff --git a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java index 345adfe7a8891..eb05dd967344d 100644 --- a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java @@ -1299,24 +1299,33 @@ public void testCommitAdvancesMinTranslogForRecovery() throws IOException { engine.flush(); engine.ensureOpen(); - assertThat(engine.translogManager().getTranslog().currentFileGeneration(), equalTo(3L)); - assertThat(engine.translogManager().getTranslog().getMinFileGeneration(), equalTo(inSync ? 3L : 2L)); + assertThat(assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().currentFileGeneration(), equalTo(3L)); + assertThat( + assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().getMinFileGeneration(), + equalTo(inSync ? 3L : 2L) + ); engine.flush(); engine.ensureOpen(); - assertThat(engine.translogManager().getTranslog().currentFileGeneration(), equalTo(3L)); - assertThat(engine.translogManager().getTranslog().getMinFileGeneration(), equalTo(inSync ? 3L : 2L)); + assertThat(assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().currentFileGeneration(), equalTo(3L)); + assertThat( + assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().getMinFileGeneration(), + equalTo(inSync ? 3L : 2L) + ); engine.flush(true, true); engine.ensureOpen(); - assertThat(engine.translogManager().getTranslog().currentFileGeneration(), equalTo(3L)); - assertThat(engine.translogManager().getTranslog().getMinFileGeneration(), equalTo(inSync ? 3L : 2L)); + assertThat(assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().currentFileGeneration(), equalTo(3L)); + assertThat( + assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().getMinFileGeneration(), + equalTo(inSync ? 3L : 2L) + ); globalCheckpoint.set(engine.getPersistedLocalCheckpoint()); engine.flush(true, true); engine.ensureOpen(); - assertThat(engine.translogManager().getTranslog().currentFileGeneration(), equalTo(3L)); - assertThat(engine.translogManager().getTranslog().getMinFileGeneration(), equalTo(3L)); + assertThat(assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().currentFileGeneration(), equalTo(3L)); + assertThat(assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().getMinFileGeneration(), equalTo(3L)); } public void testSyncTranslogConcurrently() throws Exception { @@ -2821,10 +2830,13 @@ public void testSeqNoAndCheckpoints() throws IOException, InterruptedException { equalTo(localCheckpoint) ); initialEngine.ensureOpen(); - initialEngine.translogManager().getTranslog().sync(); // to guarantee the global checkpoint is written to the translog - // checkpoint + getTranslog(initialEngine).sync(); // to guarantee the global checkpoint is written to the translog + // checkpoint initialEngine.ensureOpen(); - assertThat(initialEngine.translogManager().getTranslog().getLastSyncedGlobalCheckpoint(), equalTo(globalCheckpoint)); + assertThat( + assertAndGetInternalTranslogManager(initialEngine.translogManager()).getLastSyncedGlobalCheckpoint(), + equalTo(globalCheckpoint) + ); assertThat(Long.parseLong(initialEngine.commitStats().getUserData().get(SequenceNumbers.MAX_SEQ_NO)), equalTo(maxSeqNo)); } finally { @@ -2842,7 +2854,10 @@ public void testSeqNoAndCheckpoints() throws IOException, InterruptedException { equalTo(primarySeqNo) ); recoveringEngine.ensureOpen(); - assertThat(recoveringEngine.translogManager().getTranslog().getLastSyncedGlobalCheckpoint(), equalTo(globalCheckpoint)); + assertThat( + assertAndGetInternalTranslogManager(recoveringEngine.translogManager()).getLastSyncedGlobalCheckpoint(), + equalTo(globalCheckpoint) + ); assertThat( Long.parseLong(recoveringEngine.commitStats().getUserData().get(SequenceNumbers.MAX_SEQ_NO)), // after recovering from translog, all docs have been flushed to Lucene segments, so here we will assert @@ -3256,7 +3271,10 @@ public void testCurrentTranslogUUIIDIsCommitted() throws IOException { ); Map userData = engine.getLastCommittedSegmentInfos().getUserData(); engine.ensureOpen(); - assertEquals(engine.translogManager().getTranslog().getTranslogUUID(), userData.get(Translog.TRANSLOG_UUID_KEY)); + assertEquals( + assertAndGetInternalTranslogManager(engine.translogManager()).getTranslogUUID(), + userData.get(Translog.TRANSLOG_UUID_KEY) + ); } } // open and recover tlog @@ -3266,12 +3284,18 @@ public void testCurrentTranslogUUIIDIsCommitted() throws IOException { expectThrows(IllegalStateException.class, engine.translogManager()::ensureCanFlush); Map userData = engine.getLastCommittedSegmentInfos().getUserData(); engine.ensureOpen(); - assertEquals(engine.translogManager().getTranslog().getTranslogUUID(), userData.get(Translog.TRANSLOG_UUID_KEY)); + assertEquals( + assertAndGetInternalTranslogManager(engine.translogManager()).getTranslogUUID(), + userData.get(Translog.TRANSLOG_UUID_KEY) + ); TranslogHandler translogHandler = createTranslogHandler(config.getIndexSettings(), engine); engine.translogManager().recoverFromTranslog(translogHandler, engine.getProcessedLocalCheckpoint(), Long.MAX_VALUE); userData = engine.getLastCommittedSegmentInfos().getUserData(); engine.ensureOpen(); - assertEquals(engine.translogManager().getTranslog().getTranslogUUID(), userData.get(Translog.TRANSLOG_UUID_KEY)); + assertEquals( + assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().getTranslogUUID(), + userData.get(Translog.TRANSLOG_UUID_KEY) + ); } } } @@ -3287,11 +3311,14 @@ public void testCurrentTranslogUUIIDIsCommitted() throws IOException { try (InternalEngine engine = new InternalEngine(config)) { Map userData = engine.getLastCommittedSegmentInfos().getUserData(); engine.ensureOpen(); - assertEquals(engine.translogManager().getTranslog().getTranslogUUID(), userData.get(Translog.TRANSLOG_UUID_KEY)); + assertEquals( + assertAndGetInternalTranslogManager(engine.translogManager()).getTranslogUUID(), + userData.get(Translog.TRANSLOG_UUID_KEY) + ); engine.translogManager().recoverFromTranslog(translogHandler, engine.getProcessedLocalCheckpoint(), Long.MAX_VALUE); engine.ensureOpen(); - assertEquals(2, engine.translogManager().getTranslog().currentFileGeneration()); - assertEquals(0L, engine.translogManager().getTranslog().stats().getUncommittedOperations()); + assertEquals(2, assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().currentFileGeneration()); + assertEquals(0L, engine.translogManager().getTranslogStats().getUncommittedOperations()); } } @@ -3301,11 +3328,17 @@ public void testCurrentTranslogUUIIDIsCommitted() throws IOException { try (InternalEngine engine = new InternalEngine(config)) { Map userData = engine.getLastCommittedSegmentInfos().getUserData(); engine.ensureOpen(); - assertEquals(engine.translogManager().getTranslog().getTranslogUUID(), userData.get(Translog.TRANSLOG_UUID_KEY)); + assertEquals( + assertAndGetInternalTranslogManager(engine.translogManager()).getTranslogUUID(), + userData.get(Translog.TRANSLOG_UUID_KEY) + ); engine.translogManager().recoverFromTranslog(translogHandler, engine.getProcessedLocalCheckpoint(), Long.MAX_VALUE); userData = engine.getLastCommittedSegmentInfos().getUserData(); engine.ensureOpen(); - assertEquals(engine.translogManager().getTranslog().getTranslogUUID(), userData.get(Translog.TRANSLOG_UUID_KEY)); + assertEquals( + assertAndGetInternalTranslogManager(engine.translogManager()).getTranslogUUID(), + userData.get(Translog.TRANSLOG_UUID_KEY) + ); } } } @@ -3447,8 +3480,7 @@ protected void commitIndexWriter(IndexWriter writer, Translog translog) throws I engine.getLastCommittedSegmentInfos().userData.get(SequenceNumbers.LOCAL_CHECKPOINT_KEY) ); engine.ensureOpen(); - final long committedGen = engine.translogManager() - .getTranslog() + final long committedGen = assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog() .getMinGenerationForSeqNo(localCheckpoint + 1).translogFileGeneration; for (int gen = 1; gen < committedGen; gen++) { final Path genFile = translogPath.resolve(Translog.getFilename(gen)); @@ -3635,7 +3667,8 @@ public void testRecoverFromForeignTranslog() throws IOException { } assertVisibleCount(engine, numDocs); engine.ensureOpen(); - Translog.TranslogGeneration generation = engine.translogManager().getTranslog().getGeneration(); + Translog.TranslogGeneration generation = assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog() + .getGeneration(); engine.close(); final Path badTranslogLog = createTempDir(); @@ -3732,7 +3765,9 @@ public CustomTranslogDeletionPolicy(IndexSettings indexSettings, Supplier { long localCheckpoint = Long.parseLong(engine.getLastCommittedSegmentInfos().userData.get(SequenceNumbers.LOCAL_CHECKPOINT_KEY)); return translog.totalOperationsByMinGen(translog.getMinGenerationForSeqNo(localCheckpoint + 1).translogFileGeneration); }; - final long extraTranslogSizeInNewEngine = engine.translogManager().getTranslog().stats().getUncommittedSizeInBytes() + final long extraTranslogSizeInNewEngine = engine.translogManager().getTranslogStats().getUncommittedSizeInBytes() - Translog.DEFAULT_HEADER_SIZE_IN_BYTES; int numDocs = between(10, 100); for (int id = 0; id < numDocs; id++) { @@ -6009,7 +6048,7 @@ public void testShouldPeriodicallyFlush() throws Exception { long flushThreshold = RandomNumbers.randomLongBetween( random(), 120, - engine.translogManager().getTranslog().stats().getUncommittedSizeInBytes() - extraTranslogSizeInNewEngine + engine.translogManager().getTranslogStats().getUncommittedSizeInBytes() - extraTranslogSizeInNewEngine ); final IndexSettings indexSettings = engine.config().getIndexSettings(); final IndexMetadata indexMetadata = IndexMetadata.builder(indexSettings.getIndexMetadata()) @@ -6026,7 +6065,7 @@ public void testShouldPeriodicallyFlush() throws Exception { indexSettings.getSoftDeleteRetentionOperations() ); engine.ensureOpen(); - assertThat(engine.translogManager().getTranslog().stats().getUncommittedOperations(), equalTo(numDocs)); + assertThat(engine.translogManager().getTranslogStats().getUncommittedOperations(), equalTo(numDocs)); assertThat(engine.shouldPeriodicallyFlush(), equalTo(true)); engine.flush(); assertThat(uncommittedTranslogOperationsSinceLastCommit.getAsInt(), equalTo(0)); @@ -6083,12 +6122,12 @@ public void testShouldPeriodicallyFlushAfterMerge() throws Exception { indexSettings.getSoftDeleteRetentionOperations() ); engine.ensureOpen(); - assertThat(engine.translogManager().getTranslog().stats().getUncommittedOperations(), equalTo(1)); + assertThat(engine.translogManager().getTranslogStats().getUncommittedOperations(), equalTo(1)); assertThat(engine.shouldPeriodicallyFlush(), equalTo(false)); doc = testParsedDocument(Integer.toString(1), null, testDocumentWithTextField(), SOURCE, null); engine.index(indexForDoc(doc)); engine.ensureOpen(); - assertThat(engine.translogManager().getTranslog().stats().getUncommittedOperations(), equalTo(2)); + assertThat(engine.translogManager().getTranslogStats().getUncommittedOperations(), equalTo(2)); engine.refresh("test"); engine.forceMerge(false, 1, false, false, false, UUIDs.randomBase64UUID()); assertBusy(() -> { @@ -6124,7 +6163,7 @@ public void testStressShouldPeriodicallyFlush() throws Exception { final ParsedDocument doc = testParsedDocument(Long.toString(seqno), null, testDocumentWithTextField(), SOURCE, null); engine.index(replicaIndexForDoc(doc, 1L, seqno, false)); engine.ensureOpen(); - if (rarely() && engine.translogManager().getTranslog().shouldRollGeneration()) { + if (rarely() && engine.translogManager().shouldRollTranslogGeneration()) { engine.translogManager().rollTranslogGeneration(); } if (rarely() || engine.shouldPeriodicallyFlush()) { @@ -6348,7 +6387,7 @@ public void testTrimUnsafeCommits() throws Exception { globalCheckpoint.set(randomInt(maxSeqNo)); engine.translogManager().syncTranslog(); engine.ensureOpen(); - minTranslogGen = engine.translogManager().getTranslog().getMinFileGeneration(); + minTranslogGen = assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().getMinFileGeneration(); } store.trimUnsafeCommits(config.getTranslogConfig().getTranslogPath()); @@ -6901,7 +6940,8 @@ public void testMaxSeqNoInCommitUserData() throws Exception { AtomicBoolean running = new AtomicBoolean(true); Thread rollTranslog = new Thread(() -> { engine.ensureOpen(); - while (running.get() && engine.translogManager().getTranslog().currentFileGeneration() < 500) { + while (running.get() + && assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().currentFileGeneration() < 500) { engine.translogManager().rollTranslogGeneration(); // make adding operations to translog slower } }); @@ -7071,8 +7111,8 @@ public void testRecoverFromLocalTranslog() throws Exception { engine.ensureOpen(); assertThat( "engine should trim all unreferenced translog after recovery", - engine.translogManager().getTranslog().getMinFileGeneration(), - equalTo(engine.translogManager().getTranslog().currentFileGeneration()) + assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().getMinFileGeneration(), + equalTo(assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().currentFileGeneration()) ); } } diff --git a/server/src/test/java/org/opensearch/index/engine/NRTReplicationEngineTests.java b/server/src/test/java/org/opensearch/index/engine/NRTReplicationEngineTests.java index 6d3e54e0648f1..29fff69a433a4 100644 --- a/server/src/test/java/org/opensearch/index/engine/NRTReplicationEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/NRTReplicationEngineTests.java @@ -38,7 +38,7 @@ public void testCreateEngine() throws IOException { final AtomicLong globalCheckpoint = new AtomicLong(SequenceNumbers.NO_OPS_PERFORMED); try ( final Store nrtEngineStore = createStore(); - final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore); + final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore) ) { final SegmentInfos latestSegmentInfos = nrtEngine.getLatestSegmentInfos(); final SegmentInfos lastCommittedSegmentInfos = nrtEngine.getLastCommittedSegmentInfos(); @@ -62,7 +62,7 @@ public void testEngineWritesOpsToTranslog() throws Exception { try ( final Store nrtEngineStore = createStore(); - final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore); + final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore) ) { List operations = generateHistoryOnReplica( between(1, 500), @@ -88,7 +88,7 @@ public void testEngineWritesOpsToTranslog() throws Exception { engine.translogManager().recoverFromTranslog(translogHandler, engine.getProcessedLocalCheckpoint(), Long.MAX_VALUE); assertEquals(getDocIds(engine, true), docs); } - assertEngineCleanedUp(nrtEngine, nrtEngine.getTranslog()); + assertEngineCleanedUp(nrtEngine, assertAndGetInternalTranslogManager(nrtEngine.translogManager()).getDeletionPolicy()); } } @@ -97,7 +97,7 @@ public void testUpdateSegments() throws Exception { try ( final Store nrtEngineStore = createStore(); - final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore); + final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore) ) { // add docs to the primary engine. List operations = generateHistoryOnReplica(between(1, 500), randomBoolean(), randomBoolean(), randomBoolean()) @@ -132,7 +132,10 @@ public void testUpdateSegments() throws Exception { Set seqNos = operations.stream().map(Engine.Operation::seqNo).collect(Collectors.toSet()); - try (Translog.Snapshot snapshot = nrtEngine.getTranslog().newSnapshot()) { + nrtEngine.ensureOpen(); + try ( + Translog.Snapshot snapshot = assertAndGetInternalTranslogManager(nrtEngine.translogManager()).getTranslog().newSnapshot() + ) { assertThat(snapshot.totalOperations(), equalTo(operations.size())); assertThat( TestTranslog.drainSnapshot(snapshot, false).stream().map(Translog.Operation::seqNo).collect(Collectors.toSet()), @@ -144,11 +147,13 @@ public void testUpdateSegments() throws Exception { assertMatchingSegmentsAndCheckpoints(nrtEngine); assertEquals( - nrtEngine.getTranslog().getGeneration().translogFileGeneration, - engine.translogManager().getTranslog().getGeneration().translogFileGeneration + assertAndGetInternalTranslogManager(nrtEngine.translogManager()).getTranslog().getGeneration().translogFileGeneration, + assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().getGeneration().translogFileGeneration ); - try (Translog.Snapshot snapshot = nrtEngine.getTranslog().newSnapshot()) { + try ( + Translog.Snapshot snapshot = assertAndGetInternalTranslogManager(nrtEngine.translogManager()).getTranslog().newSnapshot() + ) { assertThat(snapshot.totalOperations(), equalTo(operations.size())); assertThat( TestTranslog.drainSnapshot(snapshot, false).stream().map(Translog.Operation::seqNo).collect(Collectors.toSet()), @@ -162,7 +167,7 @@ public void testUpdateSegments() throws Exception { expectedDocCount = test.count(Queries.newMatchAllQuery()); assertSearcherHits(nrtEngine, expectedDocCount); } - assertEngineCleanedUp(nrtEngine, nrtEngine.getTranslog()); + assertEngineCleanedUp(nrtEngine, assertAndGetInternalTranslogManager(nrtEngine.translogManager()).getDeletionPolicy()); } } @@ -171,7 +176,7 @@ public void testTrimTranslogOps() throws Exception { try ( final Store nrtEngineStore = createStore(); - final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore); + final NRTReplicationEngine nrtEngine = buildNrtReplicaEngine(globalCheckpoint, nrtEngineStore) ) { List operations = generateHistoryOnReplica( between(1, 100), @@ -181,7 +186,10 @@ public void testTrimTranslogOps() throws Exception { ); applyOperations(nrtEngine, operations); Set seqNos = operations.stream().map(Engine.Operation::seqNo).collect(Collectors.toSet()); - try (Translog.Snapshot snapshot = nrtEngine.getTranslog().newSnapshot()) { + nrtEngine.ensureOpen(); + try ( + Translog.Snapshot snapshot = assertAndGetInternalTranslogManager(nrtEngine.translogManager()).getTranslog().newSnapshot() + ) { assertThat(snapshot.totalOperations(), equalTo(operations.size())); assertThat( TestTranslog.drainSnapshot(snapshot, false).stream().map(Translog.Operation::seqNo).collect(Collectors.toSet()), diff --git a/server/src/test/java/org/opensearch/index/engine/NoOpEngineTests.java b/server/src/test/java/org/opensearch/index/engine/NoOpEngineTests.java index 1ab7e3d7bc093..e53a3b09a5eb6 100644 --- a/server/src/test/java/org/opensearch/index/engine/NoOpEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/NoOpEngineTests.java @@ -222,7 +222,7 @@ public void testTrimUnreferencedTranslogFiles() throws Exception { } // prevent translog from trimming so we can test trimUnreferencedFiles in NoOpEngine. engine.ensureOpen(); - final Translog.Snapshot snapshot = engine.translogManager().getTranslog().newSnapshot(); + final Translog.Snapshot snapshot = assertAndGetInternalTranslogManager(engine.translogManager()).getTranslog().newSnapshot(); engine.flush(true, true); engine.close(); diff --git a/test/framework/src/main/java/org/opensearch/index/engine/EngineTestCase.java b/test/framework/src/main/java/org/opensearch/index/engine/EngineTestCase.java index a8b5b03e03877..174747d306ff5 100644 --- a/test/framework/src/main/java/org/opensearch/index/engine/EngineTestCase.java +++ b/test/framework/src/main/java/org/opensearch/index/engine/EngineTestCase.java @@ -111,8 +111,11 @@ import org.opensearch.index.seqno.SequenceNumbers; import org.opensearch.index.shard.ShardId; import org.opensearch.index.store.Store; +import org.opensearch.index.translog.InternalTranslogManager; import org.opensearch.index.translog.Translog; import org.opensearch.index.translog.TranslogConfig; +import org.opensearch.index.translog.TranslogDeletionPolicy; +import org.opensearch.index.translog.TranslogManager; import org.opensearch.index.translog.listener.TranslogEventListener; import org.opensearch.indices.breaker.CircuitBreakerService; import org.opensearch.indices.breaker.NoneCircuitBreakerService; @@ -149,6 +152,7 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.lessThanOrEqualTo; import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.instanceOf; import static org.opensearch.index.engine.Engine.Operation.Origin.PEER_RECOVERY; import static org.opensearch.index.engine.Engine.Operation.Origin.PRIMARY; import static org.opensearch.index.engine.Engine.Operation.Origin.REPLICA; @@ -329,23 +333,33 @@ public void tearDown() throws Exception { try { if (engine != null && engine.isClosed.get() == false) { engine.ensureOpen(); - assertEngineCleanedUp(engine, engine.translogManager().getTranslog()); + assertEngineCleanedUp(engine, assertAndGetInternalTranslogManager(engine.translogManager()).getDeletionPolicy()); } if (replicaEngine != null && replicaEngine.isClosed.get() == false) { replicaEngine.ensureOpen(); - assertEngineCleanedUp(replicaEngine, replicaEngine.translogManager().getTranslog()); + assertEngineCleanedUp( + replicaEngine, + assertAndGetInternalTranslogManager(replicaEngine.translogManager()).getDeletionPolicy() + ); } } finally { IOUtils.close(replicaEngine, storeReplica, engine, store, () -> terminate(threadPool)); } } - protected void assertEngineCleanedUp(Engine engine, Translog translog) throws Exception { - translog.getDeletionPolicy().assertNoOpenTranslogRefs(); - assertConsistentHistoryBetweenTranslogAndLuceneIndex(engine); - assertNoInFlightDocuments(engine); - assertMaxSeqNoInCommitUserData(engine); - assertAtMostOneLuceneDocumentPerSequenceNumber(engine); + protected InternalTranslogManager assertAndGetInternalTranslogManager(final TranslogManager translogManager) { + assertThat(translogManager, instanceOf(InternalTranslogManager.class)); + return (InternalTranslogManager) translogManager; + } + + protected void assertEngineCleanedUp(Engine engine, TranslogDeletionPolicy translogDeletionPolicy) throws Exception { + if (engine.isClosed.get() == false) { + translogDeletionPolicy.assertNoOpenTranslogRefs(); + assertConsistentHistoryBetweenTranslogAndLuceneIndex(engine); + assertNoInFlightDocuments(engine); + assertMaxSeqNoInCommitUserData(engine); + assertAtMostOneLuceneDocumentPerSequenceNumber(engine); + } } protected static ParseContext.Document testDocumentWithTextField() { @@ -1481,7 +1495,11 @@ public static Translog getTranslog(Engine engine) { assert engine instanceof InternalEngine : "only InternalEngines have translogs, got: " + engine.getClass(); InternalEngine internalEngine = (InternalEngine) engine; internalEngine.ensureOpen(); - return internalEngine.translogManager().getTranslog(); + TranslogManager translogManager = internalEngine.translogManager(); + assert translogManager instanceof InternalTranslogManager : "only InternalTranslogManager have translogs, got: " + + engine.getClass(); + InternalTranslogManager internalTranslogManager = (InternalTranslogManager) translogManager; + return internalTranslogManager.getTranslog(); } /**