From: Martin Schwenke Date: Mon, 12 Aug 2019 11:02:47 +0000 (+1000) Subject: ctdb-tests: Factor out function check_cattdb_num_records() X-Git-Tag: talloc-2.3.1~228 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9654085f5facfe8a3d64667d65793146563d7f5;p=thirdparty%2Fsamba.git ctdb-tests: Factor out function check_cattdb_num_records() This can be use in multiple vacuuming tests. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tests/INTEGRATION/database/recovery.003.no_resurrect.sh b/ctdb/tests/INTEGRATION/database/recovery.003.no_resurrect.sh index 51d806a5d47..b65452c0e06 100755 --- a/ctdb/tests/INTEGRATION/database/recovery.003.no_resurrect.sh +++ b/ctdb/tests/INTEGRATION/database/recovery.003.no_resurrect.sh @@ -43,16 +43,9 @@ try_command_on_node $second $CTDB deletekey "$testdb" test1 database_has_zero_records () { - local n - for n in $notfirst ; do - local num_records - num_records=$(db_ctdb_cattdb_count_records "$n" "$testdb") - if [ "$num_records" != 0 ] ; then - return 1 - fi - done - - return 0 + # shellcheck disable=SC2086 + # $notfirst can be multi-word + check_cattdb_num_records "$testdb" 0 "$notfirst" } echo "Trigger a recovery" diff --git a/ctdb/tests/INTEGRATION/database/scripts/local.bash b/ctdb/tests/INTEGRATION/database/scripts/local.bash new file mode 100644 index 00000000000..c36f155d6ce --- /dev/null +++ b/ctdb/tests/INTEGRATION/database/scripts/local.bash @@ -0,0 +1,31 @@ +# Hey Emacs, this is a -*- shell-script -*- !!! :-) + +check_cattdb_num_records () +{ + local db="$1" + local num="$2" + local nodes="$3" + + # $nodes has embedded newlines - put list on 1 line for printing + local t + t=$(echo "$nodes" | xargs) + echo "Confirm that ${db} has ${num} record(s) on node(s): ${t}" + + local ret=0 + local node + for node in $nodes ; do + local num_found + + num_found=$(db_ctdb_cattdb_count_records "$node" "$db") + if [ "$num_found" = "$num" ] ; then + continue + fi + + printf 'BAD: %s on node %d has %d record(s), expected %d\n' \ + "$db" "$node" "$num_found" "$num" + ctdb_onnode -v "$node" "cattdb $db" + ret=1 + done + + return $ret +}