diff options
author | Martin Schwenke <martin@meltin.net> | 2019-08-12 21:02:47 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2019-10-24 04:06:44 +0000 |
commit | b9654085f5facfe8a3d64667d65793146563d7f5 (patch) | |
tree | 47ab7ce7897a7b4d7d1e2c5b78de0f18a496dcd9 /ctdb | |
parent | 5a6d319eea6b281e9f4c35cf6c8889856234a9fd (diff) | |
download | samba-b9654085f5facfe8a3d64667d65793146563d7f5.tar.gz |
ctdb-tests: Factor out function check_cattdb_num_records()
This can be use in multiple vacuuming tests.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rwxr-xr-x | ctdb/tests/INTEGRATION/database/recovery.003.no_resurrect.sh | 13 | ||||
-rw-r--r-- | ctdb/tests/INTEGRATION/database/scripts/local.bash | 31 |
2 files changed, 34 insertions, 10 deletions
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 +} |