Skip to content

Commit ab5eeb9

Browse files
committed
metamorphic: propagate FS changes to TestOptions
Tests that run a meta test and then run another one on the same filesystem currently start over from the place of the first restart operation. This commit propagates the restart FS changes to the `*TestOptions`. Note that `New()` was already modifying them (by calling `WithFSDefaults()`).
1 parent f2a76e8 commit ab5eeb9

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

external_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ func TestIteratorErrors(t *testing.T) {
5353
// at most once. We would need to skip retrying on the second invocation
5454
// of DebugCheckLevels. It's all likely more trouble than it's worth.
5555
testOpts.Opts.DebugCheck = nil
56-
// Disable the physical FS so we don't need to worry about paths down below.
57-
if fs := testOpts.Opts.FS; fs == nil || fs == vfs.Default {
58-
testOpts.Opts.FS = vfs.NewMem()
59-
}
56+
// The FS should be in-memory, so we don't need to worry about paths down
57+
// below.
58+
_ = vfs.Root(testOpts.Opts.FS).(*vfs.MemFS)
6059

6160
{
6261
test, err := metamorphic.New(metamorphic.GenerateOps(

metamorphic/meta.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,9 @@ func RunOnce(t TestingT, runDir string, seed uint64, historyPath string, rOpts .
612612

613613
// Execute runs the provided test, writing the execution history into the Test's
614614
// sink.
615+
//
616+
// Note that the test execution might change the filesystems in the TestOptions
617+
// used with New(); see the restart operation.
615618
func Execute(m *Test) error {
616619
if m.testOpts.Threads <= 1 {
617620
for m.step(m.h, nil /* optionalRecordf */) {

metamorphic/test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import (
2828
// against a database using the provided TestOptions and outputs the history of
2929
// events to an io.Writer.
3030
//
31+
// Note that the test aliases the TestOptions and can change the filesystems.
32+
//
3133
// dir specifies the path within opts.Opts.FS to open the database.
3234
func New(ops Ops, opts *TestOptions, dir string, w io.Writer) (*Test, error) {
3335
t := newTest(ops)
@@ -346,8 +348,12 @@ func (t *Test) restartDB(dbID objID) error {
346348
}
347349
t.opts.FS = crashFS
348350
t.opts.WithFSDefaults()
351+
// We want to set the new FS in testOpts too, so they are propagated to the
352+
// TestOptions that were used with metamorphic.New().
353+
t.testOpts.Opts.FS = t.opts.FS
349354
if t.opts.WALFailover != nil {
350355
t.opts.WALFailover.Secondary.FS = t.opts.FS
356+
t.testOpts.Opts.WALFailover.Secondary.FS = t.opts.FS
351357
}
352358

353359
// TODO(jackson): Audit errorRate and ensure custom options' hooks semantics

0 commit comments

Comments
 (0)