From 376298eccc4fb5fd85e4c4b938b1a8bd9a2132ac Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 18 Jan 2018 14:54:04 +0100 Subject: [PATCH] testprogs:blackbox: add regression test for unsorted links in tombstones-expunge.sh BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme (cherry picked from commit c34c2dd55545b99fba46cf374a1653bad96cea9e) --- selftest/knownfail.d/unsorted-links | 1 + .../add-unsorted-links-step1.ldif | 72 ++++++++++++++++++++++ .../add-unsorted-links-step2.ldif | 12 ++++ .../release-4-5-0-pre1/expected-expunge-output.txt | 2 +- .../expected-unsorted-links-after-expunge.ldif | 23 +++++++ testprogs/blackbox/tombstones-expunge.sh | 24 ++++++++ 6 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 selftest/knownfail.d/unsorted-links create mode 100644 source4/selftest/provisions/release-4-5-0-pre1/add-unsorted-links-step1.ldif create mode 100644 source4/selftest/provisions/release-4-5-0-pre1/add-unsorted-links-step2.ldif create mode 100644 source4/selftest/provisions/release-4-5-0-pre1/expected-unsorted-links-after-expunge.ldif diff --git a/selftest/knownfail.d/unsorted-links b/selftest/knownfail.d/unsorted-links new file mode 100644 index 00000000000..0b19ae5c116 --- /dev/null +++ b/selftest/knownfail.d/unsorted-links @@ -0,0 +1 @@ +^samba4.blackbox.tombstones-expunge.release-4-5-0-pre1.check_expected_unsorted_links diff --git a/source4/selftest/provisions/release-4-5-0-pre1/add-unsorted-links-step1.ldif b/source4/selftest/provisions/release-4-5-0-pre1/add-unsorted-links-step1.ldif new file mode 100644 index 00000000000..a1b9895d213 --- /dev/null +++ b/source4/selftest/provisions/release-4-5-0-pre1/add-unsorted-links-step1.ldif @@ -0,0 +1,72 @@ +dn: CN=unsorted-u1,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +changetype: add +objectclass: user +samaccountname: unsorted-u1 +objectGUID: 9f92d30a-fc23-11e7-a5f6-37be15454801 + +dn: CN=unsorted-u2,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +changetype: add +objectclass: user +samaccountname: unsorted-u2 +objectGUID: 9f92d30a-fc23-11e7-a5f6-37be15454802 + +dn: CN=unsorted-u3,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +changetype: add +objectclass: user +samaccountname: unsorted-u3 +objectGUID: 9f92d30a-fc23-11e7-a5f6-30be15454803 + +dn: CN=unsorted-u4,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +changetype: add +objectclass: user +samaccountname: unsorted-u4 +objectGUID: 9f92d30a-fc23-11e7-a5f6-30be15454804 + +dn: CN=unsorted-u5,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +changetype: add +objectclass: user +samaccountname: unsorted-u5 +objectGUID: 9f92d30a-fc23-11e7-a5f6-30be15454805 + +dn: CN=unsorted-u6,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +changetype: add +objectclass: user +samaccountname: unsorted-u6 +objectGUID: 9f92d30a-fc23-11e7-a5f6-30be15454806 + +dn: CN=unsorted-u7,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +changetype: add +objectclass: user +samaccountname: unsorted-u7 +objectGUID: 9f92d30a-fc23-11e7-a5f6-30be15454807 + +dn: CN=unsorted-u8,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +changetype: add +objectclass: user +samaccountname: unsorted-u8 +objectGUID: 9f92d30a-fc23-11e4-a5f6-30be15454808 + +dn: CN=unsorted-u9,CN=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +changetype: add +objectclass: user +samaccountname: unsorted-u9 +objectGUID: 9f92d30a-fc23-11e4-a5f6-30be15454809 + +dn: cn=unsorted-g,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +changetype: add +objectclass: group +samaccountname: unsorted-g +member: cn=unsorted-u1,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: cn=unsorted-u2,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: cn=unsorted-u3,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: cn=unsorted-u4,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: cn=unsorted-u5,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: cn=unsorted-u6,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: cn=unsorted-u7,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: cn=unsorted-u8,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: cn=unsorted-u9,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp + +dn: cn=unsorted-g,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp +changetype: modify +delete: member +member: cn=unsorted-u5,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp diff --git a/source4/selftest/provisions/release-4-5-0-pre1/add-unsorted-links-step2.ldif b/source4/selftest/provisions/release-4-5-0-pre1/add-unsorted-links-step2.ldif new file mode 100644 index 00000000000..521b31e1290 --- /dev/null +++ b/source4/selftest/provisions/release-4-5-0-pre1/add-unsorted-links-step2.ldif @@ -0,0 +1,12 @@ +dn: CN=unsorted-g,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +changetype: modify +replace: member +member: ;;;;;;;;;CN=unsorted-u1,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: ;;;;;;;;;CN=unsorted-u2,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: ;;;;;;;;;CN=unsorted-u3,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: ;;;;;;;;;CN=unsorted-u4,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: ;;;;;;;;;CN=unsorted-u5,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: ;;;;;;;;;CN=unsorted-u6,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: ;;;;;;;;;CN=unsorted-u7,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: ;;;;;;;;;CN=unsorted-u8,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: ;;;;;;;;;CN=unsorted-u9,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp diff --git a/source4/selftest/provisions/release-4-5-0-pre1/expected-expunge-output.txt b/source4/selftest/provisions/release-4-5-0-pre1/expected-expunge-output.txt index 68262571ab0..06a25a38eaa 100644 --- a/source4/selftest/provisions/release-4-5-0-pre1/expected-expunge-output.txt +++ b/source4/selftest/provisions/release-4-5-0-pre1/expected-expunge-output.txt @@ -1 +1 @@ -Removed 7 objects and 2 links successfully +Removed 7 objects and 3 links successfully diff --git a/source4/selftest/provisions/release-4-5-0-pre1/expected-unsorted-links-after-expunge.ldif b/source4/selftest/provisions/release-4-5-0-pre1/expected-unsorted-links-after-expunge.ldif new file mode 100644 index 00000000000..d078fd932a9 --- /dev/null +++ b/source4/selftest/provisions/release-4-5-0-pre1/expected-unsorted-links-after-expunge.ldif @@ -0,0 +1,23 @@ +# record 1 +dn: CN=unsorted-g,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: CN=unsorted-u8,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: CN=unsorted-u9,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: CN=unsorted-u3,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: CN=unsorted-u4,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: CN=unsorted-u6,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: CN=unsorted-u7,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: CN=unsorted-u1,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp +member: CN=unsorted-u2,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp + +# Referral +ref: ldap:///CN=Configuration,DC=release-4-5-0-pre1,DC=samba,DC=corp + +# Referral +ref: ldap:///DC=DomainDnsZones,DC=release-4-5-0-pre1,DC=samba,DC=corp + +# Referral +ref: ldap:///DC=ForestDnsZones,DC=release-4-5-0-pre1,DC=samba,DC=corp + +# returned 4 records +# 1 entries +# 3 referrals diff --git a/testprogs/blackbox/tombstones-expunge.sh b/testprogs/blackbox/tombstones-expunge.sh index 3f7d708c8ad..d03547f85cd 100755 --- a/testprogs/blackbox/tombstones-expunge.sh +++ b/testprogs/blackbox/tombstones-expunge.sh @@ -92,6 +92,19 @@ add_four_more_links() { fi } +add_unsorted_links() { + ldif=$release_dir/add-unsorted-links-step1.ldif + TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif --relax + if [ "$?" != "0" ]; then + return 1 + fi + ldif=$release_dir/add-unsorted-links-step2.ldif + TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.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 @@ -176,6 +189,15 @@ check_expected_after_objects() { fi } +check_expected_unsorted_links() { + tmpldif=$PREFIX_ABS/$RELEASE/expected-unsorted-links-after-expunge.ldif.tmp + TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(name=unsorted-g)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member > $tmpldif + diff $tmpldif $release_dir/expected-unsorted-links-after-expunge.ldif + if [ "$?" != "0" ]; then + return 1 + fi +} + if [ -d $release_dir ]; then testit $RELEASE undump testit "add_two_more_users" add_two_more_users @@ -192,10 +214,12 @@ if [ -d $release_dir ]; then testit_expect_failure "check_match_rule_links_decimal" check_match_rule_links_decimal testit_expect_failure "check_match_rule_links_backlink" check_match_rule_links_backlink testit_expect_failure "check_match_rule_links_notlink" check_match_rule_links_notlink + testit "add_unsorted_links" add_unsorted_links testit "tombstones_expunge" tombstones_expunge 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 + testit "check_expected_unsorted_links" check_expected_unsorted_links else subunit_start_test $RELEASE subunit_skip_test $RELEASE <