5 Usage: dbcheck-links.sh PREFIX RELEASE
14 . `dirname $0`/subunit.sh
16 . `dirname $0`/common-links.sh
19 tmpfile=$PREFIX_ABS/$RELEASE/expected-dbcheck-link-output${1}.txt.tmp
20 tmpldif1=$PREFIX_ABS/$RELEASE/expected-dbcheck-output${1}2.txt.tmp1
22 TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -s base -b '' | grep highestCommittedUSN > $tmpldif1
24 $PYTHON $BINDIR/samba-tool dbcheck -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $3 --fix --yes > $tmpfile
25 if [ "$?" != "$2" ]; then
28 sort $tmpfile > $tmpfile.sorted
29 sort $release_dir/expected-dbcheck-link-output${1}.txt > $tmpfile.expected
30 diff -u $tmpfile.sorted $tmpfile.expected
31 if [ "$?" != "0" ]; then
35 tmpldif2=$PREFIX_ABS/$RELEASE/expected-dbcheck-output${1}2.txt.tmp2
36 TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -s base -b '' | grep highestCommittedUSN > $tmpldif2
38 diff -u $tmpldif1 $tmpldif2
39 if [ "$?" != "0" ]; then
50 dbcheck "_one_way" "0" "CN=Configuration,DC=release-4-5-0-pre1,DC=samba,DC=corp"
55 tmpldif1=$PREFIX_ABS/$RELEASE/expected-dbcheck-output2.txt.tmp1
57 TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -s base -b '' | grep highestCommittedUSN > $tmpldif1
59 $PYTHON $BINDIR/samba-tool dbcheck -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb
60 if [ "$?" != "0" ]; then
63 tmpldif2=$PREFIX_ABS/$RELEASE/expected-dbcheck-output2.txt.tmp2
64 TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -s base -b '' | grep highestCommittedUSN > $tmpldif2
66 diff $tmpldif1 $tmpldif2
67 if [ "$?" != "0" ]; then
72 check_expected_after_links() {
73 tmpldif=$PREFIX_ABS/$RELEASE/expected-links-after-link-dbcheck.ldif.tmp
74 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
75 diff $tmpldif $release_dir/expected-links-after-link-dbcheck.ldif
76 if [ "$?" != "0" ]; then
81 check_expected_after_deleted_links() {
82 tmpldif=$PREFIX_ABS/$RELEASE/expected-deleted-links-after-link-dbcheck.ldif.tmp
83 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
84 diff $tmpldif $release_dir/expected-deleted-links-after-link-dbcheck.ldif
85 if [ "$?" != "0" ]; then
90 check_expected_after_objects() {
91 tmpldif=$PREFIX_ABS/$RELEASE/expected-objects-after-link-dbcheck.ldif.tmp
92 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
93 diff $tmpldif $release_dir/expected-objects-after-link-dbcheck.ldif
94 if [ "$?" != "0" ]; then
99 dbcheck_dangling_multi_valued() {
101 $PYTHON $BINDIR/samba-tool dbcheck -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --fix --yes
102 if [ "$?" != "1" ]; then
107 dangling_multi_valued_check_missing() {
108 WORDS=`TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=dangling-multi2)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l`
109 if [ $WORDS -ne 4 ]; then
110 echo Got only $WORDS links for dangling-multi2
113 WORDS=`TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=dangling-multi3)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l`
114 if [ $WORDS -ne 4 ]; then
115 echo Got only $WORDS links for dangling-multi3
120 dangling_multi_valued_check_equal_or_too_many() {
121 WORDS=`TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=dangling-multi1)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l`
122 if [ $WORDS -ne 4 ]; then
123 echo Got $WORDS links for dangling-multi1
127 WORDS=`TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=dangling-multi5)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l`
129 if [ $WORDS -ne 0 ]; then
130 echo Got $WORDS links for dangling-multi5
134 WORDS=`TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samaccountname=Administrator)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted msDS-RevealedDSAs | grep msDS-RevealedDSAs | wc -l`
136 if [ $WORDS -ne 2 ]; then
137 echo Got $WORDS links for Administrator
143 if [ -d $release_dir ]; then
144 testit $RELEASE undump
145 testit "add_two_more_users" add_two_more_users
146 testit "add_four_more_links" add_four_more_links
147 testit "remove_one_link" remove_one_link
148 testit "remove_one_user" remove_one_user
149 testit "move_one_user" move_one_user
150 testit "add_dangling_link" add_dangling_link
151 testit "add_dangling_backlink" add_dangling_backlink
152 testit "add_deleted_dangling_backlink" add_deleted_dangling_backlink
153 testit "add_deleted_source_backlink" add_deleted_source_backlink
154 testit "add_deleted_target_link" add_deleted_target_link
155 testit "add_deleted_target_backlink" add_deleted_target_backlink
156 testit "dbcheck_dangling" dbcheck_dangling
157 testit "dbcheck_clean" dbcheck_clean
158 testit "check_expected_after_deleted_links" check_expected_after_deleted_links
159 testit "check_expected_after_links" check_expected_after_links
160 testit "check_expected_after_objects" check_expected_after_objects
161 testit "dangling_one_way_link" dangling_one_way_link
162 testit "dbcheck_one_way" dbcheck_one_way
163 testit "dbcheck_clean2" dbcheck_clean
164 testit "dangling_one_way_dn" dangling_one_way_dn
165 testit "deleted_one_way_dn" deleted_one_way_dn
166 testit "dbcheck_clean3" dbcheck_clean
167 testit "add_dangling_multi_valued" add_dangling_multi_valued
168 testit "dbcheck_dangling_multi_valued" dbcheck_dangling_multi_valued
169 testit "dangling_multi_valued_check_missing" dangling_multi_valued_check_missing
170 testit "dangling_multi_valued_check_equal_or_too_many" dangling_multi_valued_check_equal_or_too_many
171 # Currently this cannot pass
172 testit "dbcheck_dangling_multi_valued_clean" dbcheck_clean
174 subunit_start_test $RELEASE
175 subunit_skip_test $RELEASE <<EOF
179 subunit_start_test "tombstones_expunge"
180 subunit_skip_test "tombstones_expunge" <<EOF
185 if [ -d $PREFIX_ABS/${RELEASE} ]; then
186 rm -fr $PREFIX_ABS/${RELEASE}