summaryrefslogtreecommitdiff
path: root/source4/torture/drs
diff options
context:
space:
mode:
authorTim Beale <timbeale@catalyst.net.nz>2017-09-18 12:39:21 +1200
committerAndrew Bartlett <abartlet@samba.org>2017-09-26 05:33:17 +0200
commit1b395f488a94f2e2811622b61a8c750374d640ed (patch)
tree985eeb41faeff896e3e1863cf0c13cde0d6bc2f2 /source4/torture/drs
parent3982b774f4f41661e890dc2ef2d9403db33c7195 (diff)
downloadsamba-1b395f488a94f2e2811622b61a8c750374d640ed.tar.gz
selftest: replica_sync did not fully cleanup if test failed
Normally the replica_sync tests do the cleanup at the end of the test case, rather than in the tearDown(). However, if the tests don't run to completion (because they fail), then the objects may not get cleaned up properly, which causes the tests to fail on the 2nd test-env. The problem is the object deletion only occurs on DC2 and it relies on replication to propagate the deletion to DC1. Presumably this propagation could be missed because the tests are repeatedly turning off inbound replication on both DCs. This patch changes the tearDown() so it tries to delete the objects off both DCs, which appears to fix the problem. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'source4/torture/drs')
-rw-r--r--source4/torture/drs/python/replica_sync.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/source4/torture/drs/python/replica_sync.py b/source4/torture/drs/python/replica_sync.py
index dd9f2763cfb..0886637c71d 100644
--- a/source4/torture/drs/python/replica_sync.py
+++ b/source4/torture/drs/python/replica_sync.py
@@ -45,23 +45,27 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase):
self.ou2 = None
def tearDown(self):
+ self._cleanup_object(self.ou1)
+ self._cleanup_object(self.ou2)
+
# re-enable replication
self._enable_inbound_repl(self.dnsname_dc1)
self._enable_inbound_repl(self.dnsname_dc2)
- if self.ldb_dc2 is not None:
- if self.ou1 is not None:
- try:
- self.ldb_dc2.delete('<GUID=%s>' % self.ou1, ["tree_delete:1"])
- except LdbError, (num, _):
- self.assertEquals(num, ERR_NO_SUCH_OBJECT)
- if self.ou2 is not None:
- try:
- self.ldb_dc2.delete('<GUID=%s>' % self.ou2, ["tree_delete:1"])
- except LdbError, (num, _):
- self.assertEquals(num, ERR_NO_SUCH_OBJECT)
super(DrsReplicaSyncTestCase, self).tearDown()
+ def _cleanup_object(self, guid):
+ """Cleans up a test object, if it still exists"""
+ if guid is not None:
+ try:
+ self.ldb_dc2.delete('<GUID=%s>' % guid, ["tree_delete:1"])
+ except LdbError, (num, _):
+ self.assertEquals(num, ERR_NO_SUCH_OBJECT)
+ try:
+ self.ldb_dc1.delete('<GUID=%s>' % guid, ["tree_delete:1"])
+ except LdbError, (num, _):
+ self.assertEquals(num, ERR_NO_SUCH_OBJECT)
+
def test_ReplEnabled(self):
"""Tests we can replicate when replication is enabled"""
self._enable_inbound_repl(self.dnsname_dc1)