selftest: Add assertion that we actually fix the replPropertyMetaData sort order
authorAndrew Bartlett <abartlet@samba.org>
Mon, 3 Aug 2015 01:50:08 +0000 (13:50 +1200)
committerStefan Metzmacher <metze@samba.org>
Tue, 25 Aug 2015 00:45:58 +0000 (02:45 +0200)
This ensures that the dbcheck rule fixes the sort order (and only fixes the sort order).

BUG: https://bugzilla.samba.org/show_bug.cgi?id=10973

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Tue Aug 25 02:45:58 CEST 2015 on sn-devel-104

source4/selftest/provisions/release-4-1-0rc3/expected-replpropertymetadata-after-dbcheck.ldif [new file with mode: 0644]
source4/selftest/provisions/release-4-1-0rc3/expected-replpropertymetadata-before-dbcheck.ldif [new file with mode: 0644]
testprogs/blackbox/dbcheck-oldrelease.sh

diff --git a/source4/selftest/provisions/release-4-1-0rc3/expected-replpropertymetadata-after-dbcheck.ldif b/source4/selftest/provisions/release-4-1-0rc3/expected-replpropertymetadata-after-dbcheck.ldif
new file mode 100644 (file)
index 0000000..e6cdedc
--- /dev/null
@@ -0,0 +1,122 @@
+# record 1
+dn: CN=ops_run_anything,OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp
+objectClass: top
+objectClass: sudoRole
+cn: ops_run_anything
+instanceType: 4
+whenCreated: 20150802225130.0Z
+uSNCreated: 3514
+name: ops_run_anything
+objectGUID: 0609a23b-81a4-44c0-9220-b89085775441
+objectCategory: CN=sudoRole,CN=Schema,CN=Configuration,DC=release-4-1-0rc3,DC=samba,DC=corp
+sudoHost: ALL
+sudoCommand: ALL
+sudoRunAsUser: ALL
+sudoRunAsGroup: ALL
+whenChanged: 20150802225647.0Z
+uSNChanged: 3515
+replPropertyMetaData:     NDR: struct replPropertyMetaDataBlob
+        version                  : 0x00000001 (1)
+        reserved                 : 0x00000000 (0)
+        ctr                      : union replPropertyMetaDataCtr(case 1)
+        ctr1: struct replPropertyMetaDataCtr1
+            count                    : 0x0000000d (13)
+            reserved                 : 0x00000000 (0)
+            array: ARRAY(13)
+                array: struct replPropertyMetaData1
+                    attid                    : DRSUAPI_ATTID_objectClass (0x0)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : DRSUAPI_ATTID_instanceType (0x20001)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : DRSUAPI_ATTID_whenCreated (0x20002)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : DRSUAPI_ATTID_ntSecurityDescriptor (0x20119)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : DRSUAPI_ATTID_name (0x90001)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : DRSUAPI_ATTID_objectCategory (0x9030E)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : UNKNOWN_ENUM_VALUE (0x290001)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:56:47 2015 UTC
+                    originating_invocation_id: b249ef44-b215-4d3b-b5d6-7cec08154b7a
+                    originating_usn          : 0x0000000000000dbb (3515)
+                    local_usn                : 0x0000000000000dbb (3515)
+                array: struct replPropertyMetaData1
+                    attid                    : UNKNOWN_ENUM_VALUE (0x9DDA71B0)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : UNKNOWN_ENUM_VALUE (0x9DDA71B1)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : UNKNOWN_ENUM_VALUE (0x9DDA71B2)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : UNKNOWN_ENUM_VALUE (0x9DDA71B5)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : UNKNOWN_ENUM_VALUE (0x9DDA71B6)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : DRSUAPI_ATTID_cn (0x3)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+
+distinguishedName: CN=ops_run_anything,OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp
+
+# returned 1 records
+# 1 entries
+# 0 referrals
diff --git a/source4/selftest/provisions/release-4-1-0rc3/expected-replpropertymetadata-before-dbcheck.ldif b/source4/selftest/provisions/release-4-1-0rc3/expected-replpropertymetadata-before-dbcheck.ldif
new file mode 100644 (file)
index 0000000..af9d827
--- /dev/null
@@ -0,0 +1,122 @@
+# record 1
+dn: CN=ops_run_anything,OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp
+objectClass: top
+objectClass: sudoRole
+cn: ops_run_anything
+instanceType: 4
+whenCreated: 20150802225130.0Z
+uSNCreated: 3514
+name: ops_run_anything
+objectGUID: 0609a23b-81a4-44c0-9220-b89085775441
+objectCategory: CN=sudoRole,CN=Schema,CN=Configuration,DC=release-4-1-0rc3,DC=samba,DC=corp
+sudoHost: ALL
+sudoCommand: ALL
+sudoRunAsUser: ALL
+sudoRunAsGroup: ALL
+replPropertyMetaData:     NDR: struct replPropertyMetaDataBlob
+        version                  : 0x00000001 (1)
+        reserved                 : 0x00000000 (0)
+        ctr                      : union replPropertyMetaDataCtr(case 1)
+        ctr1: struct replPropertyMetaDataCtr1
+            count                    : 0x0000000d (13)
+            reserved                 : 0x00000000 (0)
+            array: ARRAY(13)
+                array: struct replPropertyMetaData1
+                    attid                    : UNKNOWN_ENUM_VALUE (0x9DDA71B0)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : UNKNOWN_ENUM_VALUE (0x9DDA71B1)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : UNKNOWN_ENUM_VALUE (0x9DDA71B2)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : UNKNOWN_ENUM_VALUE (0x9DDA71B5)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : UNKNOWN_ENUM_VALUE (0x9DDA71B6)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : DRSUAPI_ATTID_objectClass (0x0)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : DRSUAPI_ATTID_instanceType (0x20001)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : DRSUAPI_ATTID_whenCreated (0x20002)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : DRSUAPI_ATTID_ntSecurityDescriptor (0x20119)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : DRSUAPI_ATTID_name (0x90001)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : DRSUAPI_ATTID_objectCategory (0x9030E)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+                array: struct replPropertyMetaData1
+                    attid                    : UNKNOWN_ENUM_VALUE (0x290001)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:56:47 2015 UTC
+                    originating_invocation_id: b249ef44-b215-4d3b-b5d6-7cec08154b7a
+                    originating_usn          : 0x0000000000000dbb (3515)
+                    local_usn                : 0x0000000000000dbb (3515)
+                array: struct replPropertyMetaData1
+                    attid                    : DRSUAPI_ATTID_cn (0x3)
+                    version                  : 0x00000001 (1)
+                    originating_change_time  : Sun Aug  2 22:51:30 2015 UTC
+                    originating_invocation_id: 7b2e1a86-f4d6-4e7f-a49f-d40f3596aa63
+                    originating_usn          : 0x0000000000000eb1 (3761)
+                    local_usn                : 0x0000000000000dba (3514)
+
+whenChanged: 20150802225647.0Z
+uSNChanged: 3515
+distinguishedName: CN=ops_run_anything,OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp
+
+# returned 1 records
+# 1 entries
+# 0 referrals
index fdb553be0f3e42baa03f3a782c5df97134857a5d..22942dd2b1037f2ed14849bc2b9fef7c04dddf0a 100755 (executable)
@@ -20,6 +20,11 @@ if [ -x "$BINDIR/ldbmodify" ]; then
     ldbmodify="$BINDIR/ldbmodify"
 fi
 
+ldbsearch="ldbsearch"
+if [ -x "$BINDIR/ldbsearch" ]; then
+    ldbsearch="$BINDIR/ldbsearch"
+fi
+
 undump() {
        if test -x $BINDIR/tdbrestore;
        then
@@ -136,10 +141,35 @@ reindex() {
        $PYTHON $BINDIR/samba-tool dbcheck --reindex -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $@
 }
 
+check_expected_before_values() {
+    if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+       tmpldif=$PREFIX_ABS/$RELEASE/expected-replpropertymetadata-before-dbcheck.ldif.tmp
+       TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -s base -b CN=ops_run_anything,OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp \* replpropertymetadata --show-binary > $tmpldif
+       diff $tmpldif $release_dir/expected-replpropertymetadata-before-dbcheck.ldif
+       if [ "$?" != "0" ]; then
+           return 1
+       fi
+    fi
+    return 0
+}
+
 # This should 'fail', because it returns the number of modified records
 dbcheck() {
        $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs --fix --yes -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $@
 }
+
+check_expected_after_values() {
+    if [ x$RELEASE = x"release-4-1-0rc3" ]; then
+       tmpldif=$PREFIX_ABS/$RELEASE/expected-replpropertymetadata-after-dbcheck.ldif.tmp
+       TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -s base -b CN=ops_run_anything,OU=SUDOers,DC=release-4-1-0rc3,DC=samba,DC=corp \* replpropertymetadata --show-binary > $tmpldif
+       diff -u $tmpldif $release_dir/expected-replpropertymetadata-after-dbcheck.ldif
+       if [ "$?" != "0" ]; then
+           return 1
+       fi
+    fi
+    return 0
+}
+
 # But having fixed it all up, this should pass
 dbcheck_clean() {
        $PYTHON $BINDIR/samba-tool dbcheck --cross-ncs -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $@
@@ -198,7 +228,9 @@ ldapcmp_sd() {
 if [ -d $release_dir ]; then
     testit $RELEASE undump
     testit "reindex" reindex
+    testit "check_expected_before_values" check_expected_before_values
     testit_expect_failure "dbcheck" dbcheck
+    testit "check_expected_after_values" check_expected_after_values
     testit "dbcheck_clean" dbcheck_clean
     testit_expect_failure "dbcheck_acl_reset" dbcheck_acl_reset
     testit "dbcheck_acl_reset_clean" dbcheck_acl_reset_clean
@@ -220,6 +252,10 @@ EOF
     subunit_start_test "reindex"
     subunit_skip_test "reindex" <<EOF
 no test provision
+EOF
+    subunit_start_test check_expected_before_values
+    subunit_skip_test check_expected_before_values<<EOF
+no test provision
 EOF
     subunit_start_test "dbcheck"
     subunit_skip_test "dbcheck" <<EOF
@@ -228,6 +264,10 @@ EOF
     subunit_start_test "dbcheck_clean"
     subunit_skip_test "dbcheck_clean" <<EOF
 no test provision
+EOF
+    subunit_start_test check_expected_after_values
+    subunit_skip_test check_expected_after_values<<EOF
+no test provision
 EOF
     subunit_start_test "dbcheck_acl_reset"
     subunit_skip_test "dbcheck_acl_reset" <<EOF
@@ -255,6 +295,11 @@ EOF
     subunit_start_test add_userparameters3
     subunit_skip_test add_userparameters3<<EOF
 no test provision
+EOF
+
+    subunit_start_test check_expected_before_values
+    subunit_skip_test check_expected_before_values<<EOF
+no test provision
 EOF
 
     subunit_start_test "dbcheck2"
@@ -277,7 +322,7 @@ EOF
 fi
 
 if [ -d $PREFIX_ABS/${RELEASE} ]; then
-  rm -fr $PREFIX_ABS/${RELEASE}
+    rm -fr $PREFIX_ABS/${RELEASE}
 fi
 
 if [ -d $PREFIX_ABS/${RELEASE}_reference ]; then