Documentation ¶
Overview ¶
Package kvtest provides some utilities to help test packages that use kv.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Deflake ¶
Deflake calls test repeatedly to check that all errors returned from kv.Txn methods produce failures in the test.
Deflake(t, test) will pass if and only if: test completes when given a well-behaved kv.Txn that never returns errors, and test panics when given a kv.Txn that returns errors "unpredictably".
The test func must use panic to communicate failures. It might be nice to use a *testing.T like sane people do, but this approach requires a test that can succeed successfully when the kv.Txn doesn't return any errors, and fail successfully when it does return an error. Unfortunately, the testing package doesn't support this, and we have to panic instead.
func DumpDB ¶
DumpDB writes a mostly human-readable representation of the entire contents of db to w.
Types ¶
type Flaky ¶
Flaky is a kv.Txn implemention that
Flaky counts each call to any method that could return an error as another error check. When, during a call to such a method, the number of error checks reaches a preset value, then that call will return an error.
Usage might involve running a test once with failAtCount set to zero to test the successful case and count the number of error checks, and then to run it again for each possible value of failAtCount from 1 to the number of error checks, to make sure all errors are handled appropriately.
func NewFlaky ¶
NewFlaky returns a new Flaky that wraps the given a kv.Txn and will fail when the count of error checks reaches failAtCount.
If failAtCount is zero, the resulting Flaky will never deliberately return an error.
func (*Flaky) ErrCheckCount ¶
ErrCheckCount returns the total number of error checks this Flaky has counted so far.
func (*Flaky) StackTrace ¶
StackTrace returns a formatted stacktrace taken from the moment an error was returned.