diff --git a/pkg/cmd/roachtest/BUILD.bazel b/pkg/cmd/roachtest/BUILD.bazel index 299a80d83dc4..db9673827dd8 100644 --- a/pkg/cmd/roachtest/BUILD.bazel +++ b/pkg/cmd/roachtest/BUILD.bazel @@ -51,9 +51,6 @@ go_library( "//pkg/util/ctxgroup", "//pkg/util/httputil", "//pkg/util/leaktest", - "//pkg/util/log", - "//pkg/util/log/logconfig", - "//pkg/util/log/logpb", "//pkg/util/quotapool", "//pkg/util/randutil", "//pkg/util/stop", diff --git a/pkg/cmd/roachtest/run.go b/pkg/cmd/roachtest/run.go index cde38acb5b42..a8aa6cc881be 100644 --- a/pkg/cmd/roachtest/run.go +++ b/pkg/cmd/roachtest/run.go @@ -29,9 +29,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/roachprod/logger" "github.com/cockroachdb/cockroach/pkg/util/allstacks" "github.com/cockroachdb/cockroach/pkg/util/leaktest" - "github.com/cockroachdb/cockroach/pkg/util/log" - "github.com/cockroachdb/cockroach/pkg/util/log/logconfig" - "github.com/cockroachdb/cockroach/pkg/util/log/logpb" "github.com/cockroachdb/cockroach/pkg/util/stop" "github.com/cockroachdb/cockroach/pkg/util/timeutil" "github.com/cockroachdb/errors" @@ -142,7 +139,8 @@ func runTests(register func(registry.Registry), filter *registry.TestFilter) err roachprod.ClearClusterCache = roachtestflags.ClearClusterCache - setLogConfig(artifactsDir) + redirectLogger := redirectCRDBLogger(context.Background(), filepath.Join(artifactsDir, "roachtest.crdb.log")) + logger.InitCRDBLogConfig(redirectLogger) runnerDir := filepath.Join(artifactsDir, runnerLogsDir) runnerLogPath := filepath.Join( runnerDir, fmt.Sprintf("test_runner-%d.log", timeutil.Now().Unix())) @@ -213,20 +211,6 @@ func runTests(register func(registry.Registry), filter *registry.TestFilter) err return err } -// This diverts all the default non-fatal logging to a file in `baseDir`. This is particularly -// useful in CI, where without this, stderr/stdout are cluttered with logs from various -// packages used in roachtest like sarama and testutils. -func setLogConfig(baseDir string) { - logConf := logconfig.DefaultStderrConfig() - logConf.Sinks.Stderr.Filter = logpb.Severity_FATAL - if err := logConf.Validate(&baseDir); err != nil { - panic(err) - } - if _, err := log.ApplyConfig(logConf, nil /* fileSinkMetricsForDir */, nil /* fatalOnLogStall */); err != nil { - panic(err) - } -} - // getUser takes the value passed on the command line and comes up with the // username to use. func getUser(userFlag string) string { @@ -377,6 +361,17 @@ func testRunnerLogger( return l, teeOpt } +func redirectCRDBLogger(ctx context.Context, path string) *logger.Logger { + verboseCfg := logger.Config{} + var err error + l, err := verboseCfg.NewLogger(path) + if err != nil { + panic(err) + } + shout(ctx, l, os.Stdout, "fallback runner logs in: %s", path) + return l +} + func maybeDumpSummaryMarkdown(r *testRunner) error { if !roachtestflags.GitHubActions { return nil