Skip to content

Commit

Permalink
metamorphic: add a test option to make downloadOp no-op
Browse files Browse the repository at this point in the history
Previously, if we had external storage enabled, we'd always
download in a download op. This meant we didn't really test cases
where a download could change the state of the LSM relative to not
doing the download.

This change adds a metamorphic test option (toggled randomly) that
disables the download operation in 50% of runs.
  • Loading branch information
itsbilal committed Nov 12, 2024
1 parent 353a036 commit 7dafc20
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions metamorphic/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ type downloadOp struct {
}

func (o *downloadOp) run(t *Test, h historyRecorder) {
if t.testOpts.disableDownloads {
h.Recordf("%s // %v", o, nil)
return
}
db := t.getDB(o.dbID)
err := t.withRetries(func() error {
return db.Download(context.Background(), o.spans)
Expand Down
9 changes: 9 additions & 0 deletions metamorphic/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func parseOptions(
return opts.useDeleteOnlyCompactionExcises
}
return true
case "TestOptions.disable_downloads":
opts.disableDownloads = true
return true
case "TestOptions.use_jemalloc_size_classes":
opts.Opts.AllocatorSizeClasses = pebble.JemallocSizeClasses
return true
Expand Down Expand Up @@ -268,6 +271,9 @@ func optionsToString(opts *TestOptions) string {
if opts.useDeleteOnlyCompactionExcises {
fmt.Fprintf(&buf, " use_delete_only_compaction_excises=%v\n", opts.useDeleteOnlyCompactionExcises)
}
if opts.disableDownloads {
fmt.Fprintf(&buf, " disable_downloads=%v\n", opts.disableDownloads)
}
if opts.Opts.AllocatorSizeClasses != nil {
if fmt.Sprint(opts.Opts.AllocatorSizeClasses) != fmt.Sprint(pebble.JemallocSizeClasses) {
panic(fmt.Sprintf("unexpected AllocatorSizeClasses %v", opts.Opts.AllocatorSizeClasses))
Expand Down Expand Up @@ -413,6 +419,8 @@ type TestOptions struct {
// useDeleteOnlyCompactionExcises turns on the ability for delete-only compactions
// to do excises. Note that this can be true even when useExcise is false.
useDeleteOnlyCompactionExcises bool
// disableDownloads, if true, makes downloadOp a no-op.
disableDownloads bool
}

// InitRemoteStorageFactory initializes Opts.Experimental.RemoteStorage.
Expand Down Expand Up @@ -861,6 +869,7 @@ func RandomOptions(
opts.Experimental.EnableDeleteOnlyCompactionExcises = func() bool {
return testOpts.useDeleteOnlyCompactionExcises
}
testOpts.disableDownloads = rng.IntN(2) == 0
testOpts.InitRemoteStorageFactory()
testOpts.Opts.EnsureDefaults()
return testOpts
Expand Down

0 comments on commit 7dafc20

Please sign in to comment.