Commit 571b34f8 authored by Michael Hanselmann's avatar Michael Hanselmann

Add unittest for daemon-util

This test doesn't cover everything, but it's better than nothing.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent e8c8cf1a
......@@ -342,6 +342,7 @@ python_tests = \
test/tempfile_fork_unittest.py
dist_TESTS = \
test/daemon-util_unittest.bash \
$(python_tests)
nodist_TESTS =
......@@ -369,6 +370,7 @@ all_python_code = \
srclink_files = \
man/footer.sgml \
test/daemon-util_unittest.bash \
$(all_python_code)
check_python_code = \
......@@ -381,6 +383,8 @@ lint_python_code = \
$(dist_tools_SCRIPTS) \
$(BUILD_BASH_COMPLETION)
test/daemon-util_unittest.bash: daemons/daemon-util
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
sed -f $(REPLACE_VARS_SED) < $< > $@
chmod u+x $@
......
......@@ -5,7 +5,7 @@ set -e
tmpdir=$(mktemp -d -t gntbuild.XXXXXXXX)
trap "rm -rf $tmpdir" EXIT
cp -r scripts lib tools test $tmpdir
cp -r daemons scripts lib tools test $tmpdir
mv $tmpdir/lib $tmpdir/ganeti
cd $tmpdir && "$@"
#!/bin/bash
#
# Copyright (C) 2010 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
set -e
daemon_util=daemons/daemon-util
err() {
echo "$@"
echo 'Aborting'
exit 1
}
$daemon_util >/dev/null 2>&1 &&
err "daemon-util succeeded without command"
$daemon_util this-is-an-unimplemented-command >/dev/null 2>&1 &&
err "daemon-util accepted unimplemented command"
$daemon_util list_start_daemons >/dev/null 2>&1 &&
err "daemon-util accepted command with underscores"
$daemon_util check-exitcode 0 ||
err "check-exitcode 0 failed"
for i in 1 2 3 4 20 25 33; do
$daemon_util check-exitcode $i >/dev/null 2>&1 && rc=0 || rc=$?
test "$rc" == 1 || err "check-exitcode $i didn't return 1"
done
$daemon_util check-exitcode 11 >/dev/null 2>&1 ||
err "check-exitcode 11 (not master) didn't return 0"
tmp=$(echo $($daemon_util list-start-daemons))
test "$tmp" == "$(echo ganeti-{noded,masterd,rapi,confd})" ||
err "list-start-daemons didn't return correct list of daemons"
tmp=$(echo $($daemon_util list-stop-daemons))
test "$tmp" == "$(echo ganeti-{confd,rapi,masterd,noded})" ||
err "list-stop-daemons didn't return correct list of daemons"
$daemon_util is-daemon-name >/dev/null 2>&1 &&
err "is-daemon-name didn't require daemon name"
for i in '' '.' '..' '-' 'not-a-daemon'; do
$daemon_util is-daemon-name "$i" >/dev/null 2>&1 &&
err "is-daemon-name thinks '$i' is a daemon name"
done
for i in ganeti-{confd,rapi,masterd,noded}; do
$daemon_util is-daemon-name $i >/dev/null 2>&1 ||
err "is-daemon-name doesn't think '$i' is a daemon name"
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment