selftest: Add test for initial link attribute RMD_VERSION value
authorTim Beale <timbeale@catalyst.net.nz>
Thu, 28 Sep 2017 01:42:08 +0000 (14:42 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 20 Oct 2017 02:05:21 +0000 (04:05 +0200)
While testing link conflicts I noticed that links on Windows start from
a different RMD_VERSION compared to Samba. This adds a simple test to
highlight the problem.

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

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/knownfail.d/link_conflicts [new file with mode: 0644]
source4/torture/drs/python/link_conflicts.py

diff --git a/selftest/knownfail.d/link_conflicts b/selftest/knownfail.d/link_conflicts
new file mode 100644 (file)
index 0000000..8c1c94f
--- /dev/null
@@ -0,0 +1,5 @@
+# Samba starts its RMD_VERSION from zero. Windows starts from one.
+samba4.drs.link_conflicts.python\(vampire_dc\).link_conflicts.DrsReplicaLinkConflictTestCase.test_link_attr_version\(vampire_dc\)
+samba4.drs.link_conflicts.python\(promoted_dc\).link_conflicts.DrsReplicaLinkConflictTestCase.test_link_attr_version\(promoted_dc\)
+
+
index c8b65563ad6900d6d93018b5e5c4352d1ae211c0..6522fb610d69be60e7f47b59dc80c334645dbb54 100644 (file)
@@ -141,14 +141,16 @@ class DrsReplicaLinkConflictTestCase(drs_base.DrsBaseTestCase):
             self.assertTrue(val in res2[0][attr],
                             "%s '%s' not found on DC2" %(attr, val))
 
-    def _check_replicated_links(self, src_obj_dn, expected_links):
-        """Checks that replication sends back the expected linked attributes"""
-
+    def zero_highwatermark(self):
+        """Returns a zeroed highwatermark so that all DRS data gets returned"""
         hwm = drsuapi.DsReplicaHighWaterMark()
         hwm.tmp_highest_usn = 0
         hwm.reserved_usn = 0
         hwm.highest_usn = 0
+        return hwm
 
+    def _check_replicated_links(self, src_obj_dn, expected_links):
+        """Checks that replication sends back the expected linked attributes"""
         self._check_replication([src_obj_dn],
                                 drsuapi.DRSUAPI_DRS_WRIT_REP,
                                 dest_dsa=None,
@@ -156,7 +158,7 @@ class DrsReplicaLinkConflictTestCase(drs_base.DrsBaseTestCase):
                                 nc_dn_str=src_obj_dn,
                                 exop=drsuapi.DRSUAPI_EXOP_REPL_OBJ,
                                 expected_links=expected_links,
-                                highwatermark=hwm)
+                                highwatermark=self.zero_highwatermark())
 
         # Check DC2 as well
         self.set_test_ldb_dc(self.ldb_dc2)
@@ -168,7 +170,7 @@ class DrsReplicaLinkConflictTestCase(drs_base.DrsBaseTestCase):
                                 nc_dn_str=src_obj_dn,
                                 exop=drsuapi.DRSUAPI_EXOP_REPL_OBJ,
                                 expected_links=expected_links,
-                                highwatermark=hwm,
+                                highwatermark=self.zero_highwatermark(),
                                 drs=self.drs2, drs_handle=self.drs2_handle)
         self.set_test_ldb_dc(self.ldb_dc1)
 
@@ -698,3 +700,28 @@ class DrsReplicaLinkConflictTestCase(drs_base.DrsBaseTestCase):
         self._test_conflict_existing_single_valued_link(sync_order=DC1_TO_DC2)
         self._test_conflict_existing_single_valued_link(sync_order=DC2_TO_DC1)
 
+    def test_link_attr_version(self):
+        """
+        Checks the link attribute version starts from the correct value
+        """
+        # create some objects and add a link
+        src_ou = self.unique_dn("OU=src")
+        src_guid = self.add_object(self.ldb_dc1, src_ou)
+        target1_ou = self.unique_dn("OU=target1")
+        target1_guid = self.add_object(self.ldb_dc1, target1_ou)
+        self.add_link_attr(self.ldb_dc1, src_ou, "managedBy", target1_ou)
+
+        # get the link info via replication
+        ctr6 = self._get_replication(drsuapi.DRSUAPI_DRS_WRIT_REP,
+                                     dest_dsa=None,
+                                     drs_error=drsuapi.DRSUAPI_EXOP_ERR_SUCCESS,
+                                     exop=drsuapi.DRSUAPI_EXOP_REPL_OBJ,
+                                     highwatermark=self.zero_highwatermark(),
+                                     nc_dn_str=src_ou)
+
+        self.assertTrue(ctr6.linked_attributes_count == 1,
+                        "DRS didn't return a link")
+        link = ctr6.linked_attributes[0]
+        self.assertTrue(link.meta_data.version == 1,
+                        "Link version started from %u, not 1" % link.meta_data.version)
+