Companion

object Companion

Types

Link copied to clipboard
annotation class AwaitsFix(val bugUrl: String = "")
Link copied to clipboard

What level of concurrency is supported by the searcher being created

Link copied to clipboard
@TestGroup(enabled = false, sysProperty = "tests.nightly")
annotation class Nightly

Annotation for tests that should only be run during nightly builds.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class SuppressCodecs(val value: String)

Properties

Link copied to clipboard

The default (embedded resource) lines file.

Link copied to clipboard

Enables or disables dumping of InfoStream messages.

Link copied to clipboard

Random sample from enwiki used in tests. See help/tests.txt. gradle task downloading this data set: gradlew getEnWikiRandomLines.

Link copied to clipboard

Leave temporary files on disk, even on successful runs.

Link copied to clipboard
Link copied to clipboard

A random multiplier which you should use when writing random tests: multiply it by the number of iterations to scale your tests (for nightly builds).

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Gets the codec to run tests with.

Link copied to clipboard

Gets the directory to run tests with

Link copied to clipboard

Gets the docValuesFormat to run tests with

Link copied to clipboard

The line file used in tests (by LineFileDocs).

Link copied to clipboard

Whether or not monster tests should run.

Link copied to clipboard

Whether or not Nightly tests should run.

Link copied to clipboard

Gets the postingsFormat to run tests with.

Link copied to clipboard

Whether or not Weekly tests should run.

Link copied to clipboard

True if and only if tests are run in verbose mode. If this flag is false tests are not expected to print any messages. Enforced with TestRuleLimitSysouts.

Functions

Link copied to clipboard
fun assertDeletedDocsEquals(info: String, leftReader: IndexReader, rightReader: IndexReader)
Link copied to clipboard
fun assertDocValuesEquals(info: String, leftReader: IndexReader, rightReader: IndexReader)

checks that docvalues across all fields are equivalent

fun assertDocValuesEquals(info: String, num: Int, leftDocValues: NumericDocValues, rightDocValues: NumericDocValues)
Link copied to clipboard
fun assertFieldInfosEquals(info: String, leftReader: IndexReader, rightReader: IndexReader)
Link copied to clipboard
fun assertNormsEquals(info: String, leftReader: IndexReader, rightReader: IndexReader)

checks that norms are the same across all fields

Link copied to clipboard
fun assertPointsEquals(info: String, leftReader: IndexReader, rightReader: IndexReader)
Link copied to clipboard
fun assertReaderEquals(info: String, leftReader: IndexReader, rightReader: IndexReader)
Link copied to clipboard
fun assertReaderStatisticsEquals(info: String, leftReader: IndexReader, rightReader: IndexReader)

checks that reader-level statistics are the same

Link copied to clipboard
fun assertStoredFieldEquals(info: String, leftField: IndexableField, rightField: IndexableField)

checks that two stored fields are equivalent

Link copied to clipboard
fun assertStoredFieldsEquals(info: String, leftReader: IndexReader, rightReader: IndexReader)

checks that stored fields of all documents are the same

Link copied to clipboard
fun assertTermsEquals(info: String, leftReader: IndexReader, rightReader: IndexReader, deep: Boolean)

Fields api equivalency

Link copied to clipboard
fun assertTermVectorsEquals(info: String, leftReader: IndexReader, rightReader: IndexReader)

checks that term vectors across all fields are equivalent

Link copied to clipboard
fun assumeFalse(msg: String, condition: Boolean)
Link copied to clipboard
Link copied to clipboard
fun assumeTrue(msg: String, condition: Boolean)
Link copied to clipboard
fun atLeast(i: Int): Int

fun atLeast(random: Random, i: Int): Int

Returns a number of at least i

Link copied to clipboard

Inspects stack trace if the given class called us.

fun callStackContains(clazz: KClass<*>, methodName: String): Boolean

Inspects stack trace to figure out if a method of a specific class called us.

Link copied to clipboard
fun callStackContainsAnyOf(vararg methodNames: String): Boolean

Inspects stack trace to figure out if one of the given method names (no class restriction) called us.

Link copied to clipboard
fun createTempDir(): Path

Creates an empty, temporary folder (when the name of the folder is of no importance).

fun createTempDir(prefix: String): Path

Creates an empty, temporary folder with the given name prefix.

Link copied to clipboard
fun createTempFile(): Path

Creates an empty temporary file.

fun createTempFile(prefix: String, suffix: String): Path

Creates an empty file with the given prefix and suffix.

Link copied to clipboard

Compute the default value of the random multiplier (based on .TEST_NIGHTLY).

Link copied to clipboard
fun <T : Throwable> expectThrows(expectedType: KClass<T>, runnable: LuceneTestCase.ThrowingRunnable): T
fun <T : Throwable> expectThrows(expectedType: KClass<T>, noExceptionMessage: String?, runnable: LuceneTestCase.ThrowingRunnable): T

Checks a specific exception class is thrown by the given runnable, and returns it.

fun <TO : Throwable, TW : Throwable> expectThrows(expectedOuterType: KClass<TO>, expectedWrappedType: KClass<TW>, runnable: LuceneTestCase.ThrowingRunnable): TW

Checks that specific wrapped and outer exception classes are thrown by the given runnable, and returns the wrapped exception.

Link copied to clipboard
fun <TO : Throwable, TW : Throwable> expectThrowsAnyOf(expectedOuterToWrappedTypes: Map<KClass<out TO>, MutableList<KClass<out TW>>>, runnable: LuceneTestCase.ThrowingRunnable): TO?

Checks that one of the specified wrapped and outer exception classes are thrown by the given runnable, and returns the outer exception.

Checks a specific exception class is thrown by the given runnable, and returns it.

Link copied to clipboard

Some tests expect the directory to contain a single segment, and want to do tests on that segment's reader. This is an utility method to help them.

Link copied to clipboard

Sometimes wrap the IndexReader as slow, parallel or filter reader (or combinations of that)

Link copied to clipboard

Creates a random empty BytesRef that sometimes uses a non-zero offset, and non-zero end-padding, to tickle latent bugs that fail to look at BytesRef.offset.

Creates a random BytesRef from the incoming bytes that sometimes uses a non-zero offset, and non-zero end-padding, to tickle latent bugs that fail to look at BytesRef.offset.

fun newBytesRef(byteLength: Int): BytesRef

Creates a random empty BytesRef, with at least the requested length of bytes free, that sometimes uses a non-zero offset, and non-zero end-padding, to tickle latent bugs that fail to look at BytesRef.offset.

Creates a BytesRef holding UTF-8 bytes for the incoming String, that sometimes uses a non-zero offset, and non-zero end-padding, to tickle latent bugs that fail to look at BytesRef.offset.

Creates a copy of the incoming BytesRef that sometimes uses a non-zero offset, and non-zero end-padding, to tickle latent bugs that fail to look at BytesRef.offset.

fun newBytesRef(bytesIn: ByteArray, offset: Int, length: Int): BytesRef

Creates a copy of the incoming bytes slice that sometimes uses a non-zero offset, and non-zero end-padding, to tickle latent bugs that fail to look at BytesRef.offset.

Link copied to clipboard

Returns a new Directory instance. Use this when the test does not care about the specific Directory implementation (most tests).

Returns a new Directory instance, using the specified random. See .newDirectory for more information.

Returns a new Directory instance, with contents copied from the provided directory. See .newDirectory for more information.

Returns a new Directory instance, using the specified random with contents copied from the provided directory. See .newDirectory for more information.

Link copied to clipboard
fun newDirectoryImpl(random: Random, clazzName: String): Directory
fun newDirectoryImpl(random: Random, clazzName: String, lf: LockFactory): Directory
Link copied to clipboard
fun newField(name: String, value: String?, type: FieldType): Field
fun newField(random: Random, name: String, value: Any?, type: FieldType): Field
Link copied to clipboard

Returns a new FSDirectory instance over the given file, which must be a folder.

Link copied to clipboard

create a new index writer config with random defaults

create a new index writer config with random defaults using the specified random

Link copied to clipboard
fun newIOContext(random: Random, oldContext: IOContext): IOContext

TODO: javadoc

Link copied to clipboard
Link copied to clipboard

Create a new searcher over the reader. This searcher might randomly use threads.

fun newSearcher(r: IndexReader, maybeWrap: Boolean, wrapWithAssertions: Boolean): IndexSearcher

Create a new searcher over the reader. This searcher might randomly use threads. if maybeWrap is true, this searcher might wrap the reader with one that returns null for getSequentialSubReaders. If wrapWithAssertions is true, this searcher might be an AssertingIndexSearcher instance.

fun newSearcher(r: IndexReader, maybeWrap: Boolean, wrapWithAssertions: Boolean, useThreads: Boolean): IndexSearcher

Create a new searcher over the reader. If maybeWrap is true, this searcher might wrap the reader with one that returns null for getSequentialSubReaders. If wrapWithAssertions is true, this searcher might be an AssertingIndexSearcher instance. The searcher will use threads if useThreads * is set to true.

fun newSearcher(r: IndexReader, maybeWrap: Boolean, wrapWithAssertions: Boolean, concurrency: LuceneTestCase.Companion.Concurrency?): IndexSearcher
Link copied to clipboard

create a new index writer config with a snapshot deletion policy

Link copied to clipboard
fun newStringField(name: String, value: String?, stored: Field.Store): Field
fun newStringField(name: String, value: BytesRef?, stored: Field.Store): Field
fun newStringField(random: Random, name: String, value: String?, stored: Field.Store): Field
fun newStringField(random: Random, name: String, value: BytesRef?, stored: Field.Store): Field
Link copied to clipboard
fun newTextField(name: String, value: String?, stored: Field.Store): Field
fun newTextField(random: Random, name: String, value: String?, stored: Field.Store): Field
Link copied to clipboard
fun random(): Random

Access to the current {@link RandomizedContext}'s Random instance. It is safe to use this method from multiple threads, etc., but it should be called while within a runner's scope (so no static initializers). The returned {@link Random} instance will be different when this method is called inside a {@link BeforeClass} hook (static suite scope) and within {@link Before}/ {@link After} hooks or test methods.

Link copied to clipboard
fun randomFixedLengthUnicodeString(random: Random, chars: CharArray, offset: Int, length: Int)

Fills provided char[] with valid random unicode code unit sequence.

Link copied to clipboard

Returns random string, including full unicode range.

fun randomUnicodeString(r: Random, maxLength: Int): String

Returns a random string up to a certain length.

Link copied to clipboard

fun rarely(random: Random): Boolean

Returns true if something should happen rarely,

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun slowFileExists(dir: Directory, fileName: String): Boolean

Returns true if the file exists (can be opened), false if it cannot be opened, and throws IOException if there's some unexpected error.

Link copied to clipboard
fun usually(random: Random): Boolean
Link copied to clipboard