Documentation
¶
Overview ¶
Package synclatency hands a test a seeded wal.SyncLatency, so a test that runs on a RAM drive still sees the fsync window of a real device (rmp #3022).
It is the ONLY place the latency is configured from the environment, and it is imported only by tests and by the test configuration of example 37; the store and WAL packages read no environment variable.
- GOGRAPH_FSYNC_LATENCY=off disables it: ForTest returns nil and the store behaves exactly as a production one.
- GOGRAPH_FSYNC_LATENCY_SEED=<uint64> fixes the seed, to replay a failure.
Otherwise every call draws a fresh seed, and the seed is logged when the test fails.
Index ¶
Constants ¶
const ( EnvSwitch = "GOGRAPH_FSYNC_LATENCY" EnvSeed = "GOGRAPH_FSYNC_LATENCY_SEED" )
The environment variables ForTest reads.
const ( Min = 1 * time.Millisecond Max = 5 * time.Millisecond )
Min and Max bound the injected delay per fsync: uniform in [Min, Max], the range of a consumer SSD's fsync under light load.
Variables ¶
This section is empty.
Functions ¶
func Enabled ¶
func Enabled() bool
Enabled reports whether GOGRAPH_FSYNC_LATENCY leaves the latency on.
func ForTest ¶
func ForTest(tb testing.TB) *wal.SyncLatency
ForTest returns a seeded wal.SyncLatency for tb, or nil when GOGRAPH_FSYNC_LATENCY=off. When tb fails, a cleanup logs the seed and the command-line setting that replays it. It fails tb if GOGRAPH_FSYNC_LATENCY_SEED is set but not an unsigned integer.
Types ¶
This section is empty.