Skip to content

util/log: Avoid logging output on stderr under go test -bench#59054

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
knz:20210115-test-bench
Jan 15, 2021
Merged

util/log: Avoid logging output on stderr under go test -bench#59054
craig[bot] merged 1 commit intocockroachdb:masterfrom
knz:20210115-test-bench

Conversation

@knz
Copy link
Copy Markdown
Contributor

@knz knz commented Jan 15, 2021

Fixes #57979

We have found that logging output can interleave with benchmark
results, which makes it awkward to run benchstat and the like on the
output.

This change ensures that log.Scope disables stderr logging for
benchmarks.

Release note: None

@knz knz requested review from mgartner and yuzefovich January 15, 2021 17:47
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 3 of 3 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @knz and @mgartner)


pkg/testutils/skip/skip.go, line 104 at r1 (raw file):

// UnderBench returns true iff a test is currently running under `go
// test -bench`.  When true, tests should avoid writing data on

super nit: seems like a double space before When.

Copy link
Copy Markdown
Contributor

@mgartner mgartner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. If you want you can remove what looks like an unnecessary bit of commented code in test_log_scope.go while you're modifying that file:

// t.Logf("restored configuration:\n%s", restoredConfig)

Copy link
Copy Markdown
Contributor Author

@knz knz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want you can remove what looks like an unnecessary bit of commented code in test_log_scope.go

Done

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @yuzefovich)


pkg/testutils/skip/skip.go, line 104 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

super nit: seems like a double space before When.

https://www.theatlantic.com/science/archive/2018/05/two-spaces-after-a-period/559304/

@knz
Copy link
Copy Markdown
Contributor Author

knz commented Jan 15, 2021

Thanks to both!

bors r=mgartner,yuzefovich

Copy link
Copy Markdown
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workspace is dirty:

[18:29:30][Step 6/6] --- a/pkg/util/log/BUILD.bazel
[18:29:30][Step 6/6] +++ b/pkg/util/log/BUILD.bazel
[18:29:30][Step 6/6] @@ -44,6 +44,7 @@ go_library(
[18:29:30][Step 6/6]      deps = [
[18:29:30][Step 6/6]          "//pkg/build",
[18:29:30][Step 6/6]          "//pkg/cli/exit",
[18:29:30][Step 6/6] +        "//pkg/testutils/skip",
[18:29:30][Step 6/6]          "//pkg/util",
[18:29:30][Step 6/6]          "//pkg/util/caller",
[18:29:30][Step 6/6]          "//pkg/util/encoding/encodingtype",

bors r-

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @knz and @yuzefovich)


pkg/testutils/skip/skip.go, line 104 at r1 (raw file):

Previously, knz (kena) wrote…

https://www.theatlantic.com/science/archive/2018/05/two-spaces-after-a-period/559304/

Oh, interesting, I'll take a look, thanks.

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 15, 2021

Canceled.

We have found that logging output can interleave with benchmark
results, which makes it awkward to run `benchstat` and the like on the
output.

This change ensures that log.Scope disables stderr logging for
benchmarks.

Release note: None
@knz knz force-pushed the 20210115-test-bench branch from 20cd305 to f14e506 Compare January 15, 2021 18:51
@knz
Copy link
Copy Markdown
Contributor Author

knz commented Jan 15, 2021

ah good catch. Fixed. I'll wait for this to be green before merging.

@knz
Copy link
Copy Markdown
Contributor Author

knz commented Jan 15, 2021

it's green now

bors r=mgartner,yuzefovich

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 15, 2021

Build succeeded:

@craig craig bot merged commit b4dfbbe into cockroachdb:master Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

log: suppressing logs with -logtostderr=false no longer works in benchmarks

4 participants