Class EngineTestCase


  • public abstract class EngineTestCase
    extends ESTestCase
    • Field Detail

      • shardId

        protected final ShardId shardId
      • INDEX_SETTINGS

        protected static final IndexSettings INDEX_SETTINGS
      • store

        protected Store store
      • storeReplica

        protected Store storeReplica
      • codecName

        protected java.lang.String codecName
      • primaryTranslogDir

        protected java.nio.file.Path primaryTranslogDir
      • replicaTranslogDir

        protected java.nio.file.Path replicaTranslogDir
      • primaryTerm

        protected java.util.concurrent.atomic.AtomicLong primaryTerm
      • SOURCE

        protected static final BytesArray SOURCE
    • Constructor Detail

      • EngineTestCase

        public EngineTestCase()
    • 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 class org.apache.lucene.util.LuceneTestCase
        Throws:
        java.lang.Exception
      • tearDown

        public void tearDown()
                      throws java.lang.Exception
        Overrides:
        tearDown in class org.apache.lucene.util.LuceneTestCase
        Throws:
        java.lang.Exception
      • testDocumentWithTextField

        protected static ParseContext.Document testDocumentWithTextField​(java.lang.String value)
      • 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)
      • 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
      • 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​(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
      • bytesArray

        protected static BytesArray bytesArray​(java.lang.String string)
      • newUid

        public static Term newUid​(java.lang.String id)
      • 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
      • 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
      • 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.