]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-tests: add reloadnodes unit tests that use the nodes list command
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 31 Jul 2024 20:30:13 +0000 (16:30 -0400)
committerMartin Schwenke <martins@samba.org>
Tue, 6 Aug 2024 00:43:36 +0000 (00:43 +0000)
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/tests/UNIT/tool/ctdb.reloadnodes.041.sh [new file with mode: 0755]
ctdb/tests/UNIT/tool/ctdb.reloadnodes.042.sh [new file with mode: 0755]

diff --git a/ctdb/tests/UNIT/tool/ctdb.reloadnodes.041.sh b/ctdb/tests/UNIT/tool/ctdb.reloadnodes.041.sh
new file mode 100755 (executable)
index 0000000..2520bae
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "3 nodes, nodes list command"
+
+cat > "${CTDB_BASE}/ctdb.conf" <<EOF
+[cluster]
+       nodes list = !${CTDB_BASE}/nodes.sh
+EOF
+test_cleanup rm -rf "${CTDB_BASE}/ctdb.conf"
+
+cat > "${CTDB_BASE}/nodes.sh" <<EOF
+#!/bin/sh
+for x in 41 42 43; do
+       echo 192.168.20.\$x
+done
+EOF
+test_cleanup rm -rf "${CTDB_BASE}/nodes.sh"
+chmod +x "${CTDB_BASE}/nodes.sh"
+
+setup_ctdbd <<EOF
+USENODESCOMMAND
+NODEMAP
+0       192.168.20.41   0x0     CURRENT RECMASTER
+1       192.168.20.42   0x0
+2       192.168.20.43   0x0
+EOF
+
+ok <<EOF
+No change in nodes file, skipping unnecessary reload
+EOF
+
+simple_test
diff --git a/ctdb/tests/UNIT/tool/ctdb.reloadnodes.042.sh b/ctdb/tests/UNIT/tool/ctdb.reloadnodes.042.sh
new file mode 100755 (executable)
index 0000000..58da901
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "3 nodes, add a node, nodes list command"
+
+cat > "${CTDB_BASE}/ctdb.conf" <<EOF
+[cluster]
+       nodes list = !${CTDB_BASE}/nodes.sh
+EOF
+test_cleanup rm -rf "${CTDB_BASE}/ctdb.conf"
+
+cat > "${CTDB_BASE}/nodes.sh" <<EOF
+#!/bin/sh
+for x in 41 42 43 44; do
+       echo 192.168.20.\$x
+done
+EOF
+test_cleanup rm -rf "${CTDB_BASE}/nodes.sh"
+chmod +x "${CTDB_BASE}/nodes.sh"
+
+setup_ctdbd <<EOF
+USENODESCOMMAND
+NODEMAP
+0       192.168.20.41   0x0     CURRENT RECMASTER
+1       192.168.20.42   0x0
+2       192.168.20.43   0x0
+EOF
+
+ok <<EOF
+Node 3 is NEW
+EOF
+
+simple_test