diff --git a/metamorphic/history.go b/metamorphic/history.go index 8a7adbe3e1..82077c79f9 100644 --- a/metamorphic/history.go +++ b/metamorphic/history.go @@ -125,7 +125,8 @@ func (h *history) Fatalf(format string, args ...interface{}) { panic(fmt.Sprintf(format, args...)) } _ = h.log.Output(2, h.format("FATAL", format, args...)) - h.err.Store(errors.Errorf(format, args...)) + // Store the first fatal error message. + h.err.CompareAndSwap(nil, errors.Errorf(format, args...)) } func (h *history) recorder( @@ -206,7 +207,11 @@ func reorderHistory(lines []string) []string { if cleaned := strings.TrimSpace(l); cleaned == "" { continue } - reordered[extractOp(l)] = l + idx := extractOp(l) + if idx >= len(reordered) { + panic("incomplete test history; this shouldn't happen given that execution completed successfully") + } + reordered[idx] = l } return reordered } diff --git a/metamorphic/meta.go b/metamorphic/meta.go index 815cd910a7..649e7a4e80 100644 --- a/metamorphic/meta.go +++ b/metamorphic/meta.go @@ -22,12 +22,12 @@ import ( "testing" "time" + "github.com/cockroachdb/errors" "github.com/cockroachdb/pebble/internal/base" "github.com/cockroachdb/pebble/internal/dsl" "github.com/cockroachdb/pebble/internal/randvar" "github.com/cockroachdb/pebble/vfs" "github.com/cockroachdb/pebble/vfs/errorfs" - "github.com/pkg/errors" "github.com/pmezard/go-difflib/difflib" "github.com/stretchr/testify/require" "golang.org/x/exp/rand" @@ -572,6 +572,8 @@ func RunOnce(t TestingT, runDir string, seed uint64, historyPath string, rOpts . fmt.Fprintf(os.Stderr, "\n%s\n", db.LSMViewURL()) } } + // Don't let the test pass if it issued a Fatalf. + err = errors.CombineErrors(err, h.Error()) if err != nil { m.saveInMemoryData()