From 80f3f7c1889d225dcc1e7841e28e9a3f7918c99c Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Fri, 5 Oct 2018 10:34:29 +1000 Subject: [PATCH] ctdb-tests: Improve counting of database records Record counts are sometimes incomplete for large databases when relevant tests are run on a real cluster. This probably has something to do with ssh, pipes and buffering, so move the filtering and counting to the remote end. This means that only the count comes across the pipe, instead of all the record data. Instead of explicitly excluding the key for persistent database sequence numbers, just exclude any key starting with '_'. Such keys are not used in tests. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Mon Oct 8 05:36:11 CEST 2018 on sn-devel-144 --- ctdb/tests/scripts/integration.bash | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash index b255f063ba2..248a7caddd1 100644 --- a/ctdb/tests/scripts/integration.bash +++ b/ctdb/tests/scripts/integration.bash @@ -701,9 +701,13 @@ db_get_path () # $1: pnn, $2: DB name db_ctdb_cattdb_count_records () { - try_command_on_node -v $1 $CTDB cattdb "$2" | - grep '^key' | grep -v '__db_sequence_number__' | - wc -l + # Count the number of keys, excluding any that begin with '_'. + # This excludes at least the sequence number record in + # persistent/replicated databases. The trailing "|| :" forces + # the command to succeed when no records are matched. + try_command_on_node $1 \ + "$CTDB cattdb $2 | grep -c '^key([0-9][0-9]*) = \"[^_]' || :" + echo "$out" } # $1: pnn, $2: DB name, $3: key string, $4: value string, $5: RSN (default 7)