testprogs:blackbox: add regression test for unsorted links in tombstones-expunge.sh
authorStefan Metzmacher <metze@samba.org>
Thu, 18 Jan 2018 13:54:04 +0000 (14:54 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 22 Jan 2018 11:26:19 +0000 (12:26 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
selftest/knownfail.d/unsorted-links [new file with mode: 0644]
source4/selftest/provisions/release-4-5-0-pre1/add-unsorted-links-step1.ldif [new file with mode: 0644]
source4/selftest/provisions/release-4-5-0-pre1/add-unsorted-links-step2.ldif [new file with mode: 0644]
source4/selftest/provisions/release-4-5-0-pre1/expected-expunge-output.txt
source4/selftest/provisions/release-4-5-0-pre1/expected-unsorted-links-after-expunge.ldif [new file with mode: 0644]
testprogs/blackbox/tombstones-expunge.sh

diff --git a/selftest/knownfail.d/unsorted-links b/selftest/knownfail.d/unsorted-links
new file mode 100644 (file)
index 0000000..0b19ae5
--- /dev/null
@@ -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 (file)
index 0000000..a1b9895
--- /dev/null
@@ -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 (file)
index 0000000..521b31e
--- /dev/null
@@ -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: <GUID=9f92d30a-fc23-11e7-a5f6-37be15454801>;<RMD_ADDTIME=131607546230000000>;<RMD_CHANGETIME=131607546230000000>;<RMD_FLAGS=0>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3765>;<RMD_ORIGINATING_USN=3765>;<RMD_VERSION=0>;<SID=S-1-5-21-4177067393-1453636373-93818738-1117>;CN=unsorted-u1,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+member: <GUID=9f92d30a-fc23-11e7-a5f6-37be15454802>;<RMD_ADDTIME=131607546230000000>;<RMD_CHANGETIME=131607546230000000>;<RMD_FLAGS=0>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3765>;<RMD_ORIGINATING_USN=3765>;<RMD_VERSION=0>;<SID=S-1-5-21-4177067393-1453636373-93818738-1118>;CN=unsorted-u2,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+member: <GUID=9f92d30a-fc23-11e7-a5f6-30be15454803>;<RMD_ADDTIME=131607546230000000>;<RMD_CHANGETIME=131607546230000000>;<RMD_FLAGS=0>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3765>;<RMD_ORIGINATING_USN=3765>;<RMD_VERSION=0>;<SID=S-1-5-21-4177067393-1453636373-93818738-1119>;CN=unsorted-u3,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+member: <GUID=9f92d30a-fc23-11e7-a5f6-30be15454804>;<RMD_ADDTIME=131607546230000000>;<RMD_CHANGETIME=131607546230000000>;<RMD_FLAGS=0>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3765>;<RMD_ORIGINATING_USN=3765>;<RMD_VERSION=0>;<SID=S-1-5-21-4177067393-1453636373-93818738-1120>;CN=unsorted-u4,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+member: <GUID=9f92d30a-fc23-11e7-a5f6-30be15454805>;<RMD_ADDTIME=131607546230000000>;<RMD_CHANGETIME=100000000000000000>;<RMD_FLAGS=1>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3766>;<RMD_ORIGINATING_USN=3766>;<RMD_VERSION=1>;<SID=S-1-5-21-4177067393-1453636373-93818738-1121>;CN=unsorted-u5,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+member: <GUID=9f92d30a-fc23-11e7-a5f6-30be15454806>;<RMD_ADDTIME=131607546230000000>;<RMD_CHANGETIME=131607546230000000>;<RMD_FLAGS=0>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3765>;<RMD_ORIGINATING_USN=3765>;<RMD_VERSION=0>;<SID=S-1-5-21-4177067393-1453636373-93818738-1122>;CN=unsorted-u6,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+member: <GUID=9f92d30a-fc23-11e7-a5f6-30be15454807>;<RMD_ADDTIME=131607546230000000>;<RMD_CHANGETIME=131607546230000000>;<RMD_FLAGS=0>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3765>;<RMD_ORIGINATING_USN=3765>;<RMD_VERSION=0>;<SID=S-1-5-21-4177067393-1453636373-93818738-1123>;CN=unsorted-u7,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+member: <GUID=9f92d30a-fc23-11e4-a5f6-30be15454808>;<RMD_ADDTIME=131607546230000000>;<RMD_CHANGETIME=131607546230000000>;<RMD_FLAGS=0>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3765>;<RMD_ORIGINATING_USN=3765>;<RMD_VERSION=0>;<SID=S-1-5-21-4177067393-1453636373-93818738-1124>;CN=unsorted-u8,CN=Users,DC=release-4-5-0-pre1,DC=samba,DC=corp
+member: <GUID=9f92d30a-fc23-11e4-a5f6-30be15454809>;<RMD_ADDTIME=131607546230000000>;<RMD_CHANGETIME=131607546230000000>;<RMD_FLAGS=0>;<RMD_INVOCID=4e4496a3-7fb8-4f97-8a33-d238db8b5e2d>;<RMD_LOCAL_USN=3765>;<RMD_ORIGINATING_USN=3765>;<RMD_VERSION=0>;<SID=S-1-5-21-4177067393-1453636373-93818738-1125>;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-unsorted-links-after-expunge.ldif b/source4/selftest/provisions/release-4-5-0-pre1/expected-unsorted-links-after-expunge.ldif
new file mode 100644 (file)
index 0000000..d078fd9
--- /dev/null
@@ -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
index 3f7d708..d03547f 100755 (executable)
@@ -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 <<EOF