Skip to content

Commit

Permalink
logictest: copy logs before cleaning them up
Browse files Browse the repository at this point in the history
This should allow us to see the testserver logs in the artifacts
directory.

Release note: None
  • Loading branch information
rafiss committed Mar 10, 2023
1 parent 118a95d commit d3186bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/sql/logictest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ go_library(
"//pkg/util",
"//pkg/util/binfetcher",
"//pkg/util/envutil",
"//pkg/util/fileutil",
"//pkg/util/log",
"//pkg/util/randutil",
"//pkg/util/retry",
Expand Down
12 changes: 11 additions & 1 deletion pkg/sql/logictest/logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/util"
"github.com/cockroachdb/cockroach/pkg/util/binfetcher"
"github.com/cockroachdb/cockroach/pkg/util/envutil"
"github.com/cockroachdb/cockroach/pkg/util/fileutil"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/randutil"
"github.com/cockroachdb/cockroach/pkg/util/retry"
Expand Down Expand Up @@ -1320,7 +1321,16 @@ func (t *logicTest) newTestServerCluster(bootstrapBinaryPath string, upgradeBina
}

t.testserverCluster = ts
t.clusterCleanupFuncs = append(t.clusterCleanupFuncs, ts.Stop)
t.clusterCleanupFuncs = append(t.clusterCleanupFuncs, func() {
// The call to ts.Stop() cleans up the cockroach-go testserver logs, so
// we copy them over so we can see them in the artifacts.
src := ts.BaseDir()
dst := filepath.Join(t.sharedIODir, filepath.Base(src))
if err := fileutil.CopyDir(src, dst); err != nil {
t.Fatal(err)
}
ts.Stop()
})

t.setUser(username.RootUser, 0 /* nodeIdx */)
}
Expand Down

0 comments on commit d3186bb

Please sign in to comment.