1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

ctdb-tests: New event script test for corrupt TDB checking

Ensures that backups of corrupt TDB files are correctly limited in
number.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2016-07-13 06:44:08 +10:00 committed by Amitay Isaacs
parent 0d60ecf032
commit 5cf45ede3f

View File

@ -0,0 +1,59 @@
#!/bin/sh
. "${TEST_SCRIPTS_DIR}/unit.sh"
define_test "TDB check, bad TDB multiple times"
setup_ctdb
db="${CTDB_DBDIR}/foo.tdb.0"
FAKE_TDB_IS_OK="no"
result_filter ()
{
_date="[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"
_time="[0-9][0-9][0-9][0-9][0-9][0-9]"
_nanos="[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"
_date_time="${_date}\.${_time}\.${_nanos}"
sed -e "s|\.${_date_time}\.|.DATE.TIME.|"
}
required_result_tdbcheck ()
{
ok <<EOF
WARNING: database ${db} is corrupted.
Moving to backup ${db}.DATE.TIME.corrupt for later analysis.
EOF
}
# List the corrupt databases
test_num_corrupt ()
{
(cd "$CTDB_DBDIR" && ls foo.tdb.0.*.corrupt)
}
# Required result is a list of up to 10 corrupt databases
required_result_num_corrupt ()
{
_num="$1"
if [ "$_num" -gt 10 ] ; then
_num=10
fi
_t=""
for _x in $(seq 1 $_num) ; do
_t="${_t:+${_t}
}foo.tdb.0.DATE.TIME.corrupt"
done
ok "$_t"
}
for i in $(seq 1 15) ; do
touch "$db"
required_result_tdbcheck
simple_test
required_result_num_corrupt "$i"
simple_test_command test_num_corrupt
done