Testing service is running
Closed this issue · 7 comments
Hi,
I'm getting unexpected results when using the assertion:
service("newrelic-sysmond").must_be_running
This is on ubuntu 11.10. The assertion works with a different service but not the one above. Logging on to the machine it shows up
root@jperry-vagrant-ubuntu-box:~# service newrelic-sysmond status
New Relic Server Monitor: newrelic-sysmond is running
Any help would be great.
Thanks,
Jay
Hi guys,
It looks like Chef isn't running the status command because the new resource we use to load the current state doesn't have status
in its list of supported actions.
Can you let me know if this works?
s = service("newrelic-sysmond")
s.supports([:status])
::Chef::Platform.provider_for_resource(s).load_current_resource.must_be_running
Thanks,
Andrew
Hi Andrew,
I get this when I run the commands you mention:
1) Error:
test_0003_should_start_the_newrelic_sysmond_service(recipe::newrelic::default):
ArgumentError: Cannot find the provider for a resource with no run context set
/var/lib/gems/1.9.1/gems/chef-0.10.8/lib/chef/platform.rb:319:in `provider_for_resource'
/var/chef/minitest/newrelic/newrelic_test.rb:44:in `block (2 levels) in <class:NewrelicSpec>'
You have access to the run_context
from minitest-chef-handler so you can provide that:
s.run_context = run_context
That should get you working but we will need to fix this in minitest-chef-handler to avoid the need for the workaround.
Are you suggesting it would look like this then
s = service("newrelic-sysmond")
s.supports([:status])
s.run_context = run_context
::Chef::Platform.provider_for_resource(s).load_current_resource.must_be_running
Yes - that should work if you try it. It's a kludge until we patch minitest-chef-handler.
Okay, I'll give it a try. Thanks!