ctdb-tests: Add "ctdb runstate" tool tests
authorMartin Schwenke <martin@meltin.net>
Fri, 15 Jul 2016 06:12:26 +0000 (16:12 +1000)
committerAmitay Isaacs <amitay@samba.org>
Mon, 25 Jul 2016 19:29:46 +0000 (21:29 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/tool/ctdb.runstate.001.sh [new file with mode: 0755]
ctdb/tests/tool/ctdb.runstate.002.sh [new file with mode: 0755]
ctdb/tests/tool/ctdb.runstate.003.sh [new file with mode: 0755]
ctdb/tests/tool/ctdb.runstate.004.sh [new file with mode: 0755]
ctdb/tests/tool/ctdb.runstate.005.sh [new file with mode: 0755]

diff --git a/ctdb/tests/tool/ctdb.runstate.001.sh b/ctdb/tests/tool/ctdb.runstate.001.sh
new file mode 100755 (executable)
index 0000000..d9559bd
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "get runstate, should be RUNNING"
+
+setup_ctdbd <<EOF
+NODEMAP
+0       192.168.20.41   0x0     CURRENT RECMASTER
+1       192.168.20.42   0x0
+2       192.168.20.43   0x0
+EOF
+
+ok "RUNNING"
+simple_test
diff --git a/ctdb/tests/tool/ctdb.runstate.002.sh b/ctdb/tests/tool/ctdb.runstate.002.sh
new file mode 100755 (executable)
index 0000000..b75b2ec
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "check if RUNNING"
+
+setup_ctdbd <<EOF
+NODEMAP
+0       192.168.20.41   0x0     CURRENT RECMASTER
+1       192.168.20.42   0x0
+2       192.168.20.43   0x0
+EOF
+
+ok "RUNNING"
+simple_test "RUNNING"
diff --git a/ctdb/tests/tool/ctdb.runstate.003.sh b/ctdb/tests/tool/ctdb.runstate.003.sh
new file mode 100755 (executable)
index 0000000..eba41f8
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "check non-RUNNING states"
+
+setup_ctdbd <<EOF
+NODEMAP
+0       192.168.20.41   0x0     CURRENT RECMASTER
+1       192.168.20.42   0x0
+2       192.168.20.43   0x0
+EOF
+
+for i in "INIT" "SETUP" "FIRST_RECOVERY" "STARTUP" "SHUTDOWN" ; do
+       required_result 1 "CTDB not in required run state (got RUNNING)"
+       simple_test "$i"
+done
diff --git a/ctdb/tests/tool/ctdb.runstate.004.sh b/ctdb/tests/tool/ctdb.runstate.004.sh
new file mode 100755 (executable)
index 0000000..666e84d
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "check invalid state"
+
+setup_ctdbd <<EOF
+NODEMAP
+0       192.168.20.41   0x0     CURRENT RECMASTER
+1       192.168.20.42   0x0
+2       192.168.20.43   0x0
+EOF
+
+required_result 1 "Invalid run state (foobar)"
+simple_test "foobar"
diff --git a/ctdb/tests/tool/ctdb.runstate.005.sh b/ctdb/tests/tool/ctdb.runstate.005.sh
new file mode 100755 (executable)
index 0000000..972783c
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "check from multiple states"
+
+setup_ctdbd <<EOF
+NODEMAP
+0       192.168.20.41   0x0     CURRENT RECMASTER
+1       192.168.20.42   0x0
+2       192.168.20.43   0x0
+EOF
+
+ok "RUNNING"
+simple_test "STARTUP" "RUNNING"