s4-test/repl_schema: Remote global ldb connections
authorKamen Mazdrashki <kamenim@samba.org>
Mon, 22 Nov 2010 13:06:36 +0000 (15:06 +0200)
committerKamen Mazdrashki <kamenim@samba.org>
Mon, 22 Nov 2010 14:24:03 +0000 (15:24 +0100)
Although unlikely, Jelmer pointed out that using persistent
SamDB connections between test may interfere with tests
behaviour (and is not xUnit compliant anyway)

Autobuild-User: Kamen Mazdrashki <kamenim@samba.org>
Autobuild-Date: Mon Nov 22 15:24:03 CET 2010 on sn-devel-104

source4/torture/drs/python/repl_schema.py

index 78759e196be44bcc8c40825d54e2f19e953d60ef..4016ed210543079bb0e99c1925f560e0a569d5ca 100644 (file)
@@ -44,21 +44,19 @@ import samba.tests
 
 class DrsReplSchemaTestCase(samba.tests.TestCase):
 
-    # RootDSE msg for DC1
-    info_dc1 = None
-    ldb_dc1 = None
-    # RootDSE msg for DC1
-    info_dc2 = None
-    ldb_dc2 = None
     # prefix for all objects created
     obj_prefix = None
 
     def setUp(self):
         super(DrsReplSchemaTestCase, self).setUp()
 
-        # connect to DCs singleton
-        self._dc_connect("dc1", "DC1", ldap_only=True)
-        self._dc_connect("dc2", "DC2", ldap_only=True)
+        # connect to DCs
+        url_dc = samba.tests.env_get_var_value("DC1")
+        (self.ldb_dc1, self.info_dc1) = samba.tests.connect_samdb_ex(url_dc, 
+                                                                     ldap_only=True)
+        url_dc = samba.tests.env_get_var_value("DC2")
+        (self.ldb_dc2, self.info_dc2) = samba.tests.connect_samdb_ex(url_dc, 
+                                                                     ldap_only=True)
 
         # initialize objects prefix if not done yet
         if self.obj_prefix is None:
@@ -78,22 +76,6 @@ class DrsReplSchemaTestCase(samba.tests.TestCase):
     def tearDown(self):
         super(DrsReplSchemaTestCase, self).tearDown()
 
-    @classmethod
-    def _dc_connect(cls, attr_name, env_var, ldap_only=True):
-        ldb_dc = None
-        attr_name_ldb = "ldb_" + attr_name
-        if hasattr(cls, attr_name_ldb):
-            ldb_dc = getattr(cls, attr_name_ldb)
-        if ldb_dc is None:
-            url_dc = samba.tests.env_get_var_value(env_var)
-            ldb_dc = samba.tests.connect_samdb(url_dc, ldap_only=ldap_only)
-            res = ldb_dc.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"])
-            info_dc = res[0]
-            setattr(cls, "ldb_" + attr_name, ldb_dc)
-            setattr(cls, "url_" + attr_name, url_dc)
-            setattr(cls, "info_" + attr_name, info_dc)
-        return ldb_dc
-
     def _net_drs_replicate(self, DC, fromDC, nc_dn):
         """Triggers replication cycle on 'DC' to
            replicate from 'fromDC'. Naming context to