summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xctdb/tests/onnode/0010.sh13
-rwxr-xr-xctdb/tests/onnode/0011.sh13
-rwxr-xr-xctdb/tools/onnode8
3 files changed, 32 insertions, 2 deletions
diff --git a/ctdb/tests/onnode/0010.sh b/ctdb/tests/onnode/0010.sh
new file mode 100755
index 00000000000..241cf58aa69
--- /dev/null
+++ b/ctdb/tests/onnode/0010.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+cmd="$ONNODE 4 hostname"
+
+define_test "$cmd" "invalid pnn 4"
+
+required_result 1 <<EOF
+onnode: "node 4" does not exist
+EOF
+
+simple_test $cmd
diff --git a/ctdb/tests/onnode/0011.sh b/ctdb/tests/onnode/0011.sh
new file mode 100755
index 00000000000..46045331f1e
--- /dev/null
+++ b/ctdb/tests/onnode/0011.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+cmd="$ONNODE 99 hostname"
+
+define_test "$cmd" "invalid pnn 99"
+
+required_result 1 <<EOF
+onnode: "node 99" does not exist
+EOF
+
+simple_test $cmd
diff --git a/ctdb/tools/onnode b/ctdb/tools/onnode
index eabe034d227..13b0d19b3ee 100755
--- a/ctdb/tools/onnode
+++ b/ctdb/tools/onnode
@@ -102,8 +102,12 @@ echo_nth ()
{
local n="$1" ; shift
- shift "$n"
- local node="$1"
+ # Note that this is 0-based
+ local node=""
+ if [ "$n" -le $# ] ; then
+ shift "$n"
+ node="$1"
+ fi
if [ -n "$node" -a "$node" != "#DEAD" ] ; then
echo "$node"