Class ESTestCase

java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.LuceneTestCase
org.elasticsearch.test.ESTestCase
Direct Known Subclasses:
AbstractAsyncBulkByScrollActionTestCase, AbstractBlobContainerRetriesTestCase, AbstractBootstrapCheckTestCase, AbstractBuilderTestCase, AbstractBytesReferenceTestCase, AbstractCoordinatorTestCase, AbstractFilteringTestCase, AbstractHttpServerTransportTestCase, AbstractMultiClustersTestCase, AbstractSignificanceHeuristicTestCase, AbstractSimpleTransportTestCase, AbstractWireTestCase, AbstractXContentTestCase, AggregatorTestCase, AnalysisFactoryTestCase, BasePipelineAggregationTestCase, CommandTestCase, EngineTestCase, ESAllocationTestCase, ESIndexInputTestCase, ESIntegTestCase, ESRestTestCase, ESSingleNodeTestCase, FieldTypeTestCase, IndexShardTestCase, MapperServiceTestCase, ModuleTestCase, RestActionTestCase, RestClientBuilderTestCase

@Listeners({ReproduceInfoPrinter.class,LoggingListener.class}) @SuppressSysoutChecks(bugUrl="we log a lot on purpose") @SuppressCodecs({"SimpleText","Memory","CheapBastard","Direct","Compressing","FST50","FSTOrd50","TestBloomFilteredLucenePostings","MockRandom","BlockTreeOrds","LuceneFixedGap","LuceneVarGapFixedInterval","LuceneVarGapDocFreqInterval","Lucene50"}) @SuppressReproduceLine public abstract class ESTestCase extends org.apache.lucene.tests.util.LuceneTestCase
Base testcase for randomized unit testing with Elasticsearch
  • Field Details

    • JAVA_TIMEZONE_IDS

      protected static final List<String> JAVA_TIMEZONE_IDS
    • JAVA_ZONE_IDS

      protected static final List<String> JAVA_ZONE_IDS
    • TEST_WORKER_VM_ID

      public static final String TEST_WORKER_VM_ID
    • TEST_WORKER_SYS_PROPERTY

      public static final String TEST_WORKER_SYS_PROPERTY
      See Also:
    • DEFAULT_TEST_WORKER_ID

      public static final String DEFAULT_TEST_WORKER_ID
      See Also:
    • FIPS_SYSPROP

      public static final String FIPS_SYSPROP
      See Also:
    • logger

      protected final org.apache.logging.log4j.Logger logger
    • failureAndSuccessEvents

      public org.junit.rules.RuleChain failureAndSuccessEvents
    • checkIndexFailures

      public static final List<Exception> checkIndexFailures
      MockFSDirectoryService sets this:
    • MIN_PRIVATE_PORT

      protected static final int MIN_PRIVATE_PORT
      Defines the minimum port that test workers should use. See also [NOTE: Port ranges for tests].
      See Also:
  • Constructor Details

    • ESTestCase

      public ESTestCase()
  • Method Details

    • resetPortCounter

      public static void resetPortCounter()
    • buildNewFakeTransportAddress

      public static TransportAddress buildNewFakeTransportAddress()
      Generates a new transport address using TransportAddress.META_ADDRESS with an incrementing port number. The port number starts at 0 and is reset after each test suite run.
    • afterIfFailed

      protected void afterIfFailed(List<Throwable> errors)
      Called when a test fails, supplying the errors it generated. Not called when the test fails because assumptions are violated.
    • afterIfSuccessful

      protected void afterIfSuccessful() throws Exception
      called after a test is finished, but only if successful
      Throws:
      Exception
    • maybeStashClassSecurityManager

      public static void maybeStashClassSecurityManager()
    • maybeRestoreClassSecurityManager

      public static void maybeRestoreClassSecurityManager() throws IOException
      Throws:
      IOException
    • setFileSystem

      public static void setFileSystem() throws Exception
      Throws:
      Exception
    • restoreFileSystem

      public static void restoreFileSystem() throws Exception
      Throws:
      Exception
    • setContentType

      public static void setContentType() throws Exception
      Throws:
      Exception
    • restoreContentType

      public static void restoreContentType()
    • ensureSupportedLocale

      public static void ensureSupportedLocale()
    • setHeaderWarningAppender

      public void setHeaderWarningAppender()
    • removeHeaderWarningAppender

      public void removeHeaderWarningAppender()
    • before

      public final void before()
    • enableWarningsCheck

      protected boolean enableWarningsCheck()
      Whether or not we check after each test whether it has left warnings behind. That happens if any deprecated feature or syntax was used by the test and the test didn't assert on it using assertWarnings(String...).
    • after

      public final void after() throws Exception
      Throws:
      Exception
    • ensureNoWarnings

      public void ensureNoWarnings()
    • filteredWarnings

      protected List<String> filteredWarnings()
    • assertSettingDeprecationsAndWarnings

      protected final void assertSettingDeprecationsAndWarnings(Setting<?>[] settings, ESTestCase.DeprecationWarning... warnings)
      Convenience method to assert warnings for settings deprecations and general deprecation warnings.
      Parameters:
      settings - the settings that are expected to be deprecated
      warnings - other expected general deprecation warnings
    • assertWarnings

      protected final void assertWarnings(String... expectedWarnings)
      Convenience method to assert warnings for settings deprecations and general deprecation warnings. All warnings passed to this method are assumed to be at WARNING level.
      Parameters:
      expectedWarnings - expected general deprecation warnings.
    • assertCriticalWarnings

      protected final void assertCriticalWarnings(String... expectedWarnings)
      Convenience method to assert warnings for settings deprecations and general deprecation warnings. All warnings passed to this method are assumed to be at CRITICAL level.
      Parameters:
      expectedWarnings - expected general deprecation warnings.
    • assertWarnings

      protected final void assertWarnings(boolean stripXContentPosition, ESTestCase.DeprecationWarning... expectedWarnings)
    • checkStaticState

      protected static void checkStaticState() throws Exception
      Throws:
      Exception
    • ensureAllSearchContextsReleased

      public final void ensureAllSearchContextsReleased() throws Exception
      Throws:
      Exception
    • resetCheckIndexStatus

      public final void resetCheckIndexStatus() throws Exception
      Throws:
      Exception
    • ensureCheckIndexPassed

      public final void ensureCheckIndexPassed()
    • scaledRandomIntBetween

      public static int scaledRandomIntBetween(int min, int max)
      Returns a "scaled" random number between min and max (inclusive).
      See Also:
      • RandomizedTest.scaledRandomIntBetween(int, int)
    • randomIntBetween

      public static int randomIntBetween(int min, int max)
      A random integer from min to max (inclusive).
      See Also:
    • randomLongBetween

      public static long randomLongBetween(long min, long max)
      A random long number between min (inclusive) and max (inclusive).
    • iterations

      public static int iterations(int min, int max)
      Returns a "scaled" number of iterations for loops which can have a variable iteration count. This method is effectively an alias to scaledRandomIntBetween(int, int).
    • between

      public static int between(int min, int max)
      See Also:
    • frequently

      public static boolean frequently()
      The exact opposite of LuceneTestCase.rarely().
    • randomBoolean

      public static boolean randomBoolean()
    • randomByte

      public static byte randomByte()
    • randomNonNegativeByte

      public static byte randomNonNegativeByte()
    • randomByteArrayOfLength

      public static byte[] randomByteArrayOfLength(int size)
      Helper method to create a byte array of a given length populated with random byte values
      See Also:
    • randomBytesReference

      public static BytesReference randomBytesReference(int length)
    • randomShort

      public static short randomShort()
    • randomInt

      public static int randomInt()
    • randomInts

      public static IntStream randomInts()
    • randomInts

      public static IntStream randomInts(long streamSize)
    • randomNonNegativeLong

      public static long randomNonNegativeLong()
      Returns:
      a long between 0 and Long.MAX_VALUE (inclusive) chosen uniformly at random.
    • randomNonNegativeInt

      public static int randomNonNegativeInt()
      Returns:
      an int between 0 and Integer.MAX_VALUE (inclusive) chosen uniformly at random.
    • randomFloat

      public static float randomFloat()
    • randomDouble

      public static double randomDouble()
    • randomDoubles

      public static DoubleStream randomDoubles()
    • randomDoubles

      public static DoubleStream randomDoubles(long streamSize)
    • randomDoubleBetween

      public static double randomDoubleBetween(double start, double end, boolean lowerInclusive)
      Returns a double value in the interval [start, end) if lowerInclusive is set to true, (start, end) otherwise.
      Parameters:
      start - lower bound of interval to draw uniformly distributed random numbers from
      end - upper bound
      lowerInclusive - whether or not to include lower end of the interval
    • randomLong

      public static long randomLong()
    • randomLongs

      public static LongStream randomLongs()
    • randomLongs

      public static LongStream randomLongs(long streamSize)
    • randomBigInteger

      public static BigInteger randomBigInteger()
      Returns a random BigInteger uniformly distributed over the range 0 to (2^64 - 1) inclusive Currently BigIntegers are only used for unsigned_long field type, where the max value is 2^64 - 1. Modify this random generator if a wider range for BigIntegers is necessary.
      Returns:
      a random bigInteger in the range [0 ; 2^64 - 1]
    • randomInt

      public static int randomInt(int max)
      A random integer from 0..max (inclusive).
    • randomByteSizeValue

      public static ByteSizeValue randomByteSizeValue()
      A random byte size value.
    • randomFrom

      @SafeVarargs public static <T> T randomFrom(T... array)
      Pick a random object from the given array. The array must not be empty.
    • randomFrom

      @SafeVarargs public static <T> T randomFrom(Random random, T... array)
      Pick a random object from the given array. The array must not be empty.
    • randomFrom

      @SafeVarargs public static <T> T randomFrom(Random random, Supplier<T>... array)
      Pick a random object from the given array of suppliers. The array must not be empty.
    • randomFrom

      public static <T> T randomFrom(List<T> list)
      Pick a random object from the given list.
    • randomFrom

      public static <T> T randomFrom(Collection<T> collection)
      Pick a random object from the given collection.
    • randomFrom

      public static <T> T randomFrom(Random random, Collection<T> collection)
      Pick a random object from the given collection.
    • randomAlphaOfLengthBetween

      public static String randomAlphaOfLengthBetween(int minCodeUnits, int maxCodeUnits)
    • randomAlphaOfLength

      public static String randomAlphaOfLength(int codeUnits)
    • randomIdentifier

      public static String randomIdentifier()
      Creates a valid random identifier such as node id or index name
    • randomUnicodeOfLengthBetween

      public static String randomUnicodeOfLengthBetween(int minCodeUnits, int maxCodeUnits)
    • randomUnicodeOfLength

      public static String randomUnicodeOfLength(int codeUnits)
    • randomUnicodeOfCodepointLengthBetween

      public static String randomUnicodeOfCodepointLengthBetween(int minCodePoints, int maxCodePoints)
    • randomUnicodeOfCodepointLength

      public static String randomUnicodeOfCodepointLength(int codePoints)
    • randomRealisticUnicodeOfLengthBetween

      public static String randomRealisticUnicodeOfLengthBetween(int minCodeUnits, int maxCodeUnits)
    • randomRealisticUnicodeOfLength

      public static String randomRealisticUnicodeOfLength(int codeUnits)
    • randomRealisticUnicodeOfCodepointLengthBetween

      public static String randomRealisticUnicodeOfCodepointLengthBetween(int minCodePoints, int maxCodePoints)
    • randomRealisticUnicodeOfCodepointLength

      public static String randomRealisticUnicodeOfCodepointLength(int codePoints)
    • generateRandomStringArray

      public static String[] generateRandomStringArray(int maxArraySize, int stringSize, boolean allowNull, boolean allowEmpty)
      Parameters:
      maxArraySize - The maximum number of elements in the random array
      stringSize - The length of each String in the array
      allowNull - Whether the returned array may be null
      allowEmpty - Whether the returned array may be empty (have zero elements)
    • generateRandomStringArray

      public static String[] generateRandomStringArray(int maxArraySize, int stringSize, boolean allowNull)
    • randomArray

      public static <T> T[] randomArray(int maxArraySize, IntFunction<T[]> arrayConstructor, Supplier<T> valueConstructor)
    • randomArray

      public static <T> T[] randomArray(int minArraySize, int maxArraySize, IntFunction<T[]> arrayConstructor, Supplier<T> valueConstructor)
    • randomList

      public static <T> List<T> randomList(int maxListSize, Supplier<T> valueConstructor)
    • randomList

      public static <T> List<T> randomList(int minListSize, int maxListSize, Supplier<T> valueConstructor)
    • randomMap

      public static <K, V> Map<K,V> randomMap(int minMapSize, int maxMapSize, Supplier<org.elasticsearch.core.Tuple<K,V>> entryConstructor)
    • randomSet

      public static <T> Set<T> randomSet(int minSetSize, int maxSetSize, Supplier<T> valueConstructor)
    • randomTimeValue

      public static String randomTimeValue(int lower, int upper, String... suffixes)
    • randomTimeValue

      public static String randomTimeValue(int lower, int upper)
    • randomTimeValue

      public static String randomTimeValue()
    • randomPositiveTimeValue

      public static String randomPositiveTimeValue()
    • randomMillisUpToYear9999

      public static long randomMillisUpToYear9999()
      generate a random epoch millis in a range 1 to 9999-12-31T23:59:59.999
    • randomTimeZone

      public static TimeZone randomTimeZone()
      generate a random TimeZone from the ones available in java.util
    • randomZone

      public static ZoneId randomZone()
      generate a random TimeZone from the ones available in java.time
    • randomDateFormatterPattern

      public static String randomDateFormatterPattern()
      Generate a random valid date formatter pattern.
    • maybeSet

      public static <T> void maybeSet(Consumer<T> consumer, T value)
      helper to randomly perform on consumer with value
    • randomValueOtherThan

      public static <T> T randomValueOtherThan(T input, Supplier<T> randomSupplier)
      helper to get a random value in a certain range that's different from the input
    • randomValueOtherThanMany

      public static <T> T randomValueOtherThanMany(Predicate<T> input, Supplier<T> randomSupplier)
      helper to get a random value in a certain range that's different from the input
    • assertBusy

      public static void assertBusy(org.elasticsearch.core.CheckedRunnable<Exception> codeBlock) throws Exception
      Runs the code block for 10 seconds waiting for no assertion to trip.
      Throws:
      Exception
    • assertBusy

      public static void assertBusy(org.elasticsearch.core.CheckedRunnable<Exception> codeBlock, long maxWaitTime, TimeUnit unit) throws Exception
      Runs the code block for the provided interval, waiting for no assertions to trip.
      Throws:
      Exception
    • waitUntil

      public static boolean waitUntil(BooleanSupplier breakSupplier) throws InterruptedException
      Periodically execute the supplied function until it returns true, or a timeout is reached. This version uses a timeout of 10 seconds. If at all possible, use assertBusy(CheckedRunnable) instead.
      Parameters:
      breakSupplier - determines whether to return immediately or continue waiting.
      Returns:
      the last value returned by breakSupplier
      Throws:
      InterruptedException - if any sleep calls were interrupted.
    • waitUntil

      public static boolean waitUntil(BooleanSupplier breakSupplier, long maxWaitTime, TimeUnit unit) throws InterruptedException
      Periodically execute the supplied function until it returns true, or until the specified maximum wait time has elapsed. If at all possible, use assertBusy(CheckedRunnable) instead.
      Parameters:
      breakSupplier - determines whether to return immediately or continue waiting.
      maxWaitTime - the maximum amount of time to wait
      unit - the unit of tie for maxWaitTime
      Returns:
      the last value returned by breakSupplier
      Throws:
      InterruptedException - if any sleep calls were interrupted.
    • terminate

      public static boolean terminate(ExecutorService... services)
    • terminate

      public static boolean terminate(ThreadPool threadPool)
    • getDataPath

      public Path getDataPath(String relativePath)
      Returns a Path pointing to the class path relative resource given as the first argument. In contrast to getClass().getResource(...).getFile() this method will not return URL encoded paths if the parent path contains spaces or other non-standard characters.
      Overrides:
      getDataPath in class org.apache.lucene.tests.util.LuceneTestCase
    • tmpPaths

      public String[] tmpPaths()
      Returns a random number of temporary paths.
    • newNodeEnvironment

      public NodeEnvironment newNodeEnvironment() throws IOException
      Throws:
      IOException
    • buildEnvSettings

      public Settings buildEnvSettings(Settings settings)
    • newNodeEnvironment

      public NodeEnvironment newNodeEnvironment(Settings settings) throws IOException
      Throws:
      IOException
    • newEnvironment

      public Environment newEnvironment()
    • newEnvironment

      public Environment newEnvironment(Settings settings)
    • settings

      public static Settings.Builder settings(IndexVersion version)
      Return consistent index settings for the provided index version.
    • indexSettings

      public static Settings.Builder indexSettings(IndexVersion indexVersionCreated, int shards, int replicas)
      Return consistent index settings for the provided index version, shard- and replica-count.
    • indexSettings

      public static Settings.Builder indexSettings(int shards, int replicas)
      Return consistent index settings for the provided shard- and replica-count.
    • randomSubsetOf

      @SafeVarargs public static <T> List<T> randomSubsetOf(int size, T... values)
      Returns size random values
    • randomSubsetOf

      public static <T> List<T> randomSubsetOf(Collection<T> collection)
      Returns a random subset of values (including a potential empty list, or the full original list)
    • randomNonEmptySubsetOf

      public static <T> List<T> randomNonEmptySubsetOf(Collection<T> collection)
    • randomSubsetOf

      public static <T> List<T> randomSubsetOf(int size, Collection<T> collection)
      Returns size random values
    • shuffledList

      public static <T> List<T> shuffledList(List<T> list)
    • randomUnique

      public static <T> Set<T> randomUnique(Supplier<T> supplier, int targetCount)
      Builds a set of unique items. Usually you'll get the requested count but you might get less than that number if the supplier returns lots of repeats. Make sure that the items properly implement equals and hashcode.
    • randomGeohash

      public static String randomGeohash(int minPrecision, int maxPrecision)
    • getTestTransportType

      public static String getTestTransportType()
    • getTestTransportPlugin

      public static Class<? extends Plugin> getTestTransportPlugin()
    • randomCompatibleMediaType

      public String randomCompatibleMediaType(org.elasticsearch.core.RestApiVersion version)
    • compatibleMediaType

      public String compatibleMediaType(org.elasticsearch.xcontent.XContentType type, org.elasticsearch.core.RestApiVersion version)
    • randomVendorType

      public org.elasticsearch.xcontent.XContentType randomVendorType()
    • toShuffledXContent

      protected final BytesReference toShuffledXContent(org.elasticsearch.xcontent.ToXContent toXContent, org.elasticsearch.xcontent.XContentType xContentType, org.elasticsearch.xcontent.ToXContent.Params params, boolean humanReadable, String... exceptFieldNames) throws IOException
      Returns the bytes that represent the XContent output of the provided ToXContent object, using the provided XContentType. Wraps the output into a new anonymous object according to the value returned by the ToXContent.isFragment() method returns. Shuffles the keys to make sure that parsing never relies on keys ordering.
      Throws:
      IOException
    • shuffleXContent

      protected final org.elasticsearch.xcontent.XContentBuilder shuffleXContent(org.elasticsearch.xcontent.XContentBuilder builder, String... exceptFieldNames) throws IOException
      Randomly shuffles the fields inside objects in the XContentBuilder passed in. Recursively goes through inner objects and also shuffles them. Exceptions for this recursive shuffling behavior can be made by passing in the names of fields which internally should stay untouched.
      Throws:
      IOException
    • shuffleXContent

      public static org.elasticsearch.xcontent.XContentBuilder shuffleXContent(org.elasticsearch.xcontent.XContentParser parser, boolean prettyPrint, String... exceptFieldNames) throws IOException
      Randomly shuffles the fields inside objects parsed using the XContentParser passed in. Recursively goes through inner objects and also shuffles them. Exceptions for this recursive shuffling behavior can be made by passing in the names of fields which internally should stay untouched.
      Throws:
      IOException
    • shuffleMap

      public static LinkedHashMap<String,Object> shuffleMap(LinkedHashMap<String,Object> map, Set<String> exceptFields)
    • copyWriteable

      public static <T extends Writeable> T copyWriteable(T original, NamedWriteableRegistry namedWriteableRegistry, Writeable.Reader<T> reader) throws IOException
      Create a copy of an original Writeable object by running it through a BytesStreamOutput and reading it in again using a provided Writeable.Reader. The stream that is wrapped around the StreamInput potentially need to use a NamedWriteableRegistry, so this needs to be provided too (although it can be empty if the object that is streamed doesn't contain any NamedWriteable objects itself.
      Throws:
      IOException
    • copyWriteable

      public static <T extends Writeable> T copyWriteable(T original, NamedWriteableRegistry namedWriteableRegistry, Writeable.Reader<T> reader, TransportVersion version) throws IOException
      Same as copyWriteable(Writeable, NamedWriteableRegistry, Writeable.Reader) but also allows to provide a TransportVersion argument which will be used to write and read back the object.
      Throws:
      IOException
    • copyNamedWriteable

      public static <C extends NamedWriteable, T extends C> C copyNamedWriteable(T original, NamedWriteableRegistry namedWriteableRegistry, Class<C> categoryClass) throws IOException
      Create a copy of an original NamedWriteable object by running it through a BytesStreamOutput and reading it in again using a provided Writeable.Reader.
      Throws:
      IOException
    • copyNamedWriteable

      public static <C extends NamedWriteable, T extends C> C copyNamedWriteable(T original, NamedWriteableRegistry namedWriteableRegistry, Class<C> categoryClass, TransportVersion version) throws IOException
      Same as copyNamedWriteable(NamedWriteable, NamedWriteableRegistry, Class) but also allows to provide a TransportVersion argument which will be used to write and read back the object.
      Returns:
      Throws:
      IOException
    • copyInstance

      protected static <T> T copyInstance(T original, NamedWriteableRegistry namedWriteableRegistry, Writeable.Writer<T> writer, Writeable.Reader<T> reader, TransportVersion version) throws IOException
      Throws:
      IOException
    • parserConfig

      protected final org.elasticsearch.xcontent.XContentParserConfiguration parserConfig()
    • createParser

      protected final org.elasticsearch.xcontent.XContentParser createParser(org.elasticsearch.xcontent.XContentBuilder builder) throws IOException
      Create a new XContentParser.
      Throws:
      IOException
    • createParser

      protected final org.elasticsearch.xcontent.XContentParser createParser(org.elasticsearch.xcontent.XContent xContent, String data) throws IOException
      Create a new XContentParser.
      Throws:
      IOException
    • createParser

      protected final org.elasticsearch.xcontent.XContentParser createParser(org.elasticsearch.xcontent.XContent xContent, InputStream data) throws IOException
      Create a new XContentParser.
      Throws:
      IOException
    • createParser

      protected final org.elasticsearch.xcontent.XContentParser createParser(org.elasticsearch.xcontent.XContent xContent, byte[] data) throws IOException
      Create a new XContentParser.
      Throws:
      IOException
    • createParser

      protected final org.elasticsearch.xcontent.XContentParser createParser(org.elasticsearch.xcontent.XContent xContent, BytesReference data) throws IOException
      Create a new XContentParser.
      Throws:
      IOException
    • createParser

      protected final org.elasticsearch.xcontent.XContentParser createParser(org.elasticsearch.xcontent.XContentParserConfiguration config, org.elasticsearch.xcontent.XContent xContent, BytesReference data) throws IOException
      Create a new XContentParser.
      Throws:
      IOException
    • createParserWithCompatibilityFor

      protected final org.elasticsearch.xcontent.XContentParser createParserWithCompatibilityFor(org.elasticsearch.xcontent.XContent xContent, String data, org.elasticsearch.core.RestApiVersion restApiVersion) throws IOException
      Throws:
      IOException
    • xContentRegistry

      protected org.elasticsearch.xcontent.NamedXContentRegistry xContentRegistry()
      The NamedXContentRegistry to use for this test. Subclasses should override and use liberally.
    • writableRegistry

      protected NamedWriteableRegistry writableRegistry()
      The NamedWriteableRegistry to use for this test. Subclasses should override and use liberally.
    • mockScript

      public static Script mockScript(String id)
      Create a "mock" script for use either with MockScriptEngine or anywhere where you need a script but don't really care about its contents.
    • getSuiteFailureMarker

      public static org.apache.lucene.tests.util.TestRuleMarkFailure getSuiteFailureMarker()
      Returns the suite failure marker: internal use only!
    • assertArrayEquals

      public static void assertArrayEquals(StackTraceElement[] expected, StackTraceElement[] actual)
      Compares two stack traces, ignoring module (which is not yet serialized)
    • assertEquals

      public static void assertEquals(StackTraceElement expected, StackTraceElement actual)
      Compares two stack trace elements, ignoring module (which is not yet serialized)
    • spinForAtLeastOneMillisecond

      protected static long spinForAtLeastOneMillisecond()
    • spinForAtLeastNMilliseconds

      protected static long spinForAtLeastNMilliseconds(long ms)
    • createDefaultIndexAnalyzers

      protected IndexAnalyzers createDefaultIndexAnalyzers()
      Creates an IndexAnalyzers with a single default analyzer
    • createTestAnalysis

      public static ESTestCase.TestAnalysis createTestAnalysis(Index index, Settings settings, AnalysisPlugin... analysisPlugins) throws IOException
      Creates an TestAnalysis with all the default analyzers configured.
      Throws:
      IOException
    • createTestAnalysis

      public static ESTestCase.TestAnalysis createTestAnalysis(Index index, Settings nodeSettings, Settings settings, AnalysisPlugin... analysisPlugins) throws IOException
      Creates an TestAnalysis with all the default analyzers configured.
      Throws:
      IOException
    • createTestAnalysis

      public static ESTestCase.TestAnalysis createTestAnalysis(IndexSettings indexSettings, Settings nodeSettings, AnalysisPlugin... analysisPlugins) throws IOException
      Creates an TestAnalysis with all the default analyzers configured.
      Throws:
      IOException
    • inFipsJvm

      public static boolean inFipsJvm()
    • getPortRange

      public static String getPortRange()
      Returns a port range for this JVM according to its Gradle worker ID. See also [NOTE: Port ranges for tests].
    • getWorkerBasePort

      protected static int getWorkerBasePort()
      Returns the start of the port range for this JVM according to its Gradle worker ID. See also [NOTE: Port ranges for tests].
    • randomIp

      protected static InetAddress randomIp(boolean v4)
    • skipTestWaitingForLuceneFix

      protected void skipTestWaitingForLuceneFix(org.apache.lucene.util.Version luceneVersionWithFix, String message)
      Call method at the beginning of a test to disable its execution until a given Lucene version is released and integrated into Elasticsearch
      Parameters:
      luceneVersionWithFix - the lucene release to wait for
      message - an additional message or link with information on the fix
    • secureRandom

      public static SecureRandom secureRandom() throws NoSuchAlgorithmException, NoSuchProviderException
      In non-FIPS mode, get a deterministic SecureRandom SHA1PRNG/SUN instance seeded by deterministic LuceneTestCase.random(). In FIPS mode, get a non-deterministic SecureRandom DEFAULT/BCFIPS instance seeded by deterministic LuceneTestCase.random().
      Returns:
      SecureRandom SHA1PRNG instance.
      Throws:
      NoSuchAlgorithmException - SHA1PRNG or DEFAULT algorithm not found.
      NoSuchProviderException - BCFIPS algorithm not found.
    • secureRandom

      public static SecureRandom secureRandom(byte[] seed) throws NoSuchAlgorithmException, NoSuchProviderException
      In non-FIPS mode, get a deterministic SecureRandom SHA1PRNG/SUN instance seeded by the input value. In FIPS mode, get a non-deterministic SecureRandom DEFAULT/BCFIPS instance seeded by the input value.
      Parameters:
      seed - Byte array to use for seeding the SecureRandom instance.
      Returns:
      SecureRandom SHA1PRNG or DEFAULT/BCFIPS instance, depending on FIPS mode.
      Throws:
      NoSuchAlgorithmException - SHA1PRNG or DEFAULT algorithm not found.
      NoSuchProviderException - BCFIPS algorithm not found.
    • secureRandomNonFips

      protected static SecureRandom secureRandomNonFips() throws NoSuchAlgorithmException
      Returns deterministic non-FIPS SecureRandom SHA1PRNG/SUN instance seeded by deterministic LuceneTestCase.random().
      Returns:
      Deterministic non-FIPS SecureRandom SHA1PRNG/SUN instance seeded by deterministic LuceneTestCase.random().
      Throws:
      NoSuchAlgorithmException - Exception if SHA1PRNG algorithm not found, such as missing SUN provider (unlikely).
    • secureRandomFips

      protected static SecureRandom secureRandomFips() throws NoSuchAlgorithmException
      Returns non-deterministic FIPS SecureRandom DEFAULT/BCFIPS instance. Seeded.
      Returns:
      Non-deterministic FIPS SecureRandom DEFAULT/BCFIPS instance. Seeded.
      Throws:
      NoSuchAlgorithmException - Exception if DEFAULT algorithm not found, such as missing BCFIPS provider.
    • secureRandomNonFips

      protected static SecureRandom secureRandomNonFips(byte[] seed) throws NoSuchAlgorithmException
      Returns deterministic non-FIPS SecureRandom SHA1PRNG/SUN instance seeded by deterministic LuceneTestCase.random().
      Returns:
      Deterministic non-FIPS SecureRandom SHA1PRNG/SUN instance seeded by deterministic LuceneTestCase.random().
      Throws:
      NoSuchAlgorithmException - Exception if SHA1PRNG algorithm not found, such as missing SUN provider (unlikely).
    • secureRandomFips

      protected static SecureRandom secureRandomFips(byte[] seed) throws NoSuchAlgorithmException
      Returns non-deterministic FIPS SecureRandom DEFAULT/BCFIPS instance. Seeded.
      Returns:
      Non-deterministic FIPS SecureRandom DEFAULT/BCFIPS instance. Seeded.
      Throws:
      NoSuchAlgorithmException - Exception if DEFAULT algorithm not found, such as missing BCFIPS provider.
    • safeAwait

      public static void safeAwait(CyclicBarrier barrier)
    • safeAwait

      public static void safeAwait(CountDownLatch countDownLatch)
    • safeSleep

      public static void safeSleep(long millis)
    • isTurkishLocale

      protected static boolean isTurkishLocale()