summaryrefslogtreecommitdiff
path: root/testprogs
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2016-11-07 11:39:53 +1300
committerGarming Sam <garming@samba.org>2016-11-22 02:10:16 +0100
commit8315d4d03ac77f1727ff01e87392f6e49ba40def (patch)
tree5280b2dc3c4ef8ddf64d887c1b568de44df5ef41 /testprogs
parent5889f399daad54124e0bb2be1fe81da1df67c84e (diff)
downloadsamba-8315d4d03ac77f1727ff01e87392f6e49ba40def.tar.gz
selftest: Add test for link and deleted link behaviour in dbcheck
The other dbcheck tests were getting over-complex, so we start a new test here based on tombestone-expunge.sh, as we are looking at very similar problems Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12297
Diffstat (limited to 'testprogs')
-rwxr-xr-xtestprogs/blackbox/dbcheck-links.sh188
1 files changed, 188 insertions, 0 deletions
diff --git a/testprogs/blackbox/dbcheck-links.sh b/testprogs/blackbox/dbcheck-links.sh
new file mode 100755
index 00000000000..11592f0a3a4
--- /dev/null
+++ b/testprogs/blackbox/dbcheck-links.sh
@@ -0,0 +1,188 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]; then
+cat <<EOF
+Usage: dbcheck-links.sh PREFIX RELEASE
+EOF
+exit 1;
+fi
+
+PREFIX_ABS="$1"
+RELEASE="$2"
+shift 2
+
+. `dirname $0`/subunit.sh
+
+release_dir=`dirname $0`/../../source4/selftest/provisions/$RELEASE
+
+ldbadd="ldbadd"
+if [ -x "$BINDIR/ldbadd" ]; then
+ ldbadd="$BINDIR/ldbadd"
+fi
+
+ldbmodify="ldbmodify"
+if [ -x "$BINDIR/ldbmodify" ]; then
+ ldbmodify="$BINDIR/ldbmodify"
+fi
+
+ldbdel="ldbdel"
+if [ -x "$BINDIR/ldbdel" ]; then
+ ldbdel="$BINDIR/ldbdel"
+fi
+
+ldbsearch="ldbsearch"
+if [ -x "$BINDIR/ldbsearch" ]; then
+ ldbsearch="$BINDIR/ldbsearch"
+fi
+
+ldbrename="ldbrename"
+if [ -x "$BINDIR/ldbrename" ]; then
+ ldbrename="$BINDIR/ldbrename"
+fi
+
+undump() {
+ if test -x $BINDIR/tdbrestore;
+ then
+ `dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE $BINDIR/tdbrestore
+ else
+ `dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE
+ fi
+}
+
+dbcheck() {
+ tmpfile=$PREFIX_ABS/$RELEASE/expected-dbcheck-link-output.txt.tmp
+ tmpldif1=$PREFIX_ABS/$RELEASE/expected-dbcheck-output2.txt.tmp1
+
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -s base -b '' | grep highestCommittedUSN > $tmpldif1
+
+ $PYTHON $BINDIR/samba-tool dbcheck -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --fix --yes > $tmpfile
+ if [ "$?" != "1" ]; then
+ return 1
+ fi
+ diff $tmpfile $release_dir/expected-dbcheck-link-output.txt
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+
+ tmpldif2=$PREFIX_ABS/$RELEASE/expected-dbcheck-output2.txt.tmp2
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -s base -b '' | grep highestCommittedUSN > $tmpldif2
+
+ diff $tmpldif1 $tmpldif2
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+dbcheck_clean() {
+ tmpldif1=$PREFIX_ABS/$RELEASE/expected-dbcheck-output2.txt.tmp1
+
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -s base -b '' | grep highestCommittedUSN > $tmpldif1
+
+ $PYTHON $BINDIR/samba-tool dbcheck -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+ tmpldif2=$PREFIX_ABS/$RELEASE/expected-dbcheck-output2.txt.tmp2
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -s base -b '' | grep highestCommittedUSN > $tmpldif2
+
+ diff $tmpldif1 $tmpldif2
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+add_two_more_users() {
+ ldif=$release_dir/add-two-more-users.ldif
+ TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+add_four_more_links() {
+ ldif=$release_dir/add-four-more-links.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+remove_one_link() {
+ ldif=$release_dir/remove-one-more-link.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+remove_one_user() {
+ ldif=$release_dir/remove-one-more-user.ldif
+ TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+move_one_user() {
+ TZ=UTC $ldbrename -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb 'cn=user1,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp' 'cn=user1x,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp'
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+check_expected_after_links() {
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-links-after-link-dbcheck.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(|(cn=swimmers)(cn=leaders)(cn=helpers))' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --sorted member > $tmpldif
+ diff $tmpldif $release_dir/expected-links-after-link-dbcheck.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+check_expected_after_deleted_links() {
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-deleted-links-after-link-dbcheck.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(|(cn=swimmers)(cn=leaders)(cn=helpers))' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member > $tmpldif
+ diff $tmpldif $release_dir/expected-deleted-links-after-link-dbcheck.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+check_expected_after_objects() {
+ tmpldif=$PREFIX_ABS/$RELEASE/expected-objects-after-link-dbcheck.ldif.tmp
+ TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(|(samaccountname=fred)(samaccountname=ddg)(samaccountname=usg)(samaccountname=user1)(samaccountname=user1x)(samaccountname=user2))' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted samAccountName | grep sAMAccountName > $tmpldif
+ diff $tmpldif $release_dir/expected-objects-after-link-dbcheck.ldif
+ if [ "$?" != "0" ]; then
+ return 1
+ fi
+}
+
+if [ -d $release_dir ]; then
+ testit $RELEASE undump
+ testit "add_two_more_users" add_two_more_users
+ testit "add_four_more_links" add_four_more_links
+ testit "remove_one_link" remove_one_link
+ testit "remove_one_user" remove_one_user
+ testit "move_one_user" move_one_user
+ testit "dbcheck" dbcheck
+ testit "dbcheck_clean" dbcheck_clean
+ testit "check_expected_after_deleted_links" check_expected_after_deleted_links
+ testit "check_expected_after_links" check_expected_after_links
+ testit "check_expected_after_objects" check_expected_after_objects
+else
+ subunit_start_test $RELEASE
+ subunit_skip_test $RELEASE <<EOF
+no test provision
+EOF
+
+ subunit_start_test "tombstones_expunge"
+ subunit_skip_test "tombstones_expunge" <<EOF
+no test provision
+EOF
+fi
+
+if [ -d $PREFIX_ABS/${RELEASE} ]; then
+ rm -fr $PREFIX_ABS/${RELEASE}
+fi
+
+exit $failed