Skip to content

Commit

Permalink
kvnemesis: write debug files using DebuggableTempDir
Browse files Browse the repository at this point in the history
Previously, kvnemesis used os.TempDir() to write the various debug
files (including the repro steps) to a temp dir. When the test failed
on EngFlow, the temp dir was not included in output.zip, which made
tests hard to investigate.

This patch uses datapathutils.DebuggableTempDir() instead. If the test
is running locally, the behavior is the same as os.TempDir(). If the
test is running remotely, it will write the debug files to
TEST_UNDECLARED_OUTPUTS_DIR and Bazel will package them up into
outputs.zip.

Informs: cockroachdb#118005

Release note: None
  • Loading branch information
miraradeva committed Jan 25, 2024
1 parent dc7c41a commit 4e746f3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/kv/kvnemesis/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ go_library(
"//pkg/sql/catalog/bootstrap",
"//pkg/storage",
"//pkg/storage/enginepb",
"//pkg/testutils/datapathutils",
"//pkg/util/bufalloc",
"//pkg/util/ctxgroup",
"//pkg/util/encoding",
Expand Down
3 changes: 2 additions & 1 deletion pkg/kv/kvnemesis/kvnemesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sync/atomic"

"github.com/cockroachdb/cockroach/pkg/kv"
"github.com/cockroachdb/cockroach/pkg/testutils/datapathutils"
"github.com/cockroachdb/cockroach/pkg/util/ctxgroup"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/errors"
Expand Down Expand Up @@ -58,7 +59,7 @@ func l(ctx context.Context, basename string, format string, args ...interface{})
var logger Logger
logger, _ = ctx.Value(loggerKey{}).(Logger)
if logger == nil {
logger = &logLogger{dir: os.TempDir()}
logger = &logLogger{dir: datapathutils.DebuggableTempDir()}
}
logger.Helper()

Expand Down
5 changes: 3 additions & 2 deletions pkg/kv/kvnemesis/kvnemesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/storage/enginepb"
"github.com/cockroachdb/cockroach/pkg/testutils/datapathutils"
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster"
Expand Down Expand Up @@ -221,9 +222,9 @@ type tBridge struct {
func newTBridge(t *testing.T) *tBridge {
// NB: we're not using t.TempDir() because we want these to survive
// on failure.
td, err := os.MkdirTemp("", "kvnemesis")
td, err := os.MkdirTemp(datapathutils.DebuggableTempDir(), "kvnemesis")
if err != nil {
td = os.TempDir()
td = datapathutils.DebuggableTempDir()
}
t.Cleanup(func() {
if t.Failed() {
Expand Down

0 comments on commit 4e746f3

Please sign in to comment.