Skip to content

Commit a346746

Browse files
committed
roachtest: detect sysbench crashes when preparing workload
Sysbench is known to flake with crashes. Previously, we would detect these crashes when running the workload and pass the run to avoid noise. This change now does the same when preparing the workload as well. It also skips the test instead of passing the test. This makes it easier to identify tests that actually ran to completion and has consequences for test selection. We also add a small helper to prefix out sysbench output with timestamps, this should aid debugging.
1 parent e233359 commit a346746

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

pkg/cmd/roachtest/roachtestutil/utils.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,12 @@ func PortLatency(
279279
}
280280
return time.Duration(avgRTT * float64(time.Second)), nil
281281
}
282+
283+
// PrefixCmdOutputWithTimestamp wraps a remote command such that it pipes
284+
// stdout and stderr through awk and prepends the timestamp. Can be used to aid
285+
// debugging long-running commands that don't already prefix output with timestamps.
286+
func PrefixCmdOutputWithTimestamp(cmd string) string {
287+
// Don't prefix blank lines with timestamps.
288+
awkCmd := `awk 'NF { cmd="date +\"%H:%M:%S\""; cmd | getline ts; close(cmd); print ts ":", $0; next } { print }'`
289+
return fmt.Sprintf(`bash -c '%s' 2>&1 |`, cmd) + awkCmd
290+
}

pkg/cmd/roachtest/tests/sysbench.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,11 @@ func runSysbench(ctx context.Context, t test.Test, c cluster.Cluster, opts sysbe
195195
t.Status("preparing workload")
196196
cmd := opts.cmd(useHAProxy /* haproxy */)
197197
{
198-
result, err := c.RunWithDetailsSingleNode(ctx, t.L(), option.WithNodes(c.WorkloadNode()), cmd+" prepare")
198+
result, err := c.RunWithDetailsSingleNode(ctx, t.L(), option.WithNodes(c.WorkloadNode()), roachtestutil.PrefixCmdOutputWithTimestamp(cmd+" prepare"))
199199
if err != nil {
200200
return err
201+
} else if msg, crashed := detectSysbenchCrash(result); crashed {
202+
t.Skipf("%s; skipping test", msg)
201203
} else if strings.Contains(result.Stdout, "FATAL") {
202204
// sysbench prepare doesn't exit on errors for some reason, so we have
203205
// to check that it didn't silently fail. We've seen it do so, causing
@@ -225,11 +227,10 @@ func runSysbench(ctx context.Context, t test.Test, c cluster.Cluster, opts sysbe
225227

226228
t.Status("running workload")
227229
start = timeutil.Now()
228-
result, err := c.RunWithDetailsSingleNode(ctx, t.L(), option.WithNodes(c.WorkloadNode()), cmd+" run")
230+
result, err := c.RunWithDetailsSingleNode(ctx, t.L(), option.WithNodes(c.WorkloadNode()), roachtestutil.PrefixCmdOutputWithTimestamp(cmd+" run"))
229231

230232
if msg, crashed := detectSysbenchCrash(result); crashed {
231-
t.L().Printf("%s; passing test anyway", msg)
232-
return nil
233+
t.Skipf("%s; skipping test", msg)
233234
}
234235

235236
if err != nil {

0 commit comments

Comments
 (0)