summaryrefslogtreecommitdiff
path: root/tests/server-tests/helpers/os_helper.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2017-02-09 16:34:56 -0800
committerelijah <elijah@riseup.net>2017-02-09 16:34:56 -0800
commit9e68982b4ef8af087e8792e502d37632d1a9a0e8 (patch)
treec5a9d8e24ac3c498972fa25ecded9b0eb5e0dd90 /tests/server-tests/helpers/os_helper.rb
parent36e47f7ae592e753149928a2a754d5e6f5abf74f (diff)
tests: check process by either process scan or service name. closes #8753
Diffstat (limited to 'tests/server-tests/helpers/os_helper.rb')
-rw-r--r--tests/server-tests/helpers/os_helper.rb28
1 files changed, 23 insertions, 5 deletions
diff --git a/tests/server-tests/helpers/os_helper.rb b/tests/server-tests/helpers/os_helper.rb
index 9923d5b1..6a71388c 100644
--- a/tests/server-tests/helpers/os_helper.rb
+++ b/tests/server-tests/helpers/os_helper.rb
@@ -20,11 +20,29 @@ class LeapTest
}.compact
end
- def assert_running(process, options={})
- processes = pgrep(process)
- assert processes.any?, "No running process for #{process}"
- if options[:single]
- assert processes.length == 1, "More than one process for #{process}"
+ #
+ # passes if the specified process is runnin.
+ #
+ # arguments:
+ #
+ # match => VALUE -- scan process table for VALUE
+ # service => VALUE -- call systemctl is-active VALUE
+ #
+ # single => true|false -- if true, there must be one result
+ #
+ def assert_running(match:nil, service:nil, single:false)
+ if match
+ processes = pgrep(match)
+ assert processes.any?, "No running process for #{match}"
+ if single
+ assert processes.length == 1, "More than one process for #{match}"
+ end
+ elsif service
+ `systemctl is-active #{service} 2>&1`
+ if $?.exitstatus != 0
+ output = `systemctl status #{service} 2>&1`
+ fail "Service '#{service}' is not running:\n#{output}"
+ end
end
end