Skip to content

Commit eae1e78

Browse files
committed
roachtest: fix test monitor error
Previously, the global test monitor would fatal on an error. This is similar to how the original monitor worked. But the original monitor would fatal where a panic could be recovered by the goroutine running the test. This would immediately short circuit the test. However, the global monitor can not use fatal since it's running in a separate goroutine which causes the panic to be unrecoverable. This change makes the global monitor call `Errorf` instead of `Fatalf`. The test context will now instead be cancelled. Epic: None Release note: None
1 parent 39d519b commit eae1e78

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

pkg/cmd/roachtest/test_monitor.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,28 @@ import (
1111
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test"
1212
)
1313

14-
var _ test.Monitor = &testMonitorImpl{}
15-
1614
type testMonitorImpl struct {
17-
*monitorImpl
15+
monitor interface {
16+
test.Monitor
17+
WaitForNodeDeath() error
18+
}
19+
t test.Test
1820
}
1921

20-
func newTestMonitor(ctx context.Context, t test.Test, c *clusterImpl) *testMonitorImpl {
22+
// newTestMonitor is a function that creates a new test monitor. It can be used for testing
23+
// purposes to replace the default monitor with a custom implementation.
24+
var newTestMonitor = func(ctx context.Context, t test.Test, c *clusterImpl) *testMonitorImpl {
2125
return &testMonitorImpl{
22-
monitorImpl: newMonitor(ctx, t, c, true /* expectExactProcessDeath */),
26+
monitor: newMonitor(ctx, t, c, true /* expectExactProcessDeath */),
27+
t: t,
2328
}
2429
}
2530

2631
func (m *testMonitorImpl) start() {
2732
go func() {
28-
err := m.WaitForNodeDeath()
33+
err := m.monitor.WaitForNodeDeath()
2934
if err != nil {
30-
m.t.Fatal(err)
35+
m.t.Errorf("test monitor: %v", err)
3136
}
3237
}()
3338
}

pkg/cmd/roachtest/test_runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ func (r *testRunner) runTest(
13511351

13521352
t.taskManager = task.NewManager(runCtx, t.L())
13531353
testMonitor := newTestMonitor(runCtx, t, c)
1354-
t.monitor = testMonitor
1354+
t.monitor = testMonitor.monitor
13551355

13561356
t.mu.Lock()
13571357
// t.Fatal() will cancel this context.

0 commit comments

Comments
 (0)