Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log: use fake stacktrace when test-exiting #27329

Merged
merged 1 commit into from
Jul 10, 2018

Conversation

tbg
Copy link
Member

@tbg tbg commented Jul 10, 2018

Having stack traces littered across tests has been a long-standing pet
peeve of mine (and presumably others). We search through logs more often
than we would like to admit, and having to skip a number of intentional
stack traces is annoying.

Make it so that whenever the logging exit func is mocked, the stack
trace indicates that.

Release note: None

@tbg tbg requested a review from a team as a code owner July 10, 2018 12:15
@tbg tbg requested review from a team July 10, 2018 12:15
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@tbg tbg force-pushed the fix/testing-stack-traces branch from 022199e to 21f2f6a Compare July 10, 2018 12:26
Copy link
Contributor

@benesch benesch left a comment

Choose a reason for hiding this comment

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

It just occurred to me: I think it would be cleaner to split this into two APIs. What we really want is an atexit callback for non tests, and an exit func override for tests. The atexit callback should not be able to prevent the exit, nor should it be responsible for issuing the os.Exit call; it should just run some cleanup code.

:lgtm: though

Reviewed 11 of 11 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)


pkg/util/log/clog.go, line 695 at r1 (raw file):

	exitOverride struct {
		f         func(int) // overrides os.Exit when non-nil; testing only
		hideStack bool      // hides stack trace; only in effect when f is nil

when f is non-nil, no?


pkg/util/log/clog.go, line 857 at r1 (raw file):

			// We're running in a test. It's a little dirty that we're detecting
			// this here, but we definitely don't want to litter stacktraces in
			// the test output when there isn't anything going wrong.

I'm confused by this comment. f can be non-nil outside of tests.


pkg/util/log/clog_test.go, line 97 at r1 (raw file):

// setFlags resets the logging flags and exit function to what tests expect.
func setFlags() {
	SetExitFunc(false, nil)

This would read much more nicely as ResetExitFunc().


pkg/util/log/clog_test.go, line 701 at r1 (raw file):

	setFlags()
	logging.stderrThreshold = Severity_NONE
	SetExitFunc(false, func(int) {})

/* hideStack */


pkg/util/log/log.go, line 53 at r1 (raw file):

	if f == nil && hideStack {
		panic("can't pass hideStack when resetting logger")
	}

Maybe introduce ResetExitFunc() that does the right thing?

@tbg tbg force-pushed the fix/testing-stack-traces branch from 21f2f6a to 19bab42 Compare July 10, 2018 19:17
Copy link
Member Author

@tbg tbg left a comment

Choose a reason for hiding this comment

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

TFTR! I introduced ResetExitFunc but stopped shy of the two separate APIs (started but realized it wasn't worth it for the three obscure users).

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained


pkg/util/log/clog.go, line 695 at r1 (raw file):

Previously, benesch (Nikhil Benesch) wrote…

when f is non-nil, no?

Done.


pkg/util/log/clog.go, line 857 at r1 (raw file):

Previously, benesch (Nikhil Benesch) wrote…

I'm confused by this comment. f can be non-nil outside of tests.

Done. The comment predates my finding out this was the case.

Copy link
Contributor

@benesch benesch left a comment

Choose a reason for hiding this comment

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

Reviewed 7 of 7 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)

@tbg tbg force-pushed the fix/testing-stack-traces branch from 19bab42 to 468a694 Compare July 10, 2018 19:43
Having stack traces littered across tests has been a long-standing pet
peeve of mine (and presumably others). We search through logs more often
than we would like to admit, and having to skip a number of intentional
stack traces is annoying.

Make it so that whenever the logging exit func is mocked, the stack
trace indicates that.

Release note: None
@tbg tbg force-pushed the fix/testing-stack-traces branch from 468a694 to a6aa1ff Compare July 10, 2018 20:38
@tbg
Copy link
Member Author

tbg commented Jul 10, 2018

bors r=benesch

craig bot pushed a commit that referenced this pull request Jul 10, 2018
27262: ui: require yarn >= 1.7.0 r=benesch,vilterp a=tschottdorf

Builds before the upgrade failed mysteriously.
@benesch (cc) suspects a bug in older versions of yarn.

```
$ make build
Running make with -j8
GOPATH set to /Users/tschottdorf/go
build/node-run.sh -C pkg/ui yarn install --offline
(echo "// Code generated by goyacc. DO NOT EDIT."; \
     echo "// GENERATED FILE DO NOT EDIT"; \
     cat pkg/sql/parser/gen/sql.go.tmp | \
     sed -E 's/^const ([A-Z][_A-Z0-9]*) =.*$/const \1 = lex.\1/g') > pkg/sql/parser/sql.go.tmp || rm pkg/sql/parser/sql.go.tmp
(echo "// Code generated by make. DO NOT EDIT."; \
     echo "// GENERATED FILE DO NOT EDIT"; \
     echo; \
     echo "package lex"; \
     echo; \
     grep '^const [A-Z][_A-Z0-9]* ' pkg/sql/parser/gen/sql.go.tmp) > pkg/sql/lex/tokens.go.tmp || rm pkg/sql/lex/tokens.go.tmp
mv -f pkg/sql/lex/tokens.go.tmp pkg/sql/lex/tokens.go
mv -f pkg/sql/parser/sql.go.tmp pkg/sql/parser/sql.go
yarn install v1.6.0
(node:50064) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[1/5] Validating package.json...
go install -v docgen
bin/prereqs ./pkg/cmd/docgen > bin/docgen.d.tmp
[2/5] Resolving packages...
mv -f bin/docgen.d.tmp bin/docgen.d
[3/5] Fetching packages...
build/node-run.sh pkg/ui/bin/gen-protobuf-cli-deps.js > pkg/ui/node_modules/protobufjs/cli/package.json
bash: pkg/ui/node_modules/protobufjs/cli/package.json: No such file or directory
make: *** [pkg/ui/yarn.installed] Error 1
make: *** Waiting for unfinished jobs....
```

Release note (general change): the build now requires yarn at version
1.7.0 or above, to work around yarnpkg/yarn#5761.

27307: storage: return TransactionRetryError from QueryIntent on pushed intent r=nvanbenschoten a=nvanbenschoten

Extracted from #26599.

This change adjusts how QueryIntent handles pushed intents. First, it
changes how pushed intents interact with SNAPSHOT transactions. Next,
it makes sure to update the response transaction in the case of pushed
intents. Finally, it returns a RETRY_SERIALIZABLE TransactionRetryError
for SERIALIZABLE transactions who observe a pushed intent with the
RETURN_ERROR behavior.

Release note: None

27329: log: use fake stacktrace when test-exiting r=benesch a=tschottdorf

Having stack traces littered across tests has been a long-standing pet
peeve of mine (and presumably others). We search through logs more often
than we would like to admit, and having to skip a number of intentional
stack traces is annoying.

Make it so that whenever the logging exit func is mocked, the stack
trace indicates that.

Release note: None

27348: engine: fix RocksDBBatchReader example comment r=nvanbenschoten a=nvanbenschoten

Release note: None

Co-authored-by: Tobias Schottdorf <[email protected]>
Co-authored-by: Nathan VanBenschoten <[email protected]>
@craig
Copy link
Contributor

craig bot commented Jul 10, 2018

Build succeeded

@craig craig bot merged commit a6aa1ff into cockroachdb:master Jul 10, 2018
@tbg tbg deleted the fix/testing-stack-traces branch July 26, 2018 09:49
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.

3 participants