mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
ctdb-tests: add unit test coverage for listnodes with command
Signed-off-by: John Mulligan <jmulligan@redhat.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
cfc0917135
commit
cdb5646b88
28
ctdb/tests/UNIT/tool/ctdb.listnodes.003.sh
Executable file
28
ctdb/tests/UNIT/tool/ctdb.listnodes.003.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
define_test "list nodes via 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"
|
||||
|
||||
required_result 0 <<EOF
|
||||
192.168.20.41
|
||||
192.168.20.42
|
||||
192.168.20.43
|
||||
EOF
|
||||
|
||||
simple_test
|
29
ctdb/tests/UNIT/tool/ctdb.listnodes.004.sh
Executable file
29
ctdb/tests/UNIT/tool/ctdb.listnodes.004.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
define_test "list nodes command fails"
|
||||
|
||||
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
|
||||
echo "error: foo" >&2
|
||||
exit 1
|
||||
EOF
|
||||
test_cleanup rm -rf "${CTDB_BASE}/nodes.sh"
|
||||
chmod +x "${CTDB_BASE}/nodes.sh"
|
||||
|
||||
|
||||
f="${CTDB_BASE}/nodes.sh"
|
||||
|
||||
required_result 1 <<EOF
|
||||
error: foo
|
||||
${TEST_DATE_STAMP}Failed to read nodes from "!${f}"
|
||||
EOF
|
||||
|
||||
simple_test
|
21
ctdb/tests/UNIT/tool/ctdb.listnodes.005.sh
Executable file
21
ctdb/tests/UNIT/tool/ctdb.listnodes.005.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
define_test "list nodes command invalid"
|
||||
|
||||
cat > "${CTDB_BASE}/ctdb.conf" <<EOF
|
||||
[cluster]
|
||||
nodes list = !${CTDB_BASE}/nodes.sh
|
||||
EOF
|
||||
test_cleanup rm -rf "${CTDB_BASE}/ctdb.conf"
|
||||
|
||||
|
||||
f="${CTDB_BASE}/nodes.sh"
|
||||
|
||||
required_result 1 <<EOF
|
||||
sys_popenv: ERROR executing command '${f}': No such file or directory
|
||||
${TEST_DATE_STAMP}Failed to read nodes from "!${f}"
|
||||
EOF
|
||||
|
||||
simple_test
|
32
ctdb/tests/UNIT/tool/ctdb.listnodes.006.sh
Executable file
32
ctdb/tests/UNIT/tool/ctdb.listnodes.006.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
define_test "list nodes command with bad output"
|
||||
|
||||
cat > "${CTDB_BASE}/ctdb.conf" <<EOF
|
||||
[cluster]
|
||||
nodes list = !${CTDB_BASE}/nodes.sh
|
||||
EOF
|
||||
test_cleanup rm -rf "${CTDB_BASE}/ctdb.conf"
|
||||
|
||||
# ctdb certainly doesn't understand xml
|
||||
cat > "${CTDB_BASE}/nodes.sh" <<EOF
|
||||
#!/bin/sh
|
||||
echo "<nodes>"
|
||||
echo "<node id="0" name="192.168.20.41" />"
|
||||
echo "<node id="1" name="192.168.20.42" />"
|
||||
echo "</nodes>"
|
||||
EOF
|
||||
test_cleanup rm -rf "${CTDB_BASE}/nodes.sh"
|
||||
chmod +x "${CTDB_BASE}/nodes.sh"
|
||||
|
||||
|
||||
f="${CTDB_BASE}/nodes.sh"
|
||||
|
||||
required_result 1 <<EOF
|
||||
Invalid node address <nodes>
|
||||
${TEST_DATE_STAMP}Failed to read nodes from "!${f}"
|
||||
EOF
|
||||
|
||||
simple_test
|
32
ctdb/tests/UNIT/tool/ctdb.listnodes.007.sh
Executable file
32
ctdb/tests/UNIT/tool/ctdb.listnodes.007.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
define_test "list nodes command valid output, but script still fails"
|
||||
|
||||
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
|
||||
exit 2
|
||||
EOF
|
||||
test_cleanup rm -rf "${CTDB_BASE}/nodes.sh"
|
||||
chmod +x "${CTDB_BASE}/nodes.sh"
|
||||
|
||||
|
||||
f="${CTDB_BASE}/nodes.sh"
|
||||
|
||||
required_result 0 <<EOF
|
||||
192.168.20.41
|
||||
192.168.20.42
|
||||
192.168.20.43
|
||||
EOF
|
||||
|
||||
simple_test
|
18
ctdb/tests/UNIT/tool/ctdb.listnodes.008.sh
Executable file
18
ctdb/tests/UNIT/tool/ctdb.listnodes.008.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
. "${TEST_SCRIPTS_DIR}/unit.sh"
|
||||
|
||||
define_test "list nodes command with argument"
|
||||
|
||||
cat > "${CTDB_BASE}/ctdb.conf" <<EOF
|
||||
[cluster]
|
||||
nodes list = !/usr/bin/printf %s\\n%s\\n 192.168.20.41 192.168.20.42
|
||||
EOF
|
||||
test_cleanup rm -rf "${CTDB_BASE}/ctdb.conf"
|
||||
|
||||
required_result 0 <<EOF
|
||||
192.168.20.41
|
||||
192.168.20.42
|
||||
EOF
|
||||
|
||||
simple_test
|
Loading…
Reference in New Issue
Block a user