[Zodb-checkins] CVS: ZODB3/ZEO/tests - testZEO.py:1.54.2.5 winserver.py:1.11.2.3

Tim Peters tim.one at comcast.net
Fri Jul 25 19:12:41 EDT 2003


Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv14731/ZEO/tests

Modified Files:
      Tag: ZODB3-3_1-branch
	testZEO.py winserver.py 
Log Message:
Following Barry's lead, more hacks to get the ZEO-on-Berkeley tests to
run at all on Windows.  Mixed bag, mostly good:  the tests all start,
and all make it to their teardown methods without error, but then a
large number fail in teardown while trying to remove a lock file that's
apparently still open.  We did substantial work on the ZODB3 head to get a
clean lockfile story on Windows, and I'm not sure we can cure the
lockfile problems on the 3.1 branch without backporting all that.


=== ZODB3/ZEO/tests/testZEO.py 1.54.2.4 => 1.54.2.5 ===
--- ZODB3/ZEO/tests/testZEO.py:1.54.2.4	Fri Jul 25 15:39:12 2003
+++ ZODB3/ZEO/tests/testZEO.py	Fri Jul 25 18:12:35 2003
@@ -181,23 +181,13 @@
     else:
         assert 0, storage
 
-
-class BDBTests(UnixTests):
-    def getStorage(self):
-        self.__bdbdir = tempfile.mktemp()
-        return 'ZEO.tests.testZEO.BDBFactory', (self.__bdbdir, 'full')
-
-    def delStorage(self):
-        shutil.rmtree(self.__bdbdir)
-
-
 class WindowsTests(GenericTests):
 
     """Add Windows-specific scaffolding to the generic test suite."""
 
     def setUp(self):
         zLOG.LOG("testZEO", zLOG.INFO, "setUp() %s" % self.id())
-        args = self.getStorageInfo()
+        args = self.getStorage()
         name = args[0]
         args = args[1]
         zeo_addr, self.test_addr, self.test_pid = \
@@ -212,15 +202,32 @@
         s.connect(self.test_addr)
         s.close()
         # the connection should cause the storage server to die
-        time.sleep(0.5)
-        self.delStorage()
+        for countdown in (5, 4, 3, 2, 1, 0):
+            try:
+                self.delStorage()
+                break
+            except OSError:
+                # Files are still open so can't be removed on Windows.
+                if countdown == 0:
+                    raise   # give up; can't know whether it will ever work
+                else:
+                    time.sleep(0.5) # wait a bit & try again
 
-    def getStorageInfo(self):
+    def getStorage(self):
         self.__fs_base = tempfile.mktemp()
         return 'ZODB.FileStorage.FileStorage', (self.__fs_base, '1') # create=1
 
     def delStorage(self):
         removefs(self.__fs_base)
+
+class BDBTests(os.name == "nt" and WindowsTests or UnixTests):
+    def getStorage(self):
+        self.__bdbdir = tempfile.mktemp()
+        return 'ZEO.tests.testZEO.BDBFactory', (self.__bdbdir, 'full')
+
+    def delStorage(self):
+        shutil.rmtree(self.__bdbdir)
+
 
 if os.name == "posix":
     test_classes = [UnixTests]


=== ZODB3/ZEO/tests/winserver.py 1.11.2.2 => 1.11.2.3 ===
--- ZODB3/ZEO/tests/winserver.py:1.11.2.2	Tue Apr 29 11:16:36 2003
+++ ZODB3/ZEO/tests/winserver.py	Fri Jul 25 18:12:35 2003
@@ -45,10 +45,13 @@
         self.storage.close()
         os._exit(0)
 
-def load_storage_class(name):
-    package = __import__("ZODB." + name)
-    mod = getattr(package, name)
-    return getattr(mod, name)
+def load_storage(name):
+    i = name.rfind('.')
+    pkgname, classname = name[:i], name[i+1:]
+    __import__(pkgname)
+    mod = sys.modules[pkgname]
+    klass = getattr(mod, classname)
+    return klass
 
 def main(args):
     ro_svr = 0
@@ -61,7 +64,7 @@
         transaction_timeout = float(args[1])
         del args[:2]
     port, storage_name, rawargs = args[0], args[1], args[2:]
-    klass = load_storage_class(storage_name)
+    klass = load_storage(storage_name)
     args = []
     for arg in rawargs:
         if arg.startswith('='):




More information about the Zodb-checkins mailing list