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

Add helpers to wrap eventmachine use #347

Merged
merged 3 commits into from
Feb 23, 2016

Conversation

richardc
Copy link
Contributor

Here we extract methods to start and stop the eventmachine thread that ruby-pcp-client needs, then add some additional exception handling and state checks to investigate current issues with non-running reactors.

We had some utf-8 spaces, which were causing mild fights with emacs as it
wanted to add a magic comment.
@@ -81,6 +81,40 @@ def get_pcp_broker_status(host)
end
end

# Start an eventmachine reactor in a thread
# @return Thread object where the EM reactor should be running
def start_eventmachine_thread

Choose a reason for hiding this comment

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

Another method name like get_eventmachine_thread would inform readers that this method returns a thread. Then again it wouldn't inform them that that starts a thread...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think 'start' or 'create' are the verbs that fit here, if we were pulling from a pool of threads then I think "get" would fit, but with EventMachine it's a singleton.

Here we extract the common start/stop eventmachine thread blocks
to methods, so we can add some additional debugging to them.
Here we beef up the newly-extracted {start,stop}_eventmachine_thread
helpers to give us more insight as to what's going on with eventmachine.

It should help in diagnosing this class of failing test:

    * On each agent, test that a 2nd association has occurred
    RuntimeError: An Eventmachine reactor needs to be running
    /var/lib/jenkins/workspace/platform_pxp-agent_intn-van-sys_stable/SLAVE_LABEL/beaker/TEST_TARGET/windows2012r2-64a/acceptance/tests/reconnect_after_broker_unavailable.rb:25
    /var/lib/jenkins/workspace/platform_pxp-agent_intn-van-sys_stable/SLAVE_LABEL/beaker/TEST_TARGET/windows2012r2-64a/acceptance/tests/reconnect_after_broker_unavailable.rb:24
    /var/lib/jenkins/workspace/platform_pxp-agent_intn-van-sys_stable/SLAVE_LABEL/beaker/TEST_TARGET/windows2012r2-64a/acceptance/tests/reconnect_after_broker_unavailable.rb:24
    /var/lib/jenkins/workspace/platform_pxp-agent_intn-van-sys_stable/SLAVE_LABEL/beaker/TEST_TARGET/windows2012r2-64a/acceptance/tests/reconnect_after_broker_unavailable.rb:24
    /var/lib/jenkins/workspace/platform_pxp-agent_intn-van-sys_stable/SLAVE_LABEL/beaker/TEST_TARGET/windows2012r2-64a/acceptance/tests/reconnect_after_broker_unavailable.rb:23
    /usr/local/rvm/gems/ruby-2.1.1/gems/beaker-2.34.0/bin/beaker:6
    /usr/local/rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15
    /usr/local/rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15
james-stocks pushed a commit that referenced this pull request Feb 23, 2016
Add helpers to wrap eventmachine use
@james-stocks james-stocks merged commit e076bb0 into puppetlabs:stable Feb 23, 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
Development

Successfully merging this pull request may close these issues.

2 participants