summaryrefslogtreecommitdiff
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
parent36e47f7ae592e753149928a2a754d5e6f5abf74f (diff)
tests: check process by either process scan or service name. closes #8753
-rw-r--r--tests/server-tests/helpers/os_helper.rb28
-rw-r--r--tests/server-tests/white-box/couchdb.rb4
-rw-r--r--tests/server-tests/white-box/mx.rb20
-rw-r--r--tests/server-tests/white-box/openvpn.rb6
-rw-r--r--tests/server-tests/white-box/soledad.rb2
-rw-r--r--tests/server-tests/white-box/webapp.rb4
6 files changed, 41 insertions, 23 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
diff --git a/tests/server-tests/white-box/couchdb.rb b/tests/server-tests/white-box/couchdb.rb
index 44a2769b..dcf71bc7 100644
--- a/tests/server-tests/white-box/couchdb.rb
+++ b/tests/server-tests/white-box/couchdb.rb
@@ -9,9 +9,9 @@ class CouchDB < LeapTest
end
def test_00_Are_daemons_running?
- assert_running 'bin/beam'
+ assert_running match: 'bin/beam'
if multimaster?
- assert_running 'bin/epmd'
+ assert_running match: 'bin/epmd'
end
pass
end
diff --git a/tests/server-tests/white-box/mx.rb b/tests/server-tests/white-box/mx.rb
index ecc8686c..432f4e54 100644
--- a/tests/server-tests/white-box/mx.rb
+++ b/tests/server-tests/white-box/mx.rb
@@ -52,17 +52,17 @@ class Mx < LeapTest
end
def test_04_Are_MX_daemons_running?
- assert_running '.*/usr/bin/twistd.*mx.tac'
- assert_running '^/usr/lib/postfix/master$'
- assert_running '^/usr/sbin/postfwd'
- assert_running 'postfwd2::cache$'
- assert_running 'postfwd2::policy$'
- assert_running '^/usr/sbin/unbound'
- assert_running '^/usr/bin/freshclam'
- assert_running '^/usr/sbin/opendkim'
+ assert_running match: '.*/usr/bin/twistd.*mx.tac'
+ assert_running match: '^/usr/lib/postfix/master$'
+ assert_running match: '^/usr/sbin/postfwd'
+ assert_running match: 'postfwd2::cache$'
+ assert_running match: 'postfwd2::policy$'
+ assert_running match: '^/usr/sbin/unbound'
+ assert_running match: '^/usr/bin/freshclam'
+ assert_running match: '^/usr/sbin/opendkim'
if Dir.glob("/var/lib/clamav/main.{c[vl]d,inc}").size > 0 and Dir.glob("/var/lib/clamav/daily.{c[vl]d,inc}").size > 0
- assert_running '^/usr/sbin/clamd'
- assert_running '^/usr/sbin/clamav-milter'
+ assert_running match: '^/usr/sbin/clamd'
+ assert_running match: '^/usr/sbin/clamav-milter'
pass
else
skip "Downloading the clamav signature files (/var/lib/clamav/{daily,main}.{c[vl]d,inc}) is still in progress, so clamd is not running."
diff --git a/tests/server-tests/white-box/openvpn.rb b/tests/server-tests/white-box/openvpn.rb
index d5cc2265..4eed7eb9 100644
--- a/tests/server-tests/white-box/openvpn.rb
+++ b/tests/server-tests/white-box/openvpn.rb
@@ -7,9 +7,9 @@ class OpenVPN < LeapTest
end
def test_01_Are_daemons_running?
- assert_running '^/usr/sbin/openvpn .* /etc/openvpn/tcp_config.conf$'
- assert_running '^/usr/sbin/openvpn .* /etc/openvpn/udp_config.conf$'
- assert_running '^/usr/sbin/unbound'
+ assert_running match: '^/usr/sbin/openvpn .* /etc/openvpn/tcp_config.conf$'
+ assert_running match: '^/usr/sbin/openvpn .* /etc/openvpn/udp_config.conf$'
+ assert_running match: '^/usr/sbin/unbound'
pass
end
diff --git a/tests/server-tests/white-box/soledad.rb b/tests/server-tests/white-box/soledad.rb
index b89145bc..112d6b9b 100644
--- a/tests/server-tests/white-box/soledad.rb
+++ b/tests/server-tests/white-box/soledad.rb
@@ -10,7 +10,7 @@ class Soledad < LeapTest
end
def test_00_Is_Soledad_running?
- assert_running '/usr/bin/python /usr/bin/twistd --uid=soledad --gid=soledad --pidfile=/var/run/soledad.pid --syslog --prefix=soledad-server web --class=leap.soledad.server.resource.SoledadResource.*'
+ assert_running service: 'soledad-server'
pass
end
diff --git a/tests/server-tests/white-box/webapp.rb b/tests/server-tests/white-box/webapp.rb
index c46c9f96..e48df524 100644
--- a/tests/server-tests/white-box/webapp.rb
+++ b/tests/server-tests/white-box/webapp.rb
@@ -27,8 +27,8 @@ class Webapp < LeapTest
end
def test_03_Are_daemons_running?
- assert_running '^/usr/sbin/apache2'
- assert_running 'ruby /usr/bin/nickserver'
+ assert_running match: '^/usr/sbin/apache2'
+ assert_running match: 'ruby /usr/bin/nickserver'
pass
end