|
@@ -62,7 +62,7 @@ public class ReadOnlyEngineTests extends EngineTestCase {
|
|
|
globalCheckpoint.set(randomLongBetween(globalCheckpoint.get(), engine.getPersistedLocalCheckpoint()));
|
|
globalCheckpoint.set(randomLongBetween(globalCheckpoint.get(), engine.getPersistedLocalCheckpoint()));
|
|
|
engine.flush();
|
|
engine.flush();
|
|
|
readOnlyEngine = new ReadOnlyEngine(engine.engineConfig, engine.getSeqNoStats(globalCheckpoint.get()),
|
|
readOnlyEngine = new ReadOnlyEngine(engine.engineConfig, engine.getSeqNoStats(globalCheckpoint.get()),
|
|
|
- engine.getTranslogStats(), false, Function.identity(), true);
|
|
|
|
|
|
|
+ engine.getTranslogStats(), false, Function.identity(), true, randomBoolean());
|
|
|
lastSeqNoStats = engine.getSeqNoStats(globalCheckpoint.get());
|
|
lastSeqNoStats = engine.getSeqNoStats(globalCheckpoint.get());
|
|
|
lastDocIds = getDocIds(engine, true);
|
|
lastDocIds = getDocIds(engine, true);
|
|
|
assertThat(readOnlyEngine.getPersistedLocalCheckpoint(), equalTo(lastSeqNoStats.getLocalCheckpoint()));
|
|
assertThat(readOnlyEngine.getPersistedLocalCheckpoint(), equalTo(lastSeqNoStats.getLocalCheckpoint()));
|
|
@@ -77,6 +77,11 @@ public class ReadOnlyEngineTests extends EngineTestCase {
|
|
|
engine.flush();
|
|
engine.flush();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ try (ReadOnlyEngine readOnlyEngineWithLazySoftDeletes = new ReadOnlyEngine(engine.engineConfig,
|
|
|
|
|
+ engine.getSeqNoStats(globalCheckpoint.get()),
|
|
|
|
|
+ engine.getTranslogStats(), false, Function.identity(), true, true)) {
|
|
|
|
|
+ EngineTestCase.checkNoSoftDeletesLoaded(readOnlyEngineWithLazySoftDeletes);
|
|
|
|
|
+ }
|
|
|
Engine.Searcher external = readOnlyEngine.acquireSearcher("test", Engine.SearcherScope.EXTERNAL);
|
|
Engine.Searcher external = readOnlyEngine.acquireSearcher("test", Engine.SearcherScope.EXTERNAL);
|
|
|
Engine.Searcher internal = readOnlyEngine.acquireSearcher("test", Engine.SearcherScope.INTERNAL);
|
|
Engine.Searcher internal = readOnlyEngine.acquireSearcher("test", Engine.SearcherScope.INTERNAL);
|
|
|
assertSame(external.getIndexReader(), internal.getIndexReader());
|
|
assertSame(external.getIndexReader(), internal.getIndexReader());
|
|
@@ -128,7 +133,7 @@ public class ReadOnlyEngineTests extends EngineTestCase {
|
|
|
engine.flushAndClose();
|
|
engine.flushAndClose();
|
|
|
|
|
|
|
|
IllegalStateException exception = expectThrows(IllegalStateException.class,
|
|
IllegalStateException exception = expectThrows(IllegalStateException.class,
|
|
|
- () -> new ReadOnlyEngine(config, null, null, true, Function.identity(), true) {
|
|
|
|
|
|
|
+ () -> new ReadOnlyEngine(config, null, null, true, Function.identity(), true, randomBoolean()) {
|
|
|
@Override
|
|
@Override
|
|
|
protected boolean assertMaxSeqNoEqualsToGlobalCheckpoint(final long maxSeqNo, final long globalCheckpoint) {
|
|
protected boolean assertMaxSeqNoEqualsToGlobalCheckpoint(final long maxSeqNo, final long globalCheckpoint) {
|
|
|
// we don't want the assertion to trip in this test
|
|
// we don't want the assertion to trip in this test
|
|
@@ -147,7 +152,8 @@ public class ReadOnlyEngineTests extends EngineTestCase {
|
|
|
try (Store store = createStore()) {
|
|
try (Store store = createStore()) {
|
|
|
EngineConfig config = config(defaultSettings, store, createTempDir(), newMergePolicy(), null, null, globalCheckpoint::get);
|
|
EngineConfig config = config(defaultSettings, store, createTempDir(), newMergePolicy(), null, null, globalCheckpoint::get);
|
|
|
store.createEmpty();
|
|
store.createEmpty();
|
|
|
- try (ReadOnlyEngine readOnlyEngine = new ReadOnlyEngine(config, null , new TranslogStats(), true, Function.identity(), true)) {
|
|
|
|
|
|
|
+ try (ReadOnlyEngine readOnlyEngine = new ReadOnlyEngine(config, null , new TranslogStats(), true, Function.identity(), true,
|
|
|
|
|
+ randomBoolean())) {
|
|
|
Class<? extends Throwable> expectedException = LuceneTestCase.TEST_ASSERTS_ENABLED ? AssertionError.class :
|
|
Class<? extends Throwable> expectedException = LuceneTestCase.TEST_ASSERTS_ENABLED ? AssertionError.class :
|
|
|
UnsupportedOperationException.class;
|
|
UnsupportedOperationException.class;
|
|
|
expectThrows(expectedException, () -> readOnlyEngine.index(null));
|
|
expectThrows(expectedException, () -> readOnlyEngine.index(null));
|
|
@@ -167,7 +173,8 @@ public class ReadOnlyEngineTests extends EngineTestCase {
|
|
|
try (Store store = createStore()) {
|
|
try (Store store = createStore()) {
|
|
|
EngineConfig config = config(defaultSettings, store, createTempDir(), newMergePolicy(), null, null, globalCheckpoint::get);
|
|
EngineConfig config = config(defaultSettings, store, createTempDir(), newMergePolicy(), null, null, globalCheckpoint::get);
|
|
|
store.createEmpty();
|
|
store.createEmpty();
|
|
|
- try (ReadOnlyEngine readOnlyEngine = new ReadOnlyEngine(config, null , new TranslogStats(), true, Function.identity(), true)) {
|
|
|
|
|
|
|
+ try (ReadOnlyEngine readOnlyEngine = new ReadOnlyEngine(config, null , new TranslogStats(), true, Function.identity(), true,
|
|
|
|
|
+ randomBoolean())) {
|
|
|
globalCheckpoint.set(randomNonNegativeLong());
|
|
globalCheckpoint.set(randomNonNegativeLong());
|
|
|
try {
|
|
try {
|
|
|
readOnlyEngine.verifyEngineBeforeIndexClosing();
|
|
readOnlyEngine.verifyEngineBeforeIndexClosing();
|
|
@@ -198,7 +205,8 @@ public class ReadOnlyEngineTests extends EngineTestCase {
|
|
|
numSegments = engine.getLastCommittedSegmentInfos().size();
|
|
numSegments = engine.getLastCommittedSegmentInfos().size();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- try (ReadOnlyEngine readOnlyEngine = new ReadOnlyEngine(config, null , null, true, Function.identity(), true)) {
|
|
|
|
|
|
|
+ try (ReadOnlyEngine readOnlyEngine = new ReadOnlyEngine(config, null , null, true, Function.identity(), true,
|
|
|
|
|
+ randomBoolean())) {
|
|
|
if (numSegments > 1) {
|
|
if (numSegments > 1) {
|
|
|
final int target = between(1, numSegments - 1);
|
|
final int target = between(1, numSegments - 1);
|
|
|
UnsupportedOperationException exception = expectThrows(UnsupportedOperationException.class,
|
|
UnsupportedOperationException exception = expectThrows(UnsupportedOperationException.class,
|
|
@@ -234,7 +242,8 @@ public class ReadOnlyEngineTests extends EngineTestCase {
|
|
|
engine.syncTranslog();
|
|
engine.syncTranslog();
|
|
|
engine.flushAndClose();
|
|
engine.flushAndClose();
|
|
|
}
|
|
}
|
|
|
- try (ReadOnlyEngine readOnlyEngine = new ReadOnlyEngine(config, null , null, true, Function.identity(), true)) {
|
|
|
|
|
|
|
+ try (ReadOnlyEngine readOnlyEngine = new ReadOnlyEngine(config, null , null, true, Function.identity(), true,
|
|
|
|
|
+ randomBoolean())) {
|
|
|
final TranslogHandler translogHandler = new TranslogHandler(xContentRegistry(), config.getIndexSettings());
|
|
final TranslogHandler translogHandler = new TranslogHandler(xContentRegistry(), config.getIndexSettings());
|
|
|
readOnlyEngine.recoverFromTranslog(translogHandler, randomNonNegativeLong());
|
|
readOnlyEngine.recoverFromTranslog(translogHandler, randomNonNegativeLong());
|
|
|
|
|
|
|
@@ -276,7 +285,8 @@ public class ReadOnlyEngineTests extends EngineTestCase {
|
|
|
engine.flush(true, true);
|
|
engine.flush(true, true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- try (ReadOnlyEngine readOnlyEngine = new ReadOnlyEngine(config, null, null, true, Function.identity(), true)) {
|
|
|
|
|
|
|
+ try (ReadOnlyEngine readOnlyEngine = new ReadOnlyEngine(config, null, null, true, Function.identity(), true,
|
|
|
|
|
+ randomBoolean())) {
|
|
|
assertThat(readOnlyEngine.getTranslogStats().estimatedNumberOfOperations(), equalTo(softDeletesEnabled ? 0 : numDocs));
|
|
assertThat(readOnlyEngine.getTranslogStats().estimatedNumberOfOperations(), equalTo(softDeletesEnabled ? 0 : numDocs));
|
|
|
assertThat(readOnlyEngine.getTranslogStats().getUncommittedOperations(), equalTo(0));
|
|
assertThat(readOnlyEngine.getTranslogStats().getUncommittedOperations(), equalTo(0));
|
|
|
assertThat(readOnlyEngine.getTranslogStats().getTranslogSizeInBytes(), greaterThan(0L));
|
|
assertThat(readOnlyEngine.getTranslogStats().getTranslogSizeInBytes(), greaterThan(0L));
|
|
@@ -313,7 +323,8 @@ public class ReadOnlyEngineTests extends EngineTestCase {
|
|
|
}
|
|
}
|
|
|
globalCheckpoint.set(engine.getProcessedLocalCheckpoint());
|
|
globalCheckpoint.set(engine.getProcessedLocalCheckpoint());
|
|
|
}
|
|
}
|
|
|
- try (ReadOnlyEngine readOnlyEngine = new ReadOnlyEngine(config, null, null, true, Function.identity(), true)) {
|
|
|
|
|
|
|
+ try (ReadOnlyEngine readOnlyEngine = new ReadOnlyEngine(config, null, null, true, Function.identity(), true,
|
|
|
|
|
+ randomBoolean())) {
|
|
|
try (Engine.SearcherSupplier searcher =
|
|
try (Engine.SearcherSupplier searcher =
|
|
|
readOnlyEngine.acquireSearcherSupplier(Function.identity(), randomFrom(Engine.SearcherScope.values()))) {
|
|
readOnlyEngine.acquireSearcherSupplier(Function.identity(), randomFrom(Engine.SearcherScope.values()))) {
|
|
|
assertThat(searcher.getSearcherId(), equalTo(lastSearcherId));
|
|
assertThat(searcher.getSearcherId(), equalTo(lastSearcherId));
|