summaryrefslogtreecommitdiff
path: root/ctdb/tests/INTEGRATION
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2020-03-06 05:10:05 +1100
committerAmitay Isaacs <amitay@samba.org>2020-07-22 02:42:38 +0000
commitd2f8cd835da39784f2d99231f9a1067ae56ede7a (patch)
tree357a999ea602a15125aad568ff394ad0aa0179c1 /ctdb/tests/INTEGRATION
parenta308f2534d3991866efa2c662921ec63b4238888 (diff)
downloadsamba-d2f8cd835da39784f2d99231f9a1067ae56ede7a.tar.gz
ctdb-tests: Improve test portability/quality
Avoid use of non-portable md5sum by constructing database names using index. Improve indentation, use more modern commands, code improvements (shellcheck). Signed-off-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb/tests/INTEGRATION')
-rwxr-xr-xctdb/tests/INTEGRATION/database/basics.001.attach.sh48
1 files changed, 23 insertions, 25 deletions
diff --git a/ctdb/tests/INTEGRATION/database/basics.001.attach.sh b/ctdb/tests/INTEGRATION/database/basics.001.attach.sh
index e5c6b81ba65..1fbffc58436 100755
--- a/ctdb/tests/INTEGRATION/database/basics.001.attach.sh
+++ b/ctdb/tests/INTEGRATION/database/basics.001.attach.sh
@@ -8,14 +8,11 @@ set -e
ctdb_test_init
-make_temp_db_filename ()
-{
- dd if=/dev/urandom count=1 bs=512 2>/dev/null |
- md5sum |
- awk '{printf "%s.tdb\n", $1}'
-}
+select_test_node
-try_command_on_node -v 0 "$CTDB getdbmap"
+# test_node set by select_test_node() above
+# shellcheck disable=SC2154
+ctdb_onnode -v "$test_node" getdbmap
dbid='dbid:0x[[:xdigit:]]+'
name='name:[^[:space:]]+'
@@ -24,27 +21,28 @@ opts='( (PERSISTENT|STICKY|READONLY|REPLICATED|UNHEALTHY))*'
line="${dbid} ${name} ${path}${opts}"
dbmap_pattern="^(Number of databases:[[:digit:]]+|${line})\$"
+# outfile set by ctdb_onnode() above
+# shellcheck disable=SC2154
num_db_init=$(sed -n -e '1s/.*://p' "$outfile")
sanity_check_output $(($num_db_init + 1)) "$dbmap_pattern"
for i in $(seq 1 5) ; do
- f=$(make_temp_db_filename)
- echo "Creating test database: $f"
- try_command_on_node 0 $CTDB attach "$f"
- try_command_on_node 0 $CTDB getdbmap
- sanity_check_output $(($num_db_init + 1)) "$dbmap_pattern"
- num=$(sed -n -e '1s/^.*://p' "$outfile")
- if [ $num = $(($num_db_init + $i)) ] ; then
- echo "OK: correct number of additional databases"
- else
- echo "BAD: no additional database"
- exit 1
- fi
- if awk '{print $2}' "$outfile" | grep -Fqx "name:$f" ; then
- echo "OK: getdbmap knows about \"$f\""
- else
- echo "BAD: getdbmap does not know about \"$f\""
- exit 1
- fi
+ f="attach_test_${i}.tdb"
+ echo "Creating test database: $f"
+ ctdb_onnode "$test_node" "attach ${f}"
+
+ ctdb_onnode "$test_node" getdbmap
+ sanity_check_output $((num_db_init + 1)) "$dbmap_pattern"
+ num=$(sed -n -e '1s/^.*://p' "$outfile")
+ if [ "$num" = $((num_db_init + i)) ] ; then
+ echo "OK: correct number of additional databases"
+ else
+ ctdb_test_fail "BAD: no additional database"
+ fi
+ if awk '{print $2}' "$outfile" | grep -Fqx "name:$f" ; then
+ echo "OK: getdbmap knows about \"$f\""
+ else
+ ctdb_test_fail "BAD: getdbmap does not know about \"$f\""
+ fi
done