worker/terminationworker: fix test hang #5528

Merged
merged 2 commits into from Jun 3, 2016

Conversation

Projects
None yet
2 participants
Contributor

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/)

davecheney added some commits Jun 3, 2016

worker/terminationworker: fix test hang`
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.
Contributor

davecheney commented Jun 3, 2016

$$fixes-1588135$$

Contributor

jujubot commented Jun 3, 2016

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

Contributor

jujubot commented Jun 3, 2016

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

Contributor

davecheney commented Jun 3, 2016

$$fixes-1588135$$

Contributor

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