MockDirectoryWrapper

This is a Directory Wrapper that adds methods intended to be used only by unit tests. It also adds a number of features useful for testing:

  • Instances created by LuceneTestCase.newDirectory are tracked to ensure they are closed by the test.

  • When a MockDirectoryWrapper is closed, it will throw an exception if it has any open files against it (with a stacktrace indicating where they were opened from).

  • When a MockDirectoryWrapper is closed, it runs CheckIndex to test if the index was corrupted.

  • MockDirectoryWrapper simulates some "features" of Windows, such as refusing to write/delete to open files.

Constructors

Link copied to clipboard
constructor(random: Random, delegate: Directory)

Types

Link copied to clipboard
open class Failure

Objects that represent fail-able conditions. Objects of a derived class are created and registered with the mock directory. After register, each object will be invoked once for each first write of a file, giving the object a chance to throw an IOException.

Link copied to clipboard
class FakeIOException : IOException

Use this when throwing fake IOException, e.g. from [ ].

Link copied to clipboard
Link copied to clipboard

Enum for controlling hard disk throttling. Set via #setThrottling(Throttling)

Properties

Link copied to clipboard
Link copied to clipboard

Trip a test assert if there is an attempt to delete an open file.

Link copied to clipboard

whether checkIndex should run on close

Link copied to clipboard
open override var commitStage: String?
Link copied to clipboard
Link copied to clipboard
open override var deleteStage: String?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override var flushStage: String?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override var isDeletingFile: Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

level passed to checkIndex when closing

Link copied to clipboard
Link copied to clipboard

Returns the peek actual storage used (bytes) in this directory.

Link copied to clipboard
open override var mergeStage: String?
Link copied to clipboard
Link copied to clipboard
open override val pendingDeletions: MutableSet<String>
Link copied to clipboard

If 0.0, no exceptions will be thrown. Else this should be a double 0.0 - 1.0. We will randomly throw an IOException on the first write to an OutputStream based on this probability.

Link copied to clipboard

If 0.0, no exceptions will be thrown during openInput and createOutput. Else this should be a double 0.0 - 1.0 and we will randomly throw an IOException in openInput and createOutput with this probability.

Link copied to clipboard
Link copied to clipboard
open override var rollbackStage: String?
Link copied to clipboard
open override var termVectorsStage: String?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun close()
Link copied to clipboard
open override fun copyFrom(from: Directory, src: String, dest: String, context: IOContext)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun crash()

Simulates a crash of OS or machine by overwriting unsynced files.

Link copied to clipboard
open override fun createOutput(name: String, context: IOContext): IndexOutput
Link copied to clipboard
open override fun createTempOutput(prefix: String, suffix: String, context: IOContext): IndexOutput
Link copied to clipboard
open override fun deleteFile(name: String)
Link copied to clipboard
open override fun ensureOpen()
Link copied to clipboard

add a Failure object to the list of objects to be evaluated at every potential failure point

Link copied to clipboard
open override fun fileLength(name: String): Long
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Returns true if this directory has not been closed.

Link copied to clipboard
open override fun listAll(): Array<String>
Link copied to clipboard

Iterate through the failures list, giving each object a chance to throw an IOE

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun obtainLock(name: String): Lock
Link copied to clipboard
open override fun openChecksumInput(name: String): ChecksumIndexInput
Link copied to clipboard
open override fun openInput(name: String, context: IOContext): IndexInput
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun rename(source: String, dest: String)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun sync(names: MutableCollection<String>)

Add a rare small sleep to catch race conditions in open/close

Link copied to clipboard
open override fun syncMetaData()
Link copied to clipboard
open override fun toString(): String