Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Unittests: locking fixes and race hunting #437

Merged
merged 7 commits into from
Aug 7, 2016

Conversation

tpepper
Copy link

@tpepper tpepper commented Aug 5, 2016

This PR enables -race in the test-utils helper and toggles it on for non-controller tests in travis (controller has known races). Some observed bugs in testutil's results channels' locking is cleaned up.

Fixes Issue #235

Tim Pepper added 7 commits August 4, 2016 17:22
A Shutdown() helper is added to the testutil clients and server in order to
handle teardown of the SSNTP session and closing the testutil results
channels.

This should prevent channel writers that are blocked from causing
goroutine leaks across test cases.

Signed-off-by: Tim Pepper <[email protected]>
The prior commit added a CloseChans() helper, which didn't have explicit
coverage.  Adding coverage for it points out that it's actually important
to not leave the channels closed in unit tests.  And then too these helpers
do not need exported generally, but do need exported for test.

Signed-off-by: Tim Pepper <[email protected]>
The code to put a result on a channel checks to see that something has
posted as awaiting a result for the given command/event/error/status
before writing to the channel to avoid writing to a non-existing channel.
That can still write to a closed channel if the closed channel is not
removed from the map.

Signed-off-by: Tim Pepper <[email protected]>
The other testutil ssntp actors are all dealt with via references.  This
should be consistent and insures something isn't inadvertantly acting on a
copy of the server state.

Signed-off-by: Tim Pepper <[email protected]>
The locking on the testutil results channels was incorrect.  The channel
writers block and do so with a lock held.  That's a major no-no.  Defering
a lock unlock seems nice a clean...unlock noted immediately after a lock.
But then you might block and sleep.

To straighten this out, the locks need initialized once at the time the
ssntp test actor is created.  Only the channel maps get modified inside the
channel close/open helpers, and those only do such modificiations with the
appropriate lock held.

Signed-off-by: Tim Pepper <[email protected]>
Controller still has races, but I think other things are mostly clean.
Let's test that theory with data by adding -race to the options for
non-controller tests.

Signed-off-by: Tim Pepper <[email protected]>
The -race option is useful and should pass through to the 'go test'
invocation if specified on the test-cases command line.

Signed-off-by: Tim Pepper <[email protected]>
@coveralls
Copy link

coveralls commented Aug 5, 2016

Coverage Status

Coverage increased (+0.07%) to 65.419% when pulling e9e316b on tpepper:unittests into 56930ea on 01org:master.

@sameo sameo merged commit 981bb66 into ciao-project:master Aug 7, 2016
@sameo sameo removed the in progress label Aug 7, 2016
@kaccardi
Copy link
Contributor

Failure rate as of 8/11: 4/30

Failures occurred 100% using go 1.6 (vs. tip).

Log of Failures:
https://travis-ci.org/kaccardi/ciao/jobs/151559516

  • timeout in launcher tests and scheduler tests

https://travis-ci.org/kaccardi/ciao/jobs/151574113

  • a data race detected in ciao-scheduler tests

https://travis-ci.org/kaccardi/ciao/jobs/151574946

https://travis-ci.org/kaccardi/ciao/jobs/151574430

@tpepper tpepper deleted the unittests branch August 29, 2016 16:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants