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

ci: add 'go test -race' #8269

Merged
merged 1 commit into from
Jul 17, 2020
Merged

ci: add 'go test -race' #8269

merged 1 commit into from
Jul 17, 2020

Conversation

dnephin
Copy link
Contributor

@dnephin dnephin commented Jul 8, 2020

I tried -race on all the packages (example) but there were many failures. I expect it to add a lot of time to CI, but it actually ran in pretty reasonable time.

Since there were over 100 failures, I'm hoping we can get this enabled on a smaller number of packages with a few fixes and opt more in over time.

-race also enables -d=checkptr (ref), which fails in the boltdb package. It looks like this was still an issue with bbolt until very recently (etcd-io/bbolt#187, etcd-io/bbolt#201). So for now that check is disabled.

There are still a bunch of failures in the smaller list of packages. I need to look over those failures to see if we should drop some of the packages from the list. Making this a draft PR until CI is green.

@dnephin dnephin mentioned this pull request Jul 17, 2020
10 tasks
@dnephin dnephin force-pushed the dnephin/ci-add-go-test-race branch from c077a05 to 6bc675c Compare July 17, 2020 16:49
@dnephin dnephin marked this pull request as ready for review July 17, 2020 16:55
@dnephin dnephin added the type/ci Relating to continuous integration (CI) tooling for testing or releases label Jul 17, 2020
@dnephin dnephin requested review from alvin-huang and a team July 17, 2020 16:59
# but we can run a little over that limit.
steps:
- checkout
- run: *install_gotestsum
Copy link
Collaborator

Choose a reason for hiding this comment

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

this will conflict with #8327 sorry!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries! Luckily it does not appear to conflict

Copy link
Collaborator

Choose a reason for hiding this comment

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

It might not conflict but it won't work properly when merged so you'll have to rebase since install_gotestsum doesn't exist anymore in master

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right! The alias is a dash now, not an underscore. I missed that! I'll rebase now

--junitfile $TEST_RESULTS_DIR/gotestsum-report.xml -- \
-tags="$GOTAGS" -p 2 \
-race -gcflags=all=-d=checkptr=0 \
./agent/{ae,cache,checks,config,pool,proxycfg,router} \
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is great! Even though we may be more prescriptive here, it allows us to incrementally fix package by package and get incremental improvements.

@alvin-huang
Copy link
Collaborator

Were you able to fix the failures in your initial test of adding the data race check or did you just filter them out of the package list to test for now?

Curious but in your testing did you see GOMAXPROCS have an affect on the race detector? ie: Does the overhead of running the race detector make any tests more flaky or OOM?

Copy link
Collaborator

@alvin-huang alvin-huang left a comment

Choose a reason for hiding this comment

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

LGTM!

@dnephin
Copy link
Contributor Author

dnephin commented Jul 17, 2020

Were you able to fix the failures in your initial test of adding the data race check or did you just filter them out of the package list to test for now?

No fixes yet. For now I filtered out the packages and tracked them in #8329. I wanted to enable this for the new agent/consul/stream package which I just merged. I'll probably try to fix one or two of these races a week and get more packages included.

Curious but in your testing did you see GOMAXPROCS have an affect on the race detector? ie: Does the overhead of running the race detector make any tests more flaky or OOM?

I did not experiment with GOMAXPROCS at all. I copied the setting from the go-test job, since it seemed appropriate here too. The only information I have about resource usage is from what I read here: https://golang.org/doc/articles/race_detector.html#Runtime_Overheads. So far it seems to run pretty fast on these packages and not cause any problems, but I expect agent and agent/consul to cause some problems.

Running every test with the race detector would add significant time to
CI. That additionaltime won't provide much value as many of the integration tests use
much of the same code.

For now we can run -race on some of the smaller packages. As we move
more code into smaller packages we should be able to add more packages
to the list that runs with '-race'.

For now this is running without parallelism, but we can enable that as
well when we need it.

boltdb fails the 'checkptr' check, which is automatically enabled by
'-race', so I've disabled checkptr as well.
@dnephin dnephin force-pushed the dnephin/ci-add-go-test-race branch from 6bc675c to 099000e Compare July 17, 2020 17:32
@dnephin dnephin merged commit e07b20e into master Jul 17, 2020
@dnephin dnephin deleted the dnephin/ci-add-go-test-race branch July 17, 2020 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/ci Relating to continuous integration (CI) tooling for testing or releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants