util

package
v0.0.0-...-d0be9ee Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2015 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const DEFAULT_MIN_WRITTEN_BYTES = 024
View Source
const (
	SYSPROP_NIGHTLY = "tests_nightly"
)

-------------------------------------------------------------------- Test groups, system properties and other annotations modifying tests --------------------------------------------------------------------

Variables

View Source
var (
	// Gets the codc to run tests with.
	TEST_CODEC = or(os.Getenv("tests_codec"), "Lucene49") // TODO prefer random

	// Gets the postingsFormat to run tests with.
	TEST_POSTINGSFORMAT = or(os.Getenv("tests_postingsformat"), "random")

	// Gets the docValuesFormat to run tests with
	TEST_DOCVALUESFORMAT = or(os.Getenv("tests_docvaluesformat"), "random")

	// Gets the directory to run tests with
	TEST_DIRECTORY = or(os.Getenv("tests_directory"), "random")
)
View Source
var INFOSTREAM = ("true" == or(os.Getenv("tests_infostream"), strconv.FormatBool(VERBOSE)))
View Source
var OLD_FORMAT_IMPERSONATION_IS_ACTIVE = false

When true, Codecs fo rold Lucene version will support writing indexes in that format. Defaults to false, can be disabled by specific tests on demand.

View Source
var PREFLEX_IMPERSONATION_IS_ACTIVE bool
View Source
var RANDOM_MULTIPLIER = func() int {
	n, err := strconv.Atoi(or(os.Getenv("tests_multiplier"), "1"))
	if err != nil {
		panic(err)
	}
	return n
}()

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).

View Source
var SuiteFailureMarker = &TestRuleMarkFailure{}

Suite failure marker (any error in the test or suite scope)

View Source
var TEST_NIGHTLY = ("true" == or(os.Getenv(SYSPROP_NIGHTLY), "false"))

Whether or not Nightly tests should run

View Source
var VERBOSE = ("true" == or(os.Getenv("tests_verbose"), "false"))

True if and only if tests are run in verbose mode. If this flag is false tests are not expected toprint and messages.

Functions

func AssumeFalse

func AssumeFalse(msg string, ok bool) error

func AssumeTrue

func AssumeTrue(msg string, ok bool) error

Assumption is different from Assert that Assumption returns error, while Assert panics.

func AtLeast

func AtLeast(i int) int

func MBitsToBytes

func MBitsToBytes(mBits int) int

func NewCloseableFile

func NewCloseableFile(file string, failureMarker *TestRuleMarkFailure) func() error

A Closeable that attempts to remove a given file/folder

func NextInt

func NextInt(r *rand.Rand, start, end int) int

L264

func Random

func Random() *rand.Rand

Note it's different from Lucene's Randomized Test Runner.

There is an overhead connected with getting the Random for a particular context and thread. It is better to cache this Random locally if tight loops with multiple invocations are present or create a derivative local Random for millions of calls like this:

r := rand.New(rand.NewSource(99))
// tight loop with many invocations.

func RandomUnicodeString

func RandomUnicodeString(r *rand.Rand) string

L314 Returns random string, including full unicode range.

func Rarely

func Rarely(random *rand.Rand) bool

Returns true if something should happen rarely,

The actual number returned will be influenced by whether TEST_NIGHTLY is active and RANDOM_MULTIPLIER

func TempDir

func TempDir(desc string) string

Returns a temp directory, based on the given description. Creates the directory.

func Usually

func Usually(r *rand.Rand) bool

Types

type TestRuleMarkFailure

type TestRuleMarkFailure struct {
	// contains filtered or unexported fields
}

func (*TestRuleMarkFailure) WasSuccessful

func (tr *TestRuleMarkFailure) WasSuccessful() bool

Check if this object was sucessful

type ThrottledIndexOutput

type ThrottledIndexOutput struct {
	*store.IndexOutputImpl
	// contains filtered or unexported fields
}

Intentionally slow IndexOutput for testing.

func NewThrottledIndexOutput

func NewThrottledIndexOutput(bytesPerSecond int, delayInMillis int64, delegate store.IndexOutput) *ThrottledIndexOutput

func (*ThrottledIndexOutput) Close

func (out *ThrottledIndexOutput) Close() error

func (*ThrottledIndexOutput) CopyBytes

func (out *ThrottledIndexOutput) CopyBytes(input util.DataInput, numBytes int64) error

func (*ThrottledIndexOutput) FilePointer

func (out *ThrottledIndexOutput) FilePointer() int64

func (*ThrottledIndexOutput) NewFromDelegate

func (out *ThrottledIndexOutput) NewFromDelegate(output store.IndexOutput) *ThrottledIndexOutput

func (*ThrottledIndexOutput) WriteByte

func (out *ThrottledIndexOutput) WriteByte(b byte) error

func (*ThrottledIndexOutput) WriteBytes

func (out *ThrottledIndexOutput) WriteBytes(buf []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL