From 172eedc0760b5d471af091c2f08ea70f17b36293 Mon Sep 17 00:00:00 2001 From: Tim Beale Date: Tue, 23 May 2017 14:37:56 +1200 Subject: [PATCH] getnc_exop.py: Fix GET_TGT behaviour in DRS tests The existing code never passed the more_flags parameter into the actual getNCChanges request, i.e. _getnc_req10(). This meant the existing GET_TGT tests effectively did nothing. Passing the flag through properly means we have to now change the tests as the DNs returned by Windows now include any target objects in the linked attributes. These tests now fail against Samba (because it doesn't support GET_TGT yet). Also added comments to the tests to help explain what they are actually doing. Note that Samba and Windows can return the objects in different orders, due to significant differences in their underlying DB implementations (Windows stores links in a separate DB, so sends links ordered strictly by USN, whereas Samba sends links based on the USN of the source object). To make the test a fair comparison between Windows and Samba, we need to use dn_ordered=False. Signed-off-by: Tim Beale Reviewed-by: Andrew Bartlett Reviewed-by: Garming Sam --- selftest/knownfail.d/getnc_exop | 4 ++++ source4/torture/drs/python/drs_base.py | 3 ++- source4/torture/drs/python/getnc_exop.py | 20 ++++++++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 selftest/knownfail.d/getnc_exop diff --git a/selftest/knownfail.d/getnc_exop b/selftest/knownfail.d/getnc_exop new file mode 100644 index 00000000000..0018b0bbd07 --- /dev/null +++ b/selftest/knownfail.d/getnc_exop @@ -0,0 +1,4 @@ +# This test fails because Samba doesn't support the GET_TGT option +samba4.drs.getnc_exop.python\(vampire_dc\).getnc_exop.DrsReplicaSyncTestCase.test_link_utdv_hwm\(vampire_dc\) +samba4.drs.getnc_exop.python\(promoted_dc\).getnc_exop.DrsReplicaSyncTestCase.test_link_utdv_hwm\(promoted_dc\) + diff --git a/source4/torture/drs/python/drs_base.py b/source4/torture/drs/python/drs_base.py index e79f076268c..57bb0545ea0 100644 --- a/source4/torture/drs/python/drs_base.py +++ b/source4/torture/drs/python/drs_base.py @@ -279,7 +279,8 @@ class DrsBaseTestCase(SambaToolCmdTest): nc_dn_str=nc_dn_str, exop=exop, max_objects=max_objects, - replica_flags=replica_flags) + replica_flags=replica_flags, + more_flags=more_flags) req10.highwatermark = highwatermark if uptodateness_vector is not None: uptodateness_vector_v1 = drsuapi.DsReplicaCursorCtrEx() diff --git a/source4/torture/drs/python/getnc_exop.py b/source4/torture/drs/python/getnc_exop.py index 37e5333e245..b87404926f2 100644 --- a/source4/torture/drs/python/getnc_exop.py +++ b/source4/torture/drs/python/getnc_exop.py @@ -434,11 +434,16 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): drsuapi.DRSUAPI_DRS_GET_ANC, expected_links=[dc3_managedBy_ou1]) - self._check_replication([dc3], + # GET_TGT seems to override DRS_CRITICAL_ONLY and also returns any + # object(s) that relate to the linked attributes (similar to GET_ANC) + self._check_replication([ou1, dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY, more_flags=drsuapi.DRSUAPI_DRS_GET_TGT, - expected_links=[dc3_managedBy_ou1]) + expected_links=[dc3_managedBy_ou1], dn_ordered=False) + # Change DC3's managedBy to OU2 instead of OU1 + # Note that the OU1 managedBy linked attribute will still exist as + # a tombstone object (and so will be returned in the replication still) m = ldb.Message() m.dn = ldb.Dn(self.ldb_dc1, dc3) m["managedBy"] = ldb.MessageElement(ou2, ldb.FLAG_MOD_REPLACE, "managedBy") @@ -467,11 +472,16 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): drsuapi.DRSUAPI_DRS_GET_ANC, expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2]) - self._check_replication([dc3], + # GET_TGT will also return any DNs referenced by the linked attributes + # (including the Tombstone attribute) + self._check_replication([ou1, ou2, dc3], drsuapi.DRSUAPI_DRS_CRITICAL_ONLY, more_flags=drsuapi.DRSUAPI_DRS_GET_TGT, - expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2]) + expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], dn_ordered=False) + # Use the highwater-mark prior to changing ManagedBy - this should + # only return the old/Tombstone and new linked attributes (we already + # know all the DNs) self._check_replication([], drsuapi.DRSUAPI_DRS_WRIT_REP, expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], @@ -500,6 +510,8 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase): expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], highwatermark=hwm7) + # Repeat the above set of tests using the uptodateness_vector + # instead of the highwater-mark self._check_replication([], drsuapi.DRSUAPI_DRS_WRIT_REP, expected_links=[dc3_managedBy_ou1,dc3_managedBy_ou2], -- 2.25.1