public abstract class IndexShardTestCase extends ESTestCase
IndexShard
instances easily,
containing utilities for shard creation and recoveries. See {newShard(boolean)
} and
newStartedShard()
for a good starting pointsESTestCase.GeohashGenerator, ESTestCase.TestAnalysis
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
Modifier and Type | Field and Description |
---|---|
protected static PeerRecoveryTargetService.RecoveryListener |
recoveryListener |
protected ThreadPool |
threadPool |
checkIndexFailed, deprecationLogger, failureAndSuccessEvents, logger
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_CODEC, TEST_DIRECTORY, TEST_DOCVALUESFORMAT, TEST_LINE_DOCS_FILE, TEST_NIGHTLY, TEST_POSTINGSFORMAT, TEST_SLOW, TEST_THROTTLING, TEST_WEEKLY, VERBOSE
Constructor and Description |
---|
IndexShardTestCase() |
Modifier and Type | Method and Description |
---|---|
protected void |
assertDocCount(IndexShard shard,
int docDount) |
protected void |
assertDocs(IndexShard shard,
Uid... uids) |
protected void |
closeShards(IndexShard... shards) |
protected void |
closeShards(java.lang.Iterable<IndexShard> shards) |
protected Engine.Delete |
deleteDoc(IndexShard shard,
java.lang.String type,
java.lang.String id) |
protected void |
flushShard(IndexShard shard) |
protected void |
flushShard(IndexShard shard,
boolean force) |
protected java.util.Set<Uid> |
getShardDocUIDs(IndexShard shard) |
protected Engine.Index |
indexDoc(IndexShard shard,
java.lang.String type,
java.lang.String id) |
protected Engine.Index |
indexDoc(IndexShard shard,
java.lang.String type,
java.lang.String id,
java.lang.String source) |
protected Engine.Index |
indexDoc(IndexShard shard,
java.lang.String type,
java.lang.String id,
java.lang.String source,
XContentType xContentType) |
protected IndexShard |
newShard(boolean primary)
creates a new initializing shard.
|
protected IndexShard |
newShard(ShardId shardId,
boolean primary,
IndexingOperationListener... listeners)
creates a new initializing shard.
|
protected IndexShard |
newShard(ShardId shardId,
boolean primary,
java.lang.String nodeId,
IndexMetaData indexMetaData,
IndexSearcherWrapper searcherWrapper)
creates a new initializing shard.
|
protected IndexShard |
newShard(ShardRouting shardRouting,
IndexingOperationListener... listeners)
creates a new initializing shard.
|
protected IndexShard |
newShard(ShardRouting routing,
IndexMetaData indexMetaData,
IndexingOperationListener... listeners)
creates a new initializing shard.
|
protected IndexShard |
newShard(ShardRouting routing,
IndexMetaData indexMetaData,
IndexSearcherWrapper indexSearcherWrapper,
IndexingOperationListener... listeners)
creates a new initializing shard.
|
protected IndexShard |
newShard(ShardRouting routing,
ShardPath shardPath,
IndexMetaData indexMetaData,
IndexSearcherWrapper indexSearcherWrapper,
IndexingOperationListener... listeners)
creates a new initializing shard.
|
protected IndexShard |
newStartedShard()
creates a new empyu shard and starts it.
|
protected IndexShard |
newStartedShard(boolean primary)
creates a new empty shard and starts it.
|
protected void |
recoverReplica(IndexShard replica,
IndexShard primary)
recovers a replica from the given primary
|
protected void |
recoverReplica(IndexShard replica,
IndexShard primary,
java.util.function.BiFunction<IndexShard,DiscoveryNode,RecoveryTarget> targetSupplier,
boolean markAsRecovering)
Recovers a replica from the give primary, allow the user to supply a custom recovery target.
|
protected void |
recoveryEmptyReplica(IndexShard replica) |
protected void |
recoveryShardFromStore(IndexShard primary) |
protected IndexShard |
reinitShard(IndexShard current,
IndexingOperationListener... listeners)
Takes an existing shard, closes it and and starts a new initialing shard at the same location
|
protected IndexShard |
reinitShard(IndexShard current,
ShardRouting routing,
IndexingOperationListener... listeners)
Takes an existing shard, closes it and and starts a new initialing shard at the same location
|
void |
setUp() |
void |
tearDown() |
after, afterIfFailed, afterIfSuccessful, assertAllIndicesRemovedAndDeletionCompleted, assertArrayEquals, assertBusy, assertBusy, assertEquals, assertPathHasBeenCleared, assertSettingDeprecationsAndWarnings, assertWarnings, awaitBusy, awaitBusy, before, between, checkStaticState, copyWriteable, createParser, createParser, createParser, createParser, createParser, createTestAnalysis, createTestAnalysis, createTestAnalysis, enableWarningsCheck, ensureAllSearchContextsReleased, ensureCheckIndexPassed, frequently, generateRandomStringArray, generateRandomStringArray, getBwcIndicesPath, getDataPath, getSuiteFailureMarker, iterations, maybeSet, mockScript, newNodeEnvironment, newNodeEnvironment, newTestIndicesModule, newTestScriptModule, randomAlphaOfLength, randomAlphaOfLengthBetween, randomBoolean, randomByte, randomDateTimeZone, randomDouble, randomDoubleBetween, randomFloat, randomFrom, randomFrom, randomFrom, randomFrom, randomFrom, randomGeohash, randomInt, randomInt, randomIntBetween, randomLong, randomNonNegativeLong, randomPositiveTimeValue, randomRealisticUnicodeOfCodepointLength, randomRealisticUnicodeOfCodepointLengthBetween, randomRealisticUnicodeOfLength, randomRealisticUnicodeOfLengthBetween, randomShort, randomSubsetOf, randomSubsetOf, randomSubsetOf, randomTimeValue, randomTimeValue, randomTimeValue, randomUnicodeOfCodepointLength, randomUnicodeOfCodepointLengthBetween, randomUnicodeOfLength, randomUnicodeOfLengthBetween, randomUnique, randomValueOtherThan, randomValueOtherThanMany, resetCheckIndexStatus, restoreContentType, restoreFileSystem, scaledRandomIntBetween, setContentType, setFileSystem, settings, shuffleMap, shuffleXContent, shuffleXContent, spinForAtLeastNMilliseconds, spinForAtLeastOneMillisecond, terminate, terminate, tmpPaths, toShuffledXContent, xContentRegistry
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, 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, 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
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
protected static final PeerRecoveryTargetService.RecoveryListener recoveryListener
protected ThreadPool threadPool
public void setUp() throws java.lang.Exception
setUp
in class org.apache.lucene.util.LuceneTestCase
java.lang.Exception
public void tearDown() throws java.lang.Exception
tearDown
in class org.apache.lucene.util.LuceneTestCase
java.lang.Exception
protected IndexShard newShard(boolean primary) throws java.io.IOException
primary
- indicates whether to a primary shard (ready to recover from an empty store) or a replica
(ready to recover from another shard)java.io.IOException
protected IndexShard newShard(ShardRouting shardRouting, IndexingOperationListener... listeners) throws java.io.IOException
shardRouting
- the ShardRouting
to use for this shardlisteners
- an optional set of listeners to add to the shardjava.io.IOException
protected IndexShard newShard(ShardId shardId, boolean primary, IndexingOperationListener... listeners) throws java.io.IOException
shardId
- the shard id to useprimary
- indicates whether to a primary shard (ready to recover from an empty store) or a replica
(ready to recover from another shard)listeners
- an optional set of listeners to add to the shardjava.io.IOException
protected IndexShard newShard(ShardId shardId, boolean primary, java.lang.String nodeId, IndexMetaData indexMetaData, @Nullable IndexSearcherWrapper searcherWrapper) throws java.io.IOException
shardId
- the shard id to useprimary
- indicates whether to a primary shard (ready to recover from an empty store) or a replica
(ready to recover from another shard)java.io.IOException
protected IndexShard newShard(ShardRouting routing, IndexMetaData indexMetaData, IndexingOperationListener... listeners) throws java.io.IOException
routing
- shard routing to useindexMetaData
- indexMetaData for the shard, including any mappinglisteners
- an optional set of listeners to add to the shardjava.io.IOException
protected IndexShard newShard(ShardRouting routing, IndexMetaData indexMetaData, @Nullable IndexSearcherWrapper indexSearcherWrapper, IndexingOperationListener... listeners) throws java.io.IOException
routing
- shard routing to useindexMetaData
- indexMetaData for the shard, including any mappingindexSearcherWrapper
- an optional wrapper to be used during searcherslisteners
- an optional set of listeners to add to the shardjava.io.IOException
protected IndexShard newShard(ShardRouting routing, ShardPath shardPath, IndexMetaData indexMetaData, @Nullable IndexSearcherWrapper indexSearcherWrapper, IndexingOperationListener... listeners) throws java.io.IOException
routing
- shard routing to useshardPath
- path to use for shard dataindexMetaData
- indexMetaData for the shard, including any mappingindexSearcherWrapper
- an optional wrapper to be used during searcherslisteners
- an optional set of listeners to add to the shardjava.io.IOException
protected IndexShard reinitShard(IndexShard current, IndexingOperationListener... listeners) throws java.io.IOException
listeners
- new listerns to use for the newly created shardjava.io.IOException
protected IndexShard reinitShard(IndexShard current, ShardRouting routing, IndexingOperationListener... listeners) throws java.io.IOException
routing
- the shard routing to use for the newly created shard.listeners
- new listerns to use for the newly created shardjava.io.IOException
protected IndexShard newStartedShard() throws java.io.IOException
java.io.IOException
protected IndexShard newStartedShard(boolean primary) throws java.io.IOException
primary
- controls whether the shard will be a primary or a replica.java.io.IOException
protected void closeShards(IndexShard... shards) throws java.io.IOException
java.io.IOException
protected void closeShards(java.lang.Iterable<IndexShard> shards) throws java.io.IOException
java.io.IOException
protected void recoveryShardFromStore(IndexShard primary) throws java.io.IOException
java.io.IOException
protected void recoveryEmptyReplica(IndexShard replica) throws java.io.IOException
java.io.IOException
protected void recoverReplica(IndexShard replica, IndexShard primary) throws java.io.IOException
java.io.IOException
protected void recoverReplica(IndexShard replica, IndexShard primary, java.util.function.BiFunction<IndexShard,DiscoveryNode,RecoveryTarget> targetSupplier, boolean markAsRecovering) throws java.io.IOException
markAsRecovering
- set to false if you have already marked the replica as recoveringjava.io.IOException
protected java.util.Set<Uid> getShardDocUIDs(IndexShard shard) throws java.io.IOException
java.io.IOException
protected void assertDocCount(IndexShard shard, int docDount) throws java.io.IOException
java.io.IOException
protected void assertDocs(IndexShard shard, Uid... uids) throws java.io.IOException
java.io.IOException
protected Engine.Index indexDoc(IndexShard shard, java.lang.String type, java.lang.String id) throws java.io.IOException
java.io.IOException
protected Engine.Index indexDoc(IndexShard shard, java.lang.String type, java.lang.String id, java.lang.String source) throws java.io.IOException
java.io.IOException
protected Engine.Index indexDoc(IndexShard shard, java.lang.String type, java.lang.String id, java.lang.String source, XContentType xContentType) throws java.io.IOException
java.io.IOException
protected Engine.Delete deleteDoc(IndexShard shard, java.lang.String type, java.lang.String id) throws java.io.IOException
java.io.IOException
protected void flushShard(IndexShard shard)
protected void flushShard(IndexShard shard, boolean force)