Permalink
Browse files

(#14297) Update upstart provider acceptance tests

Previously this test would grep the status output to determine the status of
the service. That works for upstart services, but not for init style services.
For those the return code of status must be checked. This commit adds a wrapper
function to handle using the right method to determine the service status.
  • Loading branch information...
1 parent 3c5ef40 commit f5d1f74de754d1e12854a0102a9073f3277a9d62 @haus committed May 25, 2012
Showing with 15 additions and 3 deletions.
  1. +15 −3 acceptance/tests/resource/service/ticket_14297_handle_upstart.rb
@@ -6,6 +6,18 @@
# pick any ubuntu agent
agent = agents.first
+def check_service_for(pkg, type)
+ if pkg == "apache2"
+ if type == "stop"
+ on agent, "service #{pkg} status", :acceptable_exit_codes => [1,2,3]
+ else
+ on agent, "service #{pkg} status", :acceptable_exit_codes => [0]
+ end
+ else
+ on agent, "service #{pkg} status | grep #{type} -q"
+ end
+end
+
# in Precise these packages provide a mix of upstart with no linked init
# script (tty1), upstart linked to an init script (rsyslog), and no upstart
# script - only an init script (apache2)
@@ -16,19 +28,19 @@
on agent, "service #{pkg} start", :acceptable_exit_codes => [0,1]
step "Check that status for running #{pkg}"
- on agent, "service #{pkg} status | grep start -q"
+ check_service_for(pkg, "start")
step "Stop #{pkg} with `puppet resource'"
on agent, puppet_resource("service #{pkg} ensure=stopped")
step "Check that status for stopped #{pkg}"
- on agent, "service #{pkg} status | grep stop -q"
+ check_service_for(pkg, "stop")
step "Start #{pkg} with `puppet resource'"
on agent, puppet_resource("service #{pkg} ensure=running")
step "Check that status for started #{pkg}"
- on agent, "service #{pkg} status | grep start -q"
+ check_service_for(pkg, "start")
on agent, puppet_resource("package #{pkg} ensure=absent")
end

0 comments on commit f5d1f74

Please sign in to comment.