Skip to content

Commit

Permalink
metamorphic: Add testing for ingest splits
Browse files Browse the repository at this point in the history
Ingest-time splitting was added in cockroachdb#2582. This change adds
testing for it to the metamorphic test, by flipping it
off/on in random options.
  • Loading branch information
itsbilal committed Sep 26, 2023
1 parent 14b8ccd commit be4d6c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions metamorphic/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ func parseOptions(
}
opts.seedEFOS = v
return true
case "TestOptions.ingest_split":
opts.ingestSplit = true
opts.Opts.Experimental.IngestSplit = func() bool {
return true
}
return true
default:
if customOptionParsers == nil {
return false
Expand Down Expand Up @@ -173,6 +179,9 @@ func optionsToString(opts *TestOptions) string {
if opts.seedEFOS != 0 {
fmt.Fprintf(&buf, " seed_efos=%d\n", opts.seedEFOS)
}
if opts.ingestSplit {
fmt.Fprintf(&buf, " ingest_split=%v\n", opts.ingestSplit)
}
for _, customOpt := range opts.CustomOpts {
fmt.Fprintf(&buf, " %s=%s\n", customOpt.Name(), customOpt.Value())
}
Expand Down Expand Up @@ -246,6 +255,9 @@ type TestOptions struct {
// are actually created as EventuallyFileOnlySnapshots is deterministically
// derived from the seed and the operation index.
seedEFOS uint64
// Enables ingest splits. Saved here for serialization as Options does not
// serialize this.
ingestSplit bool
}

// CustomOption defines a custom option that configures the behavior of an
Expand Down Expand Up @@ -536,6 +548,8 @@ func randomOptions(
}
}
testOpts.seedEFOS = rng.Uint64()
testOpts.ingestSplit = rng.Intn(2) == 0
opts.Experimental.IngestSplit = func() bool { return testOpts.ingestSplit }

return testOpts
}
Expand Down
4 changes: 4 additions & 0 deletions metamorphic/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func TestOptionsRoundtrip(t *testing.T) {
"Experimental.EnableValueBlocks:",
"Experimental.DisableIngestAsFlushable:",
"Experimental.RemoteStorage:",
"Experimental.IngestSplit:",
// Floating points
"Experimental.PointTombstoneWeight:",
}
Expand Down Expand Up @@ -97,6 +98,9 @@ func TestOptionsRoundtrip(t *testing.T) {
if o.Opts.Experimental.DisableIngestAsFlushable != nil {
require.Equal(t, o.Opts.Experimental.DisableIngestAsFlushable(), parsed.Opts.Experimental.DisableIngestAsFlushable())
}
if o.Opts.Experimental.IngestSplit != nil && o.Opts.Experimental.IngestSplit() {
require.Equal(t, o.Opts.Experimental.IngestSplit(), parsed.Opts.Experimental.IngestSplit())
}
require.Equal(t, o.Opts.MaxConcurrentCompactions(), parsed.Opts.MaxConcurrentCompactions())

diff := pretty.Diff(o.Opts, parsed.Opts)
Expand Down

0 comments on commit be4d6c1

Please sign in to comment.