Package org.elasticsearch.index.engine
Class EngineTestCase
- java.lang.Object
-
- org.junit.Assert
-
- org.apache.lucene.util.LuceneTestCase
-
- org.elasticsearch.test.ESTestCase
-
- org.elasticsearch.index.engine.EngineTestCase
-
public abstract class EngineTestCase extends ESTestCase
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
EngineTestCase.IndexWriterFactory
static class
EngineTestCase.PrimaryTermSupplier
-
Nested classes/interfaces inherited from class org.elasticsearch.test.ESTestCase
ESTestCase.GeohashGenerator, ESTestCase.TestAnalysis
-
Nested classes/interfaces inherited from class org.apache.lucene.util.LuceneTestCase
org.apache.lucene.util.LuceneTestCase.AwaitsFix, org.apache.lucene.util.LuceneTestCase.BadApple, org.apache.lucene.util.LuceneTestCase.Monster, org.apache.lucene.util.LuceneTestCase.Nightly, org.apache.lucene.util.LuceneTestCase.Slow, org.apache.lucene.util.LuceneTestCase.SuppressCodecs, org.apache.lucene.util.LuceneTestCase.SuppressFileSystems, org.apache.lucene.util.LuceneTestCase.SuppressFsync, org.apache.lucene.util.LuceneTestCase.SuppressReproduceLine, org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks, org.apache.lucene.util.LuceneTestCase.SuppressTempFileChecks, org.apache.lucene.util.LuceneTestCase.ThrowingRunnable, org.apache.lucene.util.LuceneTestCase.Weekly
-
-
Field Summary
Fields Modifier and Type Field Description protected AllocationId
allocationId
protected static BytesReference
B_1
protected static BytesReference
B_2
protected static BytesReference
B_3
protected java.lang.String
codecName
protected IndexSettings
defaultSettings
protected InternalEngine
engine
protected static IndexSettings
INDEX_SETTINGS
protected EngineTestCase.PrimaryTermSupplier
primaryTerm
protected java.nio.file.Path
primaryTranslogDir
protected InternalEngine
replicaEngine
protected java.nio.file.Path
replicaTranslogDir
protected ShardId
shardId
protected static BytesArray
SOURCE
protected Store
store
protected Store
storeReplica
protected ThreadPool
threadPool
protected TranslogHandler
translogHandler
-
Fields inherited from class org.elasticsearch.test.ESTestCase
checkIndexFailed, deprecationLogger, failureAndSuccessEvents, JAVA_TIMEZONE_IDS, JAVA_ZONE_IDS, JODA_TIMEZONE_IDS, logger
-
Fields inherited from class org.apache.lucene.util.LuceneTestCase
assertsAreEnabled, classRules, DEFAULT_LINE_DOCS_FILE, INFOSTREAM, JENKINS_LARGE_LINE_DOCS_FILE, LEAVE_TEMPORARY, MAYBE_CACHE_POLICY, RANDOM_MULTIPLIER, ruleChain, suiteFailureMarker, SYSPROP_AWAITSFIX, SYSPROP_BADAPPLES, SYSPROP_FAILFAST, SYSPROP_MAXFAILURES, SYSPROP_MONSTER, SYSPROP_NIGHTLY, SYSPROP_SLOW, SYSPROP_WEEKLY, TEST_ASSERTS_ENABLED, TEST_AWAITSFIX, TEST_BADAPPLES, TEST_CODEC, TEST_DIRECTORY, TEST_DOCVALUESFORMAT, TEST_LINE_DOCS_FILE, TEST_MONSTER, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_SLOW, TEST_THROTTLING, TEST_WEEKLY, VERBOSE
-
-
Constructor Summary
Constructors Constructor Description EngineTestCase()
-
Method Summary
Modifier and Type Method Description static Engine.Result
applyOperation(Engine engine, Engine.Operation operation)
static void
applyOperations(Engine engine, java.util.List<Engine.Operation> operations)
static void
assertConsistentHistoryBetweenTranslogAndLuceneIndex(Engine engine, MapperService mapper)
Asserts the provided engine has a consistent document history between translog and Lucene index.static void
assertMaxSeqNoInCommitUserData(Engine engine)
Asserts that the max_seq_no stored in the commit's user_data is never smaller than seq_no of any document in the commit.static void
assertOpsOnReplica(java.util.List<Engine.Operation> ops, InternalEngine replicaEngine, boolean shuffleOps, org.apache.logging.log4j.Logger logger)
protected static void
assertVisibleCount(Engine engine, int numDocs)
protected static void
assertVisibleCount(Engine engine, int numDocs, boolean refresh)
protected static void
assertVisibleCount(InternalEngine engine, int numDocs)
protected static void
assertVisibleCount(InternalEngine engine, int numDocs, boolean refresh)
protected static BytesArray
bytesArray(java.lang.String string)
static void
concurrentlyApplyOps(java.util.List<Engine.Operation> ops, InternalEngine engine)
EngineConfig
config(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, ReferenceManager.RefreshListener refreshListener)
EngineConfig
config(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, ReferenceManager.RefreshListener externalRefreshListener, ReferenceManager.RefreshListener internalRefreshListener, Sort indexSort, java.util.function.LongSupplier maybeGlobalCheckpointSupplier, java.util.function.Supplier<RetentionLeases> maybeRetentionLeasesSupplier, CircuitBreakerService breakerService)
EngineConfig
config(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, ReferenceManager.RefreshListener externalRefreshListener, ReferenceManager.RefreshListener internalRefreshListener, Sort indexSort, java.util.function.LongSupplier maybeGlobalCheckpointSupplier, CircuitBreakerService breakerService)
EngineConfig
config(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, ReferenceManager.RefreshListener refreshListener, Sort indexSort, java.util.function.LongSupplier globalCheckpointSupplier)
EngineConfig
config(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, ReferenceManager.RefreshListener refreshListener, Sort indexSort, java.util.function.LongSupplier globalCheckpointSupplier, java.util.function.Supplier<RetentionLeases> retentionLeasesSupplier)
EngineConfig
copy(EngineConfig config, java.util.function.LongSupplier globalCheckpointSupplier)
EngineConfig
copy(EngineConfig config, org.apache.lucene.analysis.Analyzer analyzer)
EngineConfig
copy(EngineConfig config, MergePolicy mergePolicy)
protected InternalEngine
createEngine(EngineConfig config)
protected InternalEngine
createEngine(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy)
protected InternalEngine
createEngine(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, EngineTestCase.IndexWriterFactory indexWriterFactory)
protected InternalEngine
createEngine(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, EngineTestCase.IndexWriterFactory indexWriterFactory, java.util.function.BiFunction<java.lang.Long,java.lang.Long,LocalCheckpointTracker> localCheckpointTrackerSupplier, java.util.function.LongSupplier globalCheckpointSupplier)
protected InternalEngine
createEngine(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, EngineTestCase.IndexWriterFactory indexWriterFactory, java.util.function.BiFunction<java.lang.Long,java.lang.Long,LocalCheckpointTracker> localCheckpointTrackerSupplier, java.util.function.LongSupplier globalCheckpointSupplier, java.util.function.ToLongBiFunction<Engine,Engine.Operation> seqNoForOperation)
protected InternalEngine
createEngine(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, EngineTestCase.IndexWriterFactory indexWriterFactory, java.util.function.BiFunction<java.lang.Long,java.lang.Long,LocalCheckpointTracker> localCheckpointTrackerSupplier, java.util.function.ToLongBiFunction<Engine,Engine.Operation> seqNoForOperation, Sort indexSort, java.util.function.LongSupplier globalCheckpointSupplier)
protected InternalEngine
createEngine(Store store, java.nio.file.Path translogPath)
protected InternalEngine
createEngine(Store store, java.nio.file.Path translogPath, java.util.function.BiFunction<java.lang.Long,java.lang.Long,LocalCheckpointTracker> localCheckpointTrackerSupplier)
protected InternalEngine
createEngine(Store store, java.nio.file.Path translogPath, java.util.function.BiFunction<java.lang.Long,java.lang.Long,LocalCheckpointTracker> localCheckpointTrackerSupplier, java.util.function.ToLongBiFunction<Engine,Engine.Operation> seqNoForOperation)
protected InternalEngine
createEngine(Store store, java.nio.file.Path translogPath, java.util.function.LongSupplier globalCheckpointSupplier)
static InternalEngine
createInternalEngine(EngineTestCase.IndexWriterFactory indexWriterFactory, java.util.function.BiFunction<java.lang.Long,java.lang.Long,LocalCheckpointTracker> localCheckpointTrackerSupplier, java.util.function.ToLongBiFunction<Engine,Engine.Operation> seqNoForOperation, EngineConfig config)
static MapperService
createMapperService(java.lang.String type)
static ParsedDocument
createParsedDoc(java.lang.String id, java.lang.String routing)
static ParsedDocument
createParsedDoc(java.lang.String id, java.lang.String routing, boolean recoverySource)
protected Store
createStore()
protected Store
createStore(org.apache.lucene.store.Directory directory)
protected Store
createStore(IndexSettings indexSettings, org.apache.lucene.store.Directory directory)
protected Translog
createTranslog(java.nio.file.Path translogPath, java.util.function.LongSupplier primaryTermSupplier)
protected Translog
createTranslog(java.util.function.LongSupplier primaryTermSupplier)
protected TranslogHandler
createTranslogHandler(IndexSettings indexSettings)
java.util.List<Engine.Operation>
generateHistoryOnReplica(int numOps, boolean allowGapInSeqNo, boolean allowDuplicate, boolean includeNestedDocs)
static long
generateNewSeqNo(Engine engine)
Generate a new sequence number and return it.static java.util.List<Engine.Operation>
generateSingleDocHistory(boolean forReplica, VersionType versionType, boolean partialOldPrimary, long primaryTerm, int minOpCount, int maxOpCount, java.lang.String docId)
static java.util.List<DocIdSeqNoAndTerm>
getDocIds(Engine engine, boolean refresh)
Gets a collection of tuples of docId, sequence number, and primary term of all live documents in the provided engine.static Translog
getTranslog(Engine engine)
Exposes a translog associated with the given engine for testing purpose.static boolean
hasSnapshottedCommits(Engine engine)
protected Engine.Index
indexForDoc(ParsedDocument doc)
protected Settings
indexSettings()
static CheckedBiFunction<java.lang.String,java.lang.Integer,ParsedDocument,java.io.IOException>
nestedParsedDocFactory()
protected Engine.Get
newGet(boolean realtime, ParsedDocument doc)
static Term
newUid(java.lang.String id)
static Term
newUid(ParsedDocument doc)
static java.util.List<Translog.Operation>
readAllOperationsInLucene(Engine engine, MapperService mapper)
Reads all engine operations that have been processed by the engine from Lucene index.protected Engine.Delete
replicaDeleteForDoc(java.lang.String id, long version, long seqNo, long startTime)
protected Engine.Index
replicaIndexForDoc(ParsedDocument doc, long version, long seqNo, boolean isRetry)
void
setUp()
void
tearDown()
protected static ParseContext.Document
testDocument()
protected static ParseContext.Document
testDocumentWithTextField()
protected static ParseContext.Document
testDocumentWithTextField(java.lang.String value)
protected static ParsedDocument
testParsedDocument(java.lang.String id, java.lang.String routing, ParseContext.Document document, BytesReference source, Mapping mappingUpdate)
protected static ParsedDocument
testParsedDocument(java.lang.String id, java.lang.String routing, ParseContext.Document document, BytesReference source, Mapping mappingUpdate, boolean recoverySource)
static EngineConfig.TombstoneDocSupplier
tombstoneDocSupplier()
Creates a tombstone document that only includes uid, seq#, term and version fields.static void
waitForOpsToComplete(InternalEngine engine, long seqNo)
Waits for all operations up to the provided sequence number to complete in the given internal engine.-
Methods inherited from class org.elasticsearch.test.ESTestCase
after, afterIfFailed, afterIfSuccessful, assertAllIndicesRemovedAndDeletionCompleted, assertArrayEquals, assertBusy, assertBusy, assertEquals, assertEqualsWithErrorMessageFromXContent, assertPathHasBeenCleared, assertSettingDeprecationsAndWarnings, assertSettingDeprecationsAndWarnings, assertWarnings, awaitBusy, awaitBusy, before, between, buildNewFakeTransportAddress, checkStaticState, copyInstance, copyStreamable, copyWriteable, copyWriteable, createParser, createParser, createParser, createParser, createParser, createTestAnalysis, createTestAnalysis, createTestAnalysis, enableWarningsCheck, ensureAllSearchContextsReleased, ensureCheckIndexPassed, ensureSupportedLocale, frequently, generateRandomStringArray, generateRandomStringArray, getBwcIndicesPath, getDataPath, getSuiteFailureMarker, getTestTransportPlugin, getTestTransportType, inFipsJvm, iterations, maybeSet, mockScript, newNodeEnvironment, newNodeEnvironment, newTestIndicesModule, newTestScriptModule, randomAlphaOfLength, randomAlphaOfLengthBetween, randomArray, randomArray, randomBoolean, randomByte, randomByteArrayOfLength, randomDateTimeZone, randomDouble, randomDoubleBetween, randomFloat, randomFrom, randomFrom, randomFrom, randomFrom, randomFrom, randomGeohash, randomInt, randomInt, randomIntBetween, randomLong, randomLongBetween, randomNonNegativeLong, randomPositiveTimeValue, randomRealisticUnicodeOfCodepointLength, randomRealisticUnicodeOfCodepointLengthBetween, randomRealisticUnicodeOfLength, randomRealisticUnicodeOfLengthBetween, randomShort, randomSubsetOf, randomSubsetOf, randomSubsetOf, randomTimeValue, randomTimeValue, randomTimeValue, randomTimeZone, randomUnicodeOfCodepointLength, randomUnicodeOfCodepointLengthBetween, randomUnicodeOfLength, randomUnicodeOfLengthBetween, randomUnique, randomValueOtherThan, randomValueOtherThanMany, randomZone, resetCheckIndexStatus, resetPortCounter, restoreContentType, restoreFileSystem, scaledRandomIntBetween, setContentType, setFileSystem, settings, shuffleMap, shuffleXContent, shuffleXContent, spinForAtLeastNMilliseconds, spinForAtLeastOneMillisecond, terminate, terminate, tmpPaths, toShuffledXContent, toShuffledXContent, writableRegistry, xContentRegistry
-
Methods inherited from class org.apache.lucene.util.LuceneTestCase
addVirusChecker, assertDeletedDocsEquals, assertDocsAndPositionsEnumEquals, assertDocsEnumEquals, assertDocsSkippingEquals, assertDocValuesEquals, assertDocValuesEquals, assertFieldInfosEquals, assertFieldsEquals, assertFieldStatisticsEquals, assertNormsEquals, assertPointsEquals, assertPositionsSkippingEquals, assertReaderEquals, assertReaderStatisticsEquals, assertStoredFieldEquals, assertStoredFieldsEquals, assertTermsEnumEquals, assertTermsEquals, assertTermsStatisticsEquals, assertTermStatsEquals, assertTermVectorsEquals, asSet, assumeFalse, assumeNoException, assumeTrue, assumeWorkingMMapOnWindows, atLeast, atLeast, closeAfterSuite, closeAfterTest, collate, createTempDir, createTempDir, createTempFile, createTempFile, dumpArray, dumpIterator, expectThrows, expectThrows, expectThrows, expectThrowsAnyOf, expectThrowsAnyOf, getBaseTempDirForTestClass, getDataInputStream, getOnlyLeafReader, getTestClass, getTestName, hasWorkingMMapOnWindows, isTestThread, localeForLanguageTag, maybeChangeLiveIndexWriterConfig, maybeWrapReader, newAlcoholicMergePolicy, newAlcoholicMergePolicy, newDirectory, newDirectory, newDirectory, newDirectory, newDirectory, newField, newField, newFSDirectory, newFSDirectory, newIndexWriterConfig, newIndexWriterConfig, newIndexWriterConfig, newIOContext, newIOContext, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newLogMergePolicy, newMaybeVirusCheckingDirectory, newMaybeVirusCheckingFSDirectory, newMergePolicy, newMergePolicy, newMergePolicy, newMockDirectory, newMockDirectory, newMockDirectory, newMockFSDirectory, newMockFSDirectory, newSearcher, newSearcher, newSearcher, newStringField, newStringField, newStringField, newStringField, newTextField, newTextField, newTieredMergePolicy, newTieredMergePolicy, overrideDefaultQueryCache, overrideTestDefaultQueryCache, random, randomLocale, randomTimeZone, rarely, rarely, replaceMaxFailureRule, resetDefaultQueryCache, restoreCPUCoreCount, restoreIndexWriterMaxDocs, restoreSpins, runWithRestrictedPermissions, setIndexWriterMaxDocs, setupCPUCoreCount, setupSpins, slowFileExists, usually, usually, wrapReader
-
Methods inherited from class org.junit.Assert
assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, fail
-
-
-
-
Field Detail
-
shardId
protected final ShardId shardId
-
allocationId
protected final AllocationId allocationId
-
INDEX_SETTINGS
protected static final IndexSettings INDEX_SETTINGS
-
threadPool
protected ThreadPool threadPool
-
translogHandler
protected TranslogHandler translogHandler
-
store
protected Store store
-
storeReplica
protected Store storeReplica
-
engine
protected InternalEngine engine
-
replicaEngine
protected InternalEngine replicaEngine
-
defaultSettings
protected IndexSettings defaultSettings
-
codecName
protected java.lang.String codecName
-
primaryTranslogDir
protected java.nio.file.Path primaryTranslogDir
-
replicaTranslogDir
protected java.nio.file.Path replicaTranslogDir
-
primaryTerm
protected final EngineTestCase.PrimaryTermSupplier primaryTerm
-
B_1
protected static final BytesReference B_1
-
B_2
protected static final BytesReference B_2
-
B_3
protected static final BytesReference B_3
-
SOURCE
protected static final BytesArray SOURCE
-
-
Method Detail
-
assertVisibleCount
protected static void assertVisibleCount(Engine engine, int numDocs) throws java.io.IOException
- Throws:
java.io.IOException
-
assertVisibleCount
protected static void assertVisibleCount(Engine engine, int numDocs, boolean refresh) throws java.io.IOException
- Throws:
java.io.IOException
-
indexSettings
protected Settings indexSettings()
-
setUp
public void setUp() throws java.lang.Exception
- Overrides:
setUp
in classorg.apache.lucene.util.LuceneTestCase
- Throws:
java.lang.Exception
-
copy
public EngineConfig copy(EngineConfig config, java.util.function.LongSupplier globalCheckpointSupplier)
-
copy
public EngineConfig copy(EngineConfig config, org.apache.lucene.analysis.Analyzer analyzer)
-
copy
public EngineConfig copy(EngineConfig config, MergePolicy mergePolicy)
-
tearDown
public void tearDown() throws java.lang.Exception
- Overrides:
tearDown
in classorg.apache.lucene.util.LuceneTestCase
- Throws:
java.lang.Exception
-
testDocumentWithTextField
protected static ParseContext.Document testDocumentWithTextField()
-
testDocumentWithTextField
protected static ParseContext.Document testDocumentWithTextField(java.lang.String value)
-
testDocument
protected static ParseContext.Document testDocument()
-
createParsedDoc
public static ParsedDocument createParsedDoc(java.lang.String id, java.lang.String routing)
-
createParsedDoc
public static ParsedDocument createParsedDoc(java.lang.String id, java.lang.String routing, boolean recoverySource)
-
testParsedDocument
protected static ParsedDocument testParsedDocument(java.lang.String id, java.lang.String routing, ParseContext.Document document, BytesReference source, Mapping mappingUpdate)
-
testParsedDocument
protected static ParsedDocument testParsedDocument(java.lang.String id, java.lang.String routing, ParseContext.Document document, BytesReference source, Mapping mappingUpdate, boolean recoverySource)
-
nestedParsedDocFactory
public static CheckedBiFunction<java.lang.String,java.lang.Integer,ParsedDocument,java.io.IOException> nestedParsedDocFactory() throws java.lang.Exception
- Throws:
java.lang.Exception
-
tombstoneDocSupplier
public static EngineConfig.TombstoneDocSupplier tombstoneDocSupplier()
Creates a tombstone document that only includes uid, seq#, term and version fields.
-
createStore
protected Store createStore() throws java.io.IOException
- Throws:
java.io.IOException
-
createStore
protected Store createStore(org.apache.lucene.store.Directory directory) throws java.io.IOException
- Throws:
java.io.IOException
-
createStore
protected Store createStore(IndexSettings indexSettings, org.apache.lucene.store.Directory directory) throws java.io.IOException
- Throws:
java.io.IOException
-
createTranslog
protected Translog createTranslog(java.util.function.LongSupplier primaryTermSupplier) throws java.io.IOException
- Throws:
java.io.IOException
-
createTranslog
protected Translog createTranslog(java.nio.file.Path translogPath, java.util.function.LongSupplier primaryTermSupplier) throws java.io.IOException
- Throws:
java.io.IOException
-
createTranslogHandler
protected TranslogHandler createTranslogHandler(IndexSettings indexSettings)
-
createEngine
protected InternalEngine createEngine(Store store, java.nio.file.Path translogPath) throws java.io.IOException
- Throws:
java.io.IOException
-
createEngine
protected InternalEngine createEngine(Store store, java.nio.file.Path translogPath, java.util.function.LongSupplier globalCheckpointSupplier) throws java.io.IOException
- Throws:
java.io.IOException
-
createEngine
protected InternalEngine createEngine(Store store, java.nio.file.Path translogPath, java.util.function.BiFunction<java.lang.Long,java.lang.Long,LocalCheckpointTracker> localCheckpointTrackerSupplier) throws java.io.IOException
- Throws:
java.io.IOException
-
createEngine
protected InternalEngine createEngine(Store store, java.nio.file.Path translogPath, java.util.function.BiFunction<java.lang.Long,java.lang.Long,LocalCheckpointTracker> localCheckpointTrackerSupplier, java.util.function.ToLongBiFunction<Engine,Engine.Operation> seqNoForOperation) throws java.io.IOException
- Throws:
java.io.IOException
-
createEngine
protected InternalEngine createEngine(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy) throws java.io.IOException
- Throws:
java.io.IOException
-
createEngine
protected InternalEngine createEngine(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, @Nullable EngineTestCase.IndexWriterFactory indexWriterFactory) throws java.io.IOException
- Throws:
java.io.IOException
-
createEngine
protected InternalEngine createEngine(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, @Nullable EngineTestCase.IndexWriterFactory indexWriterFactory, @Nullable java.util.function.BiFunction<java.lang.Long,java.lang.Long,LocalCheckpointTracker> localCheckpointTrackerSupplier, @Nullable java.util.function.LongSupplier globalCheckpointSupplier) throws java.io.IOException
- Throws:
java.io.IOException
-
createEngine
protected InternalEngine createEngine(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, @Nullable EngineTestCase.IndexWriterFactory indexWriterFactory, @Nullable java.util.function.BiFunction<java.lang.Long,java.lang.Long,LocalCheckpointTracker> localCheckpointTrackerSupplier, @Nullable java.util.function.LongSupplier globalCheckpointSupplier, @Nullable java.util.function.ToLongBiFunction<Engine,Engine.Operation> seqNoForOperation) throws java.io.IOException
- Throws:
java.io.IOException
-
createEngine
protected InternalEngine createEngine(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, @Nullable EngineTestCase.IndexWriterFactory indexWriterFactory, @Nullable java.util.function.BiFunction<java.lang.Long,java.lang.Long,LocalCheckpointTracker> localCheckpointTrackerSupplier, @Nullable java.util.function.ToLongBiFunction<Engine,Engine.Operation> seqNoForOperation, @Nullable Sort indexSort, @Nullable java.util.function.LongSupplier globalCheckpointSupplier) throws java.io.IOException
- Throws:
java.io.IOException
-
createEngine
protected InternalEngine createEngine(EngineConfig config) throws java.io.IOException
- Throws:
java.io.IOException
-
generateNewSeqNo
public static long generateNewSeqNo(Engine engine)
Generate a new sequence number and return it. Only works on InternalEngines
-
createInternalEngine
public static InternalEngine createInternalEngine(@Nullable EngineTestCase.IndexWriterFactory indexWriterFactory, @Nullable java.util.function.BiFunction<java.lang.Long,java.lang.Long,LocalCheckpointTracker> localCheckpointTrackerSupplier, @Nullable java.util.function.ToLongBiFunction<Engine,Engine.Operation> seqNoForOperation, EngineConfig config)
-
config
public EngineConfig config(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, ReferenceManager.RefreshListener refreshListener)
-
config
public EngineConfig config(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, ReferenceManager.RefreshListener refreshListener, Sort indexSort, java.util.function.LongSupplier globalCheckpointSupplier)
-
config
public EngineConfig config(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, ReferenceManager.RefreshListener refreshListener, Sort indexSort, java.util.function.LongSupplier globalCheckpointSupplier, java.util.function.Supplier<RetentionLeases> retentionLeasesSupplier)
-
config
public EngineConfig config(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, ReferenceManager.RefreshListener externalRefreshListener, ReferenceManager.RefreshListener internalRefreshListener, Sort indexSort, @Nullable java.util.function.LongSupplier maybeGlobalCheckpointSupplier, CircuitBreakerService breakerService)
-
config
public EngineConfig config(IndexSettings indexSettings, Store store, java.nio.file.Path translogPath, MergePolicy mergePolicy, ReferenceManager.RefreshListener externalRefreshListener, ReferenceManager.RefreshListener internalRefreshListener, Sort indexSort, @Nullable java.util.function.LongSupplier maybeGlobalCheckpointSupplier, @Nullable java.util.function.Supplier<RetentionLeases> maybeRetentionLeasesSupplier, CircuitBreakerService breakerService)
-
bytesArray
protected static BytesArray bytesArray(java.lang.String string)
-
newUid
public static Term newUid(java.lang.String id)
-
newUid
public static Term newUid(ParsedDocument doc)
-
newGet
protected Engine.Get newGet(boolean realtime, ParsedDocument doc)
-
indexForDoc
protected Engine.Index indexForDoc(ParsedDocument doc)
-
replicaIndexForDoc
protected Engine.Index replicaIndexForDoc(ParsedDocument doc, long version, long seqNo, boolean isRetry)
-
replicaDeleteForDoc
protected Engine.Delete replicaDeleteForDoc(java.lang.String id, long version, long seqNo, long startTime)
-
assertVisibleCount
protected static void assertVisibleCount(InternalEngine engine, int numDocs) throws java.io.IOException
- Throws:
java.io.IOException
-
assertVisibleCount
protected static void assertVisibleCount(InternalEngine engine, int numDocs, boolean refresh) throws java.io.IOException
- Throws:
java.io.IOException
-
generateSingleDocHistory
public static java.util.List<Engine.Operation> generateSingleDocHistory(boolean forReplica, VersionType versionType, boolean partialOldPrimary, long primaryTerm, int minOpCount, int maxOpCount, java.lang.String docId)
-
generateHistoryOnReplica
public java.util.List<Engine.Operation> generateHistoryOnReplica(int numOps, boolean allowGapInSeqNo, boolean allowDuplicate, boolean includeNestedDocs) throws java.lang.Exception
- Throws:
java.lang.Exception
-
assertOpsOnReplica
public static void assertOpsOnReplica(java.util.List<Engine.Operation> ops, InternalEngine replicaEngine, boolean shuffleOps, org.apache.logging.log4j.Logger logger) throws java.io.IOException
- Throws:
java.io.IOException
-
concurrentlyApplyOps
public static void concurrentlyApplyOps(java.util.List<Engine.Operation> ops, InternalEngine engine) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
applyOperations
public static void applyOperations(Engine engine, java.util.List<Engine.Operation> operations) throws java.io.IOException
- Throws:
java.io.IOException
-
applyOperation
public static Engine.Result applyOperation(Engine engine, Engine.Operation operation) throws java.io.IOException
- Throws:
java.io.IOException
-
getDocIds
public static java.util.List<DocIdSeqNoAndTerm> getDocIds(Engine engine, boolean refresh) throws java.io.IOException
Gets a collection of tuples of docId, sequence number, and primary term of all live documents in the provided engine.- Throws:
java.io.IOException
-
readAllOperationsInLucene
public static java.util.List<Translog.Operation> readAllOperationsInLucene(Engine engine, MapperService mapper) throws java.io.IOException
Reads all engine operations that have been processed by the engine from Lucene index. The returned operations are sorted and de-duplicated, thus each sequence number will be have at most one operation.- Throws:
java.io.IOException
-
assertConsistentHistoryBetweenTranslogAndLuceneIndex
public static void assertConsistentHistoryBetweenTranslogAndLuceneIndex(Engine engine, MapperService mapper) throws java.io.IOException
Asserts the provided engine has a consistent document history between translog and Lucene index.- Throws:
java.io.IOException
-
assertMaxSeqNoInCommitUserData
public static void assertMaxSeqNoInCommitUserData(Engine engine) throws java.lang.Exception
Asserts that the max_seq_no stored in the commit's user_data is never smaller than seq_no of any document in the commit.- Throws:
java.lang.Exception
-
createMapperService
public static MapperService createMapperService(java.lang.String type) throws java.io.IOException
- Throws:
java.io.IOException
-
getTranslog
public static Translog getTranslog(Engine engine)
Exposes a translog associated with the given engine for testing purpose.
-
waitForOpsToComplete
public static void waitForOpsToComplete(InternalEngine engine, long seqNo) throws java.lang.InterruptedException
Waits for all operations up to the provided sequence number to complete in the given internal engine.- Parameters:
seqNo
- the sequence number that the checkpoint must advance to before this method returns- Throws:
java.lang.InterruptedException
- if the thread was interrupted while blocking on the condition
-
hasSnapshottedCommits
public static boolean hasSnapshottedCommits(Engine engine)
-
-