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

worker/terminationworker: fix test hang #5528

Merged
merged 2 commits into from Jun 3, 2016
Merged

worker/terminationworker: fix test hang #5528

merged 2 commits into from Jun 3, 2016

Conversation

davecheney
Copy link
Contributor

@davecheney davecheney commented Jun 3, 2016

Fixes LP 1588135

Fix a race on the ownership of the abort signal.

The TestSignal test attempts to see if sending SIGABRT to the test
binary itself will cause the worker to unblock itself and exit as
exited. However, as the original author discovered there is a race
between sending the signal and the worker spawned from NewWorker
registering a handler to catch SIGABRT. If the handler was not registered
in time the SIGABRT would cause the test process to exit.

To fix this problem they set up a SIGABRT handler in SetUpTest to ensure
that SIGABRT was always handled. However this meant that if NewWorker's
handler was not registered in time to catch the signal, it would be
delivered to the channel registered by SetUpTest, causing the test binary
to hang.

The fix is to remove the SetUpTest workaround and ensure the handler is
always registered before spawning the loop goroutine so the caller is
assured that once NewWorker has returned, the handler is in place and it
is safe to send the signal.

This PR also removes unnecessary use of testing.BaseSuite.

(Review request: http://reviews.vapour.ws/r/4975/)

Fixes LP 1588135

Fix a race on the ownership of the abort signal.

The TestSignal test attempts to see if sending the SIGABRT to the test
binary itself will cause the worker to unblock itself and exit as
exited. However, as the original author discovered there is a race
between sending the signal and the worker spawned from NewWorker
registering a handler to catch SIGABRT. If the hander was not registered
in time the SIGABRT would cause the test process to exit.

To fix this problem they set up a SIGABRT handler in SetUpTest to ensure
that SIGABRT was always handled. However this meant that if NewWorker's
handler was not registered in time to catch the signal, it would be
delivered to the channel registed by SetUpTest, causing the test binary
to hang.

The fix is to remove the SetUpTest workaround and ensure the handler is
always registered before spawning the loop goroutine so the caller is
assured that once NewWorker has returned, the handler is in place and it
is safe to send the signal.

This PR also removes unnecessary use of testing.BaseSuite.
@davecheney
Copy link
Contributor Author

$$fixes-1588135$$

@jujubot
Copy link
Collaborator

jujubot commented Jun 3, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot
Copy link
Collaborator

jujubot commented Jun 3, 2016

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/7972

@davecheney
Copy link
Contributor Author

$$fixes-1588135$$

@jujubot
Copy link
Collaborator

jujubot commented Jun 3, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit bfa4702 into juju:master Jun 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants