dbtest

package
v1.11.12 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Benchmarks is a list of all database benchmarks
	Benchmarks = map[string]func(b *testing.B, db database.Database, keys, values [][]byte){
		"Get":            BenchmarkGet,
		"Put":            BenchmarkPut,
		"Delete":         BenchmarkDelete,
		"BatchPut":       BenchmarkBatchPut,
		"BatchDelete":    BenchmarkBatchDelete,
		"BatchWrite":     BenchmarkBatchWrite,
		"ParallelGet":    BenchmarkParallelGet,
		"ParallelPut":    BenchmarkParallelPut,
		"ParallelDelete": BenchmarkParallelDelete,
	}
	// BenchmarkSizes to use with each benchmark
	BenchmarkSizes = [][]int{

		{1024, 32, 32},
		{1024, 256, 256},
		{1024, 2 * units.KiB, 2 * units.KiB},
	}
)
View Source
var Tests = map[string]func(t *testing.T, db database.Database){
	"SimpleKeyValue":                   TestSimpleKeyValue,
	"OverwriteKeyValue":                TestOverwriteKeyValue,
	"EmptyKey":                         TestEmptyKey,
	"KeyEmptyValue":                    TestKeyEmptyValue,
	"SimpleKeyValueClosed":             TestSimpleKeyValueClosed,
	"NewBatchClosed":                   TestNewBatchClosed,
	"BatchPut":                         TestBatchPut,
	"BatchDelete":                      TestBatchDelete,
	"BatchReset":                       TestBatchReset,
	"BatchReuse":                       TestBatchReuse,
	"BatchRewrite":                     TestBatchRewrite,
	"BatchReplay":                      TestBatchReplay,
	"BatchReplayPropagateError":        TestBatchReplayPropagateError,
	"BatchInner":                       TestBatchInner,
	"BatchLargeSize":                   TestBatchLargeSize,
	"IteratorSnapshot":                 TestIteratorSnapshot,
	"Iterator":                         TestIterator,
	"IteratorStart":                    TestIteratorStart,
	"IteratorPrefix":                   TestIteratorPrefix,
	"IteratorStartPrefix":              TestIteratorStartPrefix,
	"IteratorMemorySafety":             TestIteratorMemorySafety,
	"IteratorClosed":                   TestIteratorClosed,
	"IteratorError":                    TestIteratorError,
	"IteratorErrorAfterRelease":        TestIteratorErrorAfterRelease,
	"CompactNoPanic":                   TestCompactNoPanic,
	"MemorySafetyDatabase":             TestMemorySafetyDatabase,
	"MemorySafetyBatch":                TestMemorySafetyBatch,
	"AtomicClear":                      TestAtomicClear,
	"Clear":                            TestClear,
	"AtomicClearPrefix":                TestAtomicClearPrefix,
	"ClearPrefix":                      TestClearPrefix,
	"ModifyValueAfterPut":              TestModifyValueAfterPut,
	"ModifyValueAfterBatchPut":         TestModifyValueAfterBatchPut,
	"ModifyValueAfterBatchPutReplay":   TestModifyValueAfterBatchPutReplay,
	"ConcurrentBatches":                TestConcurrentBatches,
	"ManySmallConcurrentKVPairBatches": TestManySmallConcurrentKVPairBatches,
	"PutGetEmpty":                      TestPutGetEmpty,
}

Tests is a list of all database tests

Functions

func BenchmarkBatchDelete

func BenchmarkBatchDelete(b *testing.B, db database.Database, keys, _ [][]byte)

BenchmarkBatchDelete measures the time it takes to batch delete.

func BenchmarkBatchPut

func BenchmarkBatchPut(b *testing.B, db database.Database, keys, values [][]byte)

BenchmarkBatchPut measures the time it takes to batch put.

func BenchmarkBatchWrite

func BenchmarkBatchWrite(b *testing.B, db database.Database, keys, values [][]byte)

BenchmarkBatchWrite measures the time it takes to batch write.

func BenchmarkDelete

func BenchmarkDelete(b *testing.B, db database.Database, keys, values [][]byte)

BenchmarkDelete measures the time it takes to delete a (k, v) from a database.

func BenchmarkGet

func BenchmarkGet(b *testing.B, db database.Database, keys, values [][]byte)

BenchmarkGet measures the time it takes to get an operation from a database.

func BenchmarkParallelDelete

func BenchmarkParallelDelete(b *testing.B, db database.Database, keys, values [][]byte)

BenchmarkParallelDelete measures the time it takes to delete a (k, v) from the db.

func BenchmarkParallelGet

func BenchmarkParallelGet(b *testing.B, db database.Database, keys, values [][]byte)

BenchmarkParallelGet measures the time it takes to read in parallel.

func BenchmarkParallelPut

func BenchmarkParallelPut(b *testing.B, db database.Database, keys, values [][]byte)

BenchmarkParallelPut measures the time it takes to write to the db in parallel.

func BenchmarkPut

func BenchmarkPut(b *testing.B, db database.Database, keys, values [][]byte)

BenchmarkPut measures the time it takes to write an operation to a database.

func FuzzKeyValue

func FuzzKeyValue(f *testing.F, db database.Database)

func FuzzNewIteratorWithPrefix

func FuzzNewIteratorWithPrefix(f *testing.F, db database.Database)

func FuzzNewIteratorWithStartAndPrefix

func FuzzNewIteratorWithStartAndPrefix(f *testing.F, db database.Database)

func SetupBenchmark

func SetupBenchmark(b *testing.B, count int, keySize, valueSize int) ([][]byte, [][]byte)

Writes size data into the db in order to setup reads in subsequent tests.

func TestAtomicClear

func TestAtomicClear(t *testing.T, db database.Database)

func TestAtomicClearPrefix

func TestAtomicClearPrefix(t *testing.T, db database.Database)

func TestBatchDelete

func TestBatchDelete(t *testing.T, db database.Database)

TestBatchDelete tests to make sure that batched deletes work as expected.

func TestBatchInner

func TestBatchInner(t *testing.T, db database.Database)

TestBatchInner tests to make sure that inner can be used to write to the database.

func TestBatchLargeSize

func TestBatchLargeSize(t *testing.T, db database.Database)

TestBatchLargeSize tests to make sure that the batch can support a large amount of entries.

func TestBatchPut

func TestBatchPut(t *testing.T, db database.Database)

TestBatchPut tests to make sure that batched writes work as expected.

func TestBatchReplay

func TestBatchReplay(t *testing.T, db database.Database)

TestBatchReplay tests to make sure that batches will correctly replay their contents.

func TestBatchReplayPropagateError

func TestBatchReplayPropagateError(t *testing.T, db database.Database)

TestBatchReplayPropagateError tests to make sure that batches will correctly propagate any returned error during Replay.

func TestBatchReset

func TestBatchReset(t *testing.T, db database.Database)

TestBatchReset tests to make sure that a batch drops un-written operations when it is reset.

func TestBatchReuse

func TestBatchReuse(t *testing.T, db database.Database)

TestBatchReuse tests to make sure that a batch can be reused once it is reset.

func TestBatchRewrite

func TestBatchRewrite(t *testing.T, db database.Database)

TestBatchRewrite tests to make sure that write can be called multiple times on a batch and the values will be updated correctly.

func TestClear

func TestClear(t *testing.T, db database.Database)

func TestClearPrefix

func TestClearPrefix(t *testing.T, db database.Database)

func TestCompactNoPanic

func TestCompactNoPanic(t *testing.T, db database.Database)

TestCompactNoPanic tests to make sure compact never panics.

func TestConcurrentBatches

func TestConcurrentBatches(t *testing.T, db database.Database)

func TestEmptyKey

func TestEmptyKey(t *testing.T, db database.Database)

func TestIterator

func TestIterator(t *testing.T, db database.Database)

TestIterator tests to make sure the database iterates over the database contents lexicographically.

func TestIteratorClosed

func TestIteratorClosed(t *testing.T, db database.Database)

TestIteratorClosed tests to make sure that an iterator that was created with a closed database will report a closed error correctly.

func TestIteratorError

func TestIteratorError(t *testing.T, db database.Database)

TestIteratorError tests to make sure that an iterator on a database will report itself as being exhausted and return database.ErrClosed to indicate that the iteration was not successful. Additionally tests that an iterator that has already called Next() can still serve its current value after the underlying DB was closed.

func TestIteratorErrorAfterRelease

func TestIteratorErrorAfterRelease(t *testing.T, db database.Database)

TestIteratorErrorAfterRelease tests to make sure that an iterator that was released still reports the error correctly.

func TestIteratorMemorySafety

func TestIteratorMemorySafety(t *testing.T, db database.Database)

TestIteratorMemorySafety tests to make sure that keys can values are able to be modified from the returned iterator.

func TestIteratorPrefix

func TestIteratorPrefix(t *testing.T, db database.Database)

TestIteratorPrefix tests to make sure the iterator can be configured to skip keys missing the provided prefix.

func TestIteratorSnapshot

func TestIteratorSnapshot(t *testing.T, db database.Database)

TestIteratorSnapshot tests to make sure the database iterates over a snapshot of the database at the time of the iterator creation.

func TestIteratorStart

func TestIteratorStart(t *testing.T, db database.Database)

TestIteratorStart tests to make sure the iterator can be configured to start mid way through the database.

func TestIteratorStartPrefix

func TestIteratorStartPrefix(t *testing.T, db database.Database)

TestIteratorStartPrefix tests to make sure that the iterator can start mid way through the database while skipping a prefix.

func TestKeyEmptyValue

func TestKeyEmptyValue(t *testing.T, db database.Database)

func TestManySmallConcurrentKVPairBatches

func TestManySmallConcurrentKVPairBatches(t *testing.T, db database.Database)

func TestMemorySafetyBatch

func TestMemorySafetyBatch(t *testing.T, db database.Database)

TestMemorySafetyBatch ensures it is safe to modify a key after passing it to Batch.Put.

func TestMemorySafetyDatabase

func TestMemorySafetyDatabase(t *testing.T, db database.Database)

TestMemorySafetyDatabase ensures it is safe to modify a key after passing it to Database.Put and Database.Get.

func TestModifyValueAfterBatchPut

func TestModifyValueAfterBatchPut(t *testing.T, db database.Database)

func TestModifyValueAfterBatchPutReplay

func TestModifyValueAfterBatchPutReplay(t *testing.T, db database.Database)

func TestModifyValueAfterPut

func TestModifyValueAfterPut(t *testing.T, db database.Database)

func TestNewBatchClosed

func TestNewBatchClosed(t *testing.T, db database.Database)

TestNewBatchClosed tests to make sure that calling NewBatch on a closed database returns a batch that errors correctly.

func TestOverwriteKeyValue

func TestOverwriteKeyValue(t *testing.T, db database.Database)

func TestPutGetEmpty

func TestPutGetEmpty(t *testing.T, db database.Database)

func TestSimpleKeyValue

func TestSimpleKeyValue(t *testing.T, db database.Database)

TestSimpleKeyValue tests to make sure that simple Put + Get + Delete + Has calls return the expected values.

func TestSimpleKeyValueClosed

func TestSimpleKeyValueClosed(t *testing.T, db database.Database)

TestSimpleKeyValueClosed tests to make sure that Put + Get + Delete + Has calls return the correct error when the database has been closed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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