Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metamorphic: fix TestOptionsRoundtrip flake #3458

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion metamorphic/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func RunOnce(t TestingT, runDir string, seed uint64, historyPath string, rOpts .
}
// Wrap the filesystem with a VFS that will inject random latency if
// the test options require it.
if testOpts.ioLatencyProbability > 0.0 {
if testOpts.ioLatencyProbability > 0 {
opts.FS = errorfs.Wrap(opts.FS, errorfs.RandomLatency(
errorfs.Randomly(testOpts.ioLatencyProbability, testOpts.ioLatencySeed),
testOpts.ioLatencyMean,
Expand Down
8 changes: 5 additions & 3 deletions metamorphic/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ func optionsToString(opts *TestOptions) string {
if opts.ingestSplit {
fmt.Fprintf(&buf, " ingest_split=%v\n", opts.ingestSplit)
}
if opts.ioLatencyProbability > 0.0 {
if opts.ioLatencyProbability > 0 {
fmt.Fprintf(&buf, " io_latency_mean=%s\n", opts.ioLatencyMean)
fmt.Fprintf(&buf, " io_latency_probability=%f\n", opts.ioLatencyProbability)
fmt.Fprintf(&buf, " io_latency_probability=%.10f\n", opts.ioLatencyProbability)
fmt.Fprintf(&buf, " io_latency_seed=%d\n", opts.ioLatencySeed)
}
if opts.useSharedReplicate {
Expand Down Expand Up @@ -714,8 +714,10 @@ func RandomOptions(
testOpts.strictFS = rng.Intn(2) != 0 // Only relevant for MemFS.
// 50% of the time, enable IO latency injection.
if rng.Intn(2) == 0 {
// Note: we want ioLatencyProbability to be at least 1e-10, otherwise it
// might print as 0 when we stringify options.
testOpts.ioLatencyProbability = 1e-10 + 0.01*rng.Float64() // 0-1%
testOpts.ioLatencyMean = expRandDuration(rng, 3*time.Millisecond, time.Second)
testOpts.ioLatencyProbability = 0.01 * rng.Float64() // 0-1%
testOpts.ioLatencySeed = rng.Int63()
}
testOpts.Threads = rng.Intn(runtime.GOMAXPROCS(0)) + 1
Expand Down
Loading