root / test / daemon-util_unittest.bash @ 12eff9b9
History | View | Annotate | Download (2.2 kB)
1 |
#!/bin/bash |
---|---|
2 |
# |
3 |
|
4 |
# Copyright (C) 2010 Google Inc. |
5 |
# |
6 |
# This program is free software; you can redistribute it and/or modify |
7 |
# it under the terms of the GNU General Public License as published by |
8 |
# the Free Software Foundation; either version 2 of the License, or |
9 |
# (at your option) any later version. |
10 |
# |
11 |
# This program is distributed in the hope that it will be useful, but |
12 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
# General Public License for more details. |
15 |
# |
16 |
# You should have received a copy of the GNU General Public License |
17 |
# along with this program; if not, write to the Free Software |
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
19 |
# 02110-1301, USA. |
20 |
|
21 |
set -e |
22 |
|
23 |
daemon_util=daemons/daemon-util |
24 |
|
25 |
err() { |
26 |
echo "$@" |
27 |
echo 'Aborting' |
28 |
exit 1 |
29 |
} |
30 |
|
31 |
$daemon_util >/dev/null 2>&1 && |
32 |
err "daemon-util succeeded without command" |
33 |
|
34 |
$daemon_util this-is-an-unimplemented-command >/dev/null 2>&1 && |
35 |
err "daemon-util accepted unimplemented command" |
36 |
|
37 |
$daemon_util list_start_daemons >/dev/null 2>&1 && |
38 |
err "daemon-util accepted command with underscores" |
39 |
|
40 |
$daemon_util check-exitcode 0 || |
41 |
err "check-exitcode 0 failed" |
42 |
|
43 |
for i in 1 2 3 4 20 25 33; do |
44 |
$daemon_util check-exitcode $i >/dev/null 2>&1 && rc=0 || rc=$? |
45 |
test "$rc" == 1 || err "check-exitcode $i didn't return 1" |
46 |
done |
47 |
|
48 |
$daemon_util check-exitcode 11 >/dev/null 2>&1 || |
49 |
err "check-exitcode 11 (not master) didn't return 0" |
50 |
|
51 |
tmp=$(echo $($daemon_util list-start-daemons)) |
52 |
test "$tmp" == "$(echo ganeti-{noded,masterd,rapi,confd})" || |
53 |
err "list-start-daemons didn't return correct list of daemons" |
54 |
|
55 |
tmp=$(echo $($daemon_util list-stop-daemons)) |
56 |
test "$tmp" == "$(echo ganeti-{confd,rapi,masterd,noded})" || |
57 |
err "list-stop-daemons didn't return correct list of daemons" |
58 |
|
59 |
$daemon_util is-daemon-name >/dev/null 2>&1 && |
60 |
err "is-daemon-name didn't require daemon name" |
61 |
|
62 |
for i in '' '.' '..' '-' 'not-a-daemon'; do |
63 |
$daemon_util is-daemon-name "$i" >/dev/null 2>&1 && |
64 |
err "is-daemon-name thinks '$i' is a daemon name" |
65 |
done |
66 |
|
67 |
for i in ganeti-{confd,rapi,masterd,noded}; do |
68 |
$daemon_util is-daemon-name $i >/dev/null 2>&1 || |
69 |
err "is-daemon-name doesn't think '$i' is a daemon name" |
70 |
done |