Documentation
¶
Index ¶
- Constants
- Variables
- func CheckIndex(dir store.Directory, crossCheckTermVectors bool) *index.CheckIndexStatus
- func NewCloseableDirectory(dir BaseDirectoryWrapper, failureMarker *TestRuleMarkFailure) func() error
- func NewDefaultIOContext(r *rand.Rand) store.IOContext
- func NewField(r *rand.Rand, name, value string, typ *docu.FieldType) *docu.Field
- func NewIOContext(r *rand.Rand, oldContext store.IOContext) store.IOContext
- func NewIndexWriterConfig(v util.Version, a analysis.Analyzer) *index.IndexWriterConfig
- func NewNullInfoStream() util.InfoStream
- func NewSearcher(r index.IndexReader) *ts.AssertingIndexSearcher
- func NewTextField(name, value string, stored bool) *docu.Field
- func SuppressCodecs(name string)
- type BaseDirectoryWrapper
- type BaseDirectoryWrapperImpl
- type Failure
- type Handle
- type MockDirectoryWrapper
- func (w *MockDirectoryWrapper) ClearLock(name string) error
- func (w *MockDirectoryWrapper) Close() error
- func (w *MockDirectoryWrapper) Copy(to store.Directory, src string, dest string, context store.IOContext) error
- func (w *MockDirectoryWrapper) Crash() error
- func (w *MockDirectoryWrapper) CreateOutput(name string, context store.IOContext) (store.IndexOutput, error)
- func (w *MockDirectoryWrapper) DeleteFile(name string) error
- func (w *MockDirectoryWrapper) FileExists(name string) bool
- func (w *MockDirectoryWrapper) FileLength(name string) (int64, error)
- func (w *MockDirectoryWrapper) ListAll() ([]string, error)
- func (w *MockDirectoryWrapper) LockFactory() store.LockFactory
- func (w *MockDirectoryWrapper) LockID() string
- func (w *MockDirectoryWrapper) MakeLock(name string) store.Lock
- func (w *MockDirectoryWrapper) OpenInput(name string, context store.IOContext) (ii store.IndexInput, err error)
- func (w *MockDirectoryWrapper) SetLockFactory(lockFactory store.LockFactory)
- func (mdw *MockDirectoryWrapper) SetThrottling(throttling Throttling)
- func (w *MockDirectoryWrapper) String() string
- func (w *MockDirectoryWrapper) Sync(names []string) error
- type MockIndexInputWrapper
- func (w *MockIndexInputWrapper) Clone() store.IndexInput
- func (w *MockIndexInputWrapper) Close() (err error)
- func (w *MockIndexInputWrapper) FilePointer() int64
- func (w *MockIndexInputWrapper) Length() int64
- func (w *MockIndexInputWrapper) ReadByte() (byte, error)
- func (w *MockIndexInputWrapper) ReadBytes(buf []byte) error
- func (w *MockIndexInputWrapper) ReadInt() (int32, error)
- func (w *MockIndexInputWrapper) ReadLong() (int64, error)
- func (w *MockIndexInputWrapper) ReadShort() (int16, error)
- func (w *MockIndexInputWrapper) ReadString() (string, error)
- func (w *MockIndexInputWrapper) ReadStringStringMap() (map[string]string, error)
- func (w *MockIndexInputWrapper) ReadVInt() (int32, error)
- func (w *MockIndexInputWrapper) ReadVLong() (int64, error)
- func (w *MockIndexInputWrapper) Seek(pos int64) error
- func (w *MockIndexInputWrapper) String() string
- type MockIndexOutputWrapper
- func (w *MockIndexOutputWrapper) Close() (err error)
- func (w *MockIndexOutputWrapper) CopyBytes(input util.DataInput, numBytes int64) error
- func (w *MockIndexOutputWrapper) FilePointer() int64
- func (w *MockIndexOutputWrapper) Flush() error
- func (w *MockIndexOutputWrapper) Length() (int64, error)
- func (w *MockIndexOutputWrapper) String() string
- func (w *MockIndexOutputWrapper) WriteByte(b byte) error
- func (w *MockIndexOutputWrapper) WriteBytes(buf []byte) error
- type MockLock
- type MockLockFactoryWrapper
- type NullInfoStream
- type TestRuleSetupAndRestoreClassEnv
- type ThreadNameFixingPrintStreamInfoStream
- type Throttling
Constants ¶
const ( // always emulate a slow hard disk. Cold be very slow! THROTTLING_ALWAYS = Throttling(1) // sometimes (2% of the time) emulate a slow hard disk. THROTTLING_SOMETIMES = Throttling(2) // never throttle output THROTTLING_NEVER = Throttling(3) )
const ( HANDLE_INPUT = Handle(1) HANDLE_OUTPUT = Handle(2) HANDLE_SLICE = Handle(3) )
Variables ¶
var ClassEnvRule = &TestRuleSetupAndRestoreClassEnv{}
Class environment setup rule.
var TEST_THROTTLING = either(TEST_NIGHTLY, THROTTLING_SOMETIMES, THROTTLING_NEVER).(Throttling)
Throttling
var TEST_VERSION_CURRENT = util.VERSION_45
Use this constant then creating Analyzers and any other version-dependent stuff. NOTE: Change this when developmenet starts for new Lucene version:
Functions ¶
func CheckIndex ¶
func CheckIndex(dir store.Directory, crossCheckTermVectors bool) *index.CheckIndexStatus
func NewCloseableDirectory ¶
func NewCloseableDirectory(dir BaseDirectoryWrapper, failureMarker *TestRuleMarkFailure) func() error
Attempts to close a BaseDirectoryWrapper
func NewIndexWriterConfig ¶
Create a new index writer config with random defaults
func NewNullInfoStream ¶
func NewNullInfoStream() util.InfoStream
func NewSearcher ¶
func NewSearcher(r index.IndexReader) *ts.AssertingIndexSearcher
L1305 Create a new searcher over the reader. This searcher might randomly use threads
func SuppressCodecs ¶
func SuppressCodecs(name string)
Types ¶
type BaseDirectoryWrapper ¶
Calls check index on close. do NOT make any methods in this class synchronized, volatile do NOT import anything from the concurrency package. no randoms, no nothing.
func NewDirectory ¶
func NewDirectory() BaseDirectoryWrapper
Returns a new Direcotry instance. Use this when the test does not care about the specific Directory implementation (most tests).
The Directory is wrapped with BaseDirectoryWrapper. This menas usually it will be picky, such as ensuring that you properly close it and all open files in your test. It will emulate some features of Windows, such as not allowing open files ot be overwritten.
type BaseDirectoryWrapperImpl ¶
type BaseDirectoryWrapperImpl struct { store.Directory // our delegate in directory // contains filtered or unexported fields }
func NewBaseDirectoryWrapper ¶
func NewBaseDirectoryWrapper(delegate store.Directory) *BaseDirectoryWrapperImpl
func (*BaseDirectoryWrapperImpl) Close ¶
func (dw *BaseDirectoryWrapperImpl) Close() error
func (*BaseDirectoryWrapperImpl) IsOpen ¶
func (dw *BaseDirectoryWrapperImpl) IsOpen() bool
func (*BaseDirectoryWrapperImpl) String ¶
func (dw *BaseDirectoryWrapperImpl) String() string
type Failure ¶
type Failure struct {
// contains filtered or unexported fields
}
Objects that represent fail-lable conditions. Objects of a derived class are created and registered with teh 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 IO error.
func (*Failure) ClearDoFail ¶
func (f *Failure) ClearDoFail()
func (*Failure) Reset ¶
reset should set the state of the failure to its default (freshly constructed) state. Reset is convenient for tests that want to create one failure object and then reuse it in mutiple cases. This, combined with the fact that Failure subclasses are often anonymous classes makes reset difficult to do otherwise.
A typical example of use is
failure := &Failure { eval: func(dir *MockDirectoryWrapper) { ... } } ... mock.failOn(failure.reset())
type MockDirectoryWrapper ¶
type MockDirectoryWrapper struct { *BaseDirectoryWrapperImpl sync.Locker // simulate Java's synchronized keyword // contains filtered or unexported fields }
This is a Directory wrapper that adds methods intended to be used only by unit tests. It also adds a number of fatures useful for testing:
1. Instances created by newDirectory() are tracked to ensure they are closed by the test. 2. When a MockDirectoryWrapper is closed, it returns an error if it has any open files against it (with a stacktrace indicating where they were opened from) 3. When a MockDirectoryWrapper is closed, it runs CheckIndex to test if the index was corrupted. 4. MockDirectoryWrapper simulates some "features" of Windows, such as refusing to write/delete to open files.
func NewMockDirectoryWrapper ¶
func NewMockDirectoryWrapper(random *rand.Rand, delegate store.Directory) *MockDirectoryWrapper
func (*MockDirectoryWrapper) ClearLock ¶
func (w *MockDirectoryWrapper) ClearLock(name string) error
func (*MockDirectoryWrapper) Close ¶
func (w *MockDirectoryWrapper) Close() error
func (*MockDirectoryWrapper) Crash ¶
func (w *MockDirectoryWrapper) Crash() error
Simulates a crash of OS or machine by overwriting unsynced files.
func (*MockDirectoryWrapper) CreateOutput ¶
func (w *MockDirectoryWrapper) CreateOutput(name string, context store.IOContext) (store.IndexOutput, error)
func (*MockDirectoryWrapper) DeleteFile ¶
func (w *MockDirectoryWrapper) DeleteFile(name string) error
func (*MockDirectoryWrapper) FileExists ¶
func (w *MockDirectoryWrapper) FileExists(name string) bool
func (*MockDirectoryWrapper) FileLength ¶
func (w *MockDirectoryWrapper) FileLength(name string) (int64, error)
func (*MockDirectoryWrapper) ListAll ¶
func (w *MockDirectoryWrapper) ListAll() ([]string, error)
func (*MockDirectoryWrapper) LockFactory ¶
func (w *MockDirectoryWrapper) LockFactory() store.LockFactory
func (*MockDirectoryWrapper) LockID ¶
func (w *MockDirectoryWrapper) LockID() string
func (*MockDirectoryWrapper) MakeLock ¶
func (w *MockDirectoryWrapper) MakeLock(name string) store.Lock
func (*MockDirectoryWrapper) OpenInput ¶
func (w *MockDirectoryWrapper) OpenInput(name string, context store.IOContext) (ii store.IndexInput, err error)
func (*MockDirectoryWrapper) SetLockFactory ¶
func (w *MockDirectoryWrapper) SetLockFactory(lockFactory store.LockFactory)
func (*MockDirectoryWrapper) SetThrottling ¶
func (mdw *MockDirectoryWrapper) SetThrottling(throttling Throttling)
func (*MockDirectoryWrapper) String ¶
func (w *MockDirectoryWrapper) String() string
func (*MockDirectoryWrapper) Sync ¶
func (w *MockDirectoryWrapper) Sync(names []string) error
type MockIndexInputWrapper ¶
type MockIndexInputWrapper struct { *store.IndexInputImpl // contains filtered or unexported fields }
Used by MockDirectoryWrapper to create an input stream that keeps track of when it's been closed.
func (*MockIndexInputWrapper) Clone ¶
func (w *MockIndexInputWrapper) Clone() store.IndexInput
func (*MockIndexInputWrapper) Close ¶
func (w *MockIndexInputWrapper) Close() (err error)
func (*MockIndexInputWrapper) FilePointer ¶
func (w *MockIndexInputWrapper) FilePointer() int64
func (*MockIndexInputWrapper) Length ¶
func (w *MockIndexInputWrapper) Length() int64
func (*MockIndexInputWrapper) ReadByte ¶
func (w *MockIndexInputWrapper) ReadByte() (byte, error)
func (*MockIndexInputWrapper) ReadBytes ¶
func (w *MockIndexInputWrapper) ReadBytes(buf []byte) error
func (*MockIndexInputWrapper) ReadInt ¶
func (w *MockIndexInputWrapper) ReadInt() (int32, error)
func (*MockIndexInputWrapper) ReadLong ¶
func (w *MockIndexInputWrapper) ReadLong() (int64, error)
func (*MockIndexInputWrapper) ReadShort ¶
func (w *MockIndexInputWrapper) ReadShort() (int16, error)
func (*MockIndexInputWrapper) ReadString ¶
func (w *MockIndexInputWrapper) ReadString() (string, error)
func (*MockIndexInputWrapper) ReadStringStringMap ¶
func (w *MockIndexInputWrapper) ReadStringStringMap() (map[string]string, error)
func (*MockIndexInputWrapper) ReadVInt ¶
func (w *MockIndexInputWrapper) ReadVInt() (int32, error)
func (*MockIndexInputWrapper) ReadVLong ¶
func (w *MockIndexInputWrapper) ReadVLong() (int64, error)
func (*MockIndexInputWrapper) Seek ¶
func (w *MockIndexInputWrapper) Seek(pos int64) error
func (*MockIndexInputWrapper) String ¶
func (w *MockIndexInputWrapper) String() string
type MockIndexOutputWrapper ¶
type MockIndexOutputWrapper struct { *store.IndexOutputImpl // contains filtered or unexported fields }
Used by MockRAMDirectory to create an output stream that will throw an error on fake disk full, track max disk space actually used, and maybe throw random IO errors.
func (*MockIndexOutputWrapper) Close ¶
func (w *MockIndexOutputWrapper) Close() (err error)
func (*MockIndexOutputWrapper) CopyBytes ¶
func (w *MockIndexOutputWrapper) CopyBytes(input util.DataInput, numBytes int64) error
func (*MockIndexOutputWrapper) FilePointer ¶
func (w *MockIndexOutputWrapper) FilePointer() int64
func (*MockIndexOutputWrapper) Flush ¶
func (w *MockIndexOutputWrapper) Flush() error
func (*MockIndexOutputWrapper) Length ¶
func (w *MockIndexOutputWrapper) Length() (int64, error)
func (*MockIndexOutputWrapper) String ¶
func (w *MockIndexOutputWrapper) String() string
func (*MockIndexOutputWrapper) WriteByte ¶
func (w *MockIndexOutputWrapper) WriteByte(b byte) error
func (*MockIndexOutputWrapper) WriteBytes ¶
func (w *MockIndexOutputWrapper) WriteBytes(buf []byte) error
type MockLockFactoryWrapper ¶
type MockLockFactoryWrapper struct { store.LockFactory // contains filtered or unexported fields }
Used by MockDirectoryWrapper to wrap another factory and track open locks.
func (*MockLockFactoryWrapper) Clear ¶
func (w *MockLockFactoryWrapper) Clear(lockName string) error
func (*MockLockFactoryWrapper) Make ¶
func (w *MockLockFactoryWrapper) Make(lockName string) store.Lock
func (*MockLockFactoryWrapper) String ¶
func (w *MockLockFactoryWrapper) String() string
type NullInfoStream ¶
type NullInfoStream int
Prints nothing. Just to make sure tests pass w/ and w/o enabled InfoStream without actually making noise.
func (NullInfoStream) Clone ¶
func (is NullInfoStream) Clone() util.InfoStream
func (NullInfoStream) Close ¶
func (is NullInfoStream) Close() error
func (NullInfoStream) IsEnabled ¶
func (is NullInfoStream) IsEnabled(component string) bool
func (NullInfoStream) Message ¶
func (is NullInfoStream) Message(component, message string, args ...interface{})
type TestRuleSetupAndRestoreClassEnv ¶
type TestRuleSetupAndRestoreClassEnv struct {
// contains filtered or unexported fields
}
Setup and restore suite-level environment (fine grained junk that doesn't fit anywhere else)
func (*TestRuleSetupAndRestoreClassEnv) After ¶
func (rule *TestRuleSetupAndRestoreClassEnv) After() error
func (*TestRuleSetupAndRestoreClassEnv) Before ¶
func (rule *TestRuleSetupAndRestoreClassEnv) Before() error
type ThreadNameFixingPrintStreamInfoStream ¶
type ThreadNameFixingPrintStreamInfoStream struct {
*util.PrintStreamInfoStream
}
func (*ThreadNameFixingPrintStreamInfoStream) Message ¶
func (is *ThreadNameFixingPrintStreamInfoStream) Message(component, message string, args ...interface{})
type Throttling ¶
type Throttling int
Controlling hard disk throttling Set via setThrottling() WARNING: can make tests very slow.