[Zodb-checkins] CVS: ZODB3/BDBStorage/tests - BerkeleyTestBase.py:1.7.4.1 ZODBTestBase.py:1.5.4.1 test_create.py:1.11.6.1 test_storage_api.py:1.23.2.1 test_virgin.py:1.10.6.1 test_zodb_simple.py:1.8.4.1 timeiter.py:1.3.6.1 timepickles.py:1.2.4.1

Barry Warsaw barry@wooz.org
Tue, 7 Jan 2003 14:40:51 -0500


Update of /cvs-repository/ZODB3/BDBStorage/tests
In directory cvs.zope.org:/tmp/cvs-serv24866/BDBStorage/tests

Modified Files:
      Tag: ZODB3-3_1-branch
	BerkeleyTestBase.py ZODBTestBase.py test_create.py 
	test_storage_api.py test_virgin.py test_zodb_simple.py 
	timeiter.py timepickles.py 
Log Message:
Sync'ing with the trunk for BDBStorage.  Note though that the
RecoveryStorage tests refactored on the trunk are disabled on the
branch.



=== ZODB3/BDBStorage/tests/BerkeleyTestBase.py 1.7 => 1.7.4.1 ===
--- ZODB3/BDBStorage/tests/BerkeleyTestBase.py:1.7	Tue Sep  3 13:21:52 2002
+++ ZODB3/BDBStorage/tests/BerkeleyTestBase.py	Tue Jan  7 14:40:44 2003
@@ -2,20 +2,23 @@
 #
 # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE
-# 
+#
 ##############################################################################
 
-# Basic test framework class for both the Full and Minimal Berkeley storages
+# Basic test framework class for both the BDBFullStorage and BDBMinimalStorage
+# Berkeley storages
 
 import os
 import errno
+
+from BDBStorage.BerkeleyBase import BerkeleyConfig
 from ZODB.tests.StorageTestBase import StorageTestBase
 
 DBHOME = 'test-db'
@@ -23,44 +26,48 @@
 
 
 class BerkeleyTestBase(StorageTestBase):
-    def _zap_dbhome(self):
+    def _zap_dbhome(self, dir):
         # If the tests exited with any uncommitted objects, they'll blow up
         # subsequent tests because the next transaction commit will try to
         # commit those object.  But they're tied to closed databases, so
         # that's broken.  Aborting the transaction now saves us the headache.
         try:
-            for file in os.listdir(DBHOME):
-                os.unlink(os.path.join(DBHOME, file))
-            os.removedirs(DBHOME)
+            for file in os.listdir(dir):
+                os.unlink(os.path.join(dir, file))
+            os.removedirs(dir)
         except OSError, e:
-            if e.errno <> errno.ENOENT: raise
+            if e.errno <> errno.ENOENT:
+                raise
 
-    def setUp(self):
-        StorageTestBase.setUp(self)
-        self._zap_dbhome()
-        os.mkdir(DBHOME)
+    def _mk_dbhome(self, dir):
+        # Checkpointing just slows the tests down because we have to wait for
+        # the thread to properly shutdown.  This can take up to 10 seconds, so
+        # for the purposes of the test suite we shut off this thread.
+        config = BerkeleyConfig()
+        config.interval = 0
+        os.mkdir(dir)
         try:
-            self._storage = self.ConcreteStorage(DBHOME)
+            return self.ConcreteStorage(dir, config=config)
         except:
-            self._zap_dbhome()
+            self._zap_dbhome(dir)
             raise
 
+    def setUp(self):
+        StorageTestBase.setUp(self)
+        self._zap_dbhome(DBHOME)
+        self._storage = self._mk_dbhome(DBHOME)
+
     def tearDown(self):
         StorageTestBase.tearDown(self)
-        self._zap_dbhome()
+        self._zap_dbhome(DBHOME)
 
 
 
 class MinimalTestBase(BerkeleyTestBase):
-    from bsddb3Storage import Minimal
-    ConcreteStorage = Minimal.Minimal
+    from BDBStorage import BDBMinimalStorage
+    ConcreteStorage = BDBMinimalStorage.BDBMinimalStorage
 
 
 class FullTestBase(BerkeleyTestBase):
-    from bsddb3Storage import Full
-    ConcreteStorage = Full.Full
-
-
-class AutopackTestBase(BerkeleyTestBase):
-    from bsddb3Storage import Autopack
-    ConcreteStorage = Autopack.Autopack
+    from BDBStorage import BDBFullStorage
+    ConcreteStorage = BDBFullStorage.BDBFullStorage


=== ZODB3/BDBStorage/tests/ZODBTestBase.py 1.5 => 1.5.4.1 ===
--- ZODB3/BDBStorage/tests/ZODBTestBase.py:1.5	Tue Sep  3 13:21:20 2002
+++ ZODB3/BDBStorage/tests/ZODBTestBase.py	Tue Jan  7 14:40:44 2003
@@ -18,7 +18,7 @@
 import errno
 
 from ZODB import DB
-from bsddb3Storage.tests.BerkeleyTestBase import BerkeleyTestBase
+from BDBStorage.tests.BerkeleyTestBase import BerkeleyTestBase
 
 DBHOME = 'test-db'
 
@@ -27,8 +27,8 @@
 class ZODBTestBase(BerkeleyTestBase):
     def setUp(self):
         BerkeleyTestBase.setUp(self)
+        self._db = None
         try:
-            self._storage = self.ConcreteStorage(DBHOME)
             self._db = DB(self._storage)
             self._conn = self._db.open()
             self._root = self._conn.root()


=== ZODB3/BDBStorage/tests/test_create.py 1.11 => 1.11.6.1 ===
--- ZODB3/BDBStorage/tests/test_create.py:1.11	Mon Feb 11 18:40:43 2002
+++ ZODB3/BDBStorage/tests/test_create.py	Tue Jan  7 14:40:44 2003
@@ -2,21 +2,28 @@
 #
 # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE
-# 
+#
 ##############################################################################
 
 # Unit test for database creation
 
 import os
+import time
 import unittest
-import BerkeleyTestBase    
+
+import BDBStorage
+if BDBStorage.is_available:
+    from BDBStorage.BerkeleyBase import BerkeleyConfig
+    from BDBStorage.BDBFullStorage import BDBFullStorage
+
+from BDBStorage.tests import BerkeleyTestBase
 
 
 
@@ -25,21 +32,16 @@
         self.failUnless(os.path.isdir(BerkeleyTestBase.DBHOME))
 
 
-class MinimalCreateTest(BerkeleyTestBase.BerkeleyTestBase,
-                        BerkeleyTestBase.MinimalTestBase,
-                        TestMixin):
+class MinimalCreateTest(BerkeleyTestBase.MinimalTestBase, TestMixin):
     pass
 
 
-class FullCreateTest(BerkeleyTestBase.BerkeleyTestBase,
-                     BerkeleyTestBase.FullTestBase,
-                     TestMixin):
+class FullCreateTest(BerkeleyTestBase.FullTestBase, TestMixin):
     pass
 
 
 
-class FullOpenExistingTest(BerkeleyTestBase.BerkeleyTestBase,
-                           BerkeleyTestBase.FullTestBase):
+class FullOpenExistingTest(BerkeleyTestBase.FullTestBase):
     def checkOpenWithExistingVersions(self):
         version = 'test-version'
         oid = self._storage.new_oid()
@@ -71,11 +73,48 @@
 
 
 
+class FullOpenCloseTest(BerkeleyTestBase.FullTestBase):
+    def _mk_dbhome(self, dir):
+        config = BerkeleyConfig
+        config.interval = 10
+        os.mkdir(dir)
+        try:
+            return self.ConcreteStorage(dir, config=config)
+        except:
+            self._zap_dbhome(dir)
+            raise
+
+    def checkCloseWithCheckpointingThread(self):
+        # All the interesting stuff happens in the setUp and tearDown
+        time.sleep(20)
+
+
+
+class OpenRecoveryTest(BerkeleyTestBase.FullTestBase):
+    def _mk_dbhome(self, dir):
+        self._dir = dir
+
+    def checkOpenWithBogusConfig(self):
+        class C: pass
+        c = C()
+        # This instance won't have the necessary attributes, so the creation
+        # will fail.  We want to be sure that everything gets cleaned up
+        # enough to fix that and create a proper storage.
+        self.assertRaises(AttributeError, BDBFullStorage, self._dir, config=c)
+        c = BerkeleyConfig()
+        s = BDBFullStorage(self._dir, config=c)
+        s.close()
+
+
+
 def test_suite():
     suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(MinimalCreateTest, 'check'))
-    suite.addTest(unittest.makeSuite(FullCreateTest, 'check'))
-    suite.addTest(unittest.makeSuite(FullOpenExistingTest, 'check'))
+    if BDBStorage.is_available:
+        suite.addTest(unittest.makeSuite(MinimalCreateTest, 'check'))
+        suite.addTest(unittest.makeSuite(FullCreateTest, 'check'))
+        suite.addTest(unittest.makeSuite(FullOpenExistingTest, 'check'))
+        suite.addTest(unittest.makeSuite(FullOpenCloseTest, 'check'))
+        suite.addTest(unittest.makeSuite(OpenRecoveryTest, 'check'))
     return suite
 
 


=== ZODB3/BDBStorage/tests/test_storage_api.py 1.23 => 1.23.2.1 ===
--- ZODB3/BDBStorage/tests/test_storage_api.py:1.23	Thu Oct  3 13:33:43 2002
+++ ZODB3/BDBStorage/tests/test_storage_api.py	Tue Jan  7 14:40:44 2003
@@ -1,27 +1,25 @@
 ##############################################################################
 #
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# Copyright (c) 2001, 2002, 2003 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE
-# 
+#
 ##############################################################################
 
 # Unit tests for basic storage functionality
 
 import unittest
-# Import this here and now so that import failures properly cause the test
-# suite to ignore these tests.
-import bsddb3
-
 from ZODB import POSException
 
-import BerkeleyTestBase
+import BDBStorage
+from BDBStorage.tests import BerkeleyTestBase
+
 from ZODB.tests.BasicStorage import BasicStorage
 from ZODB.tests.RevisionStorage import RevisionStorage
 from ZODB.tests.VersionStorage import VersionStorage
@@ -30,7 +28,9 @@
      TransactionalUndoVersionStorage
 from ZODB.tests.PackableStorage import PackableStorage
 from ZODB.tests.HistoryStorage import HistoryStorage
-from ZODB.tests.IteratorStorage import IteratorStorage
+from ZODB.tests.IteratorStorage import IteratorStorage, ExtendedIteratorStorage
+# XXX The refactored RecoveryStorage test is only available on the trunk.
+#from ZODB.tests.RecoveryStorage import RecoveryStorage
 from ZODB.tests import ConflictResolution
 
 
@@ -47,40 +47,41 @@
 class FullTest(BerkeleyTestBase.FullTestBase, BasicStorage,
                RevisionStorage, VersionStorage,
                TransactionalUndoStorage,
-               TransactionalUndoVersionStorage, PackableStorage,
-               HistoryStorage, IteratorStorage,
+               TransactionalUndoVersionStorage,
+               PackableStorage,
+               HistoryStorage,
+               IteratorStorage, ExtendedIteratorStorage,
                ConflictResolution.ConflictResolvingStorage,
                ConflictResolution.ConflictResolvingTransUndoStorage):
-
-    # BAW: This test fails, it should be fixed.
-    # DBNotFoundError: (-30990, 'DB_NOTFOUND: No matching key/data pair found')
-    def checkVersionIterator(self):
-        import sys
-        print >> sys.stderr, \
-              'FullTest.checkVersionIterator() temporarily disabled.'
+    pass
 
 
-    def checkTransactionalUndoAfterPackWithObjectUnlinkFromRoot(self):
-        # the current berkeley storage fails this test, but we don't
-        # intend to fix it for this version of the code.
-        pass
-
+
+DST_DBHOME = 'test-dst'
 
-class AutopackTest(BerkeleyTestBase.AutopackTestBase, BasicStorage):
-    def checkVersionedStoreAndLoad(self):
-        # This storage doesn't support versions, so we should get an exception
-        oid = self._storage.new_oid()
-        self.assertRaises(POSException.Unsupported,
-                          self._dostore,
-                          oid, data=11, version='a version')
+##class FullRecoveryTest(BerkeleyTestBase.FullTestBase,
+##                       RecoveryStorage):
+##    def setUp(self):
+##        BerkeleyTestBase.FullTestBase.setUp(self)
+##        self._zap_dbhome(DST_DBHOME)
+##        self._dst = self._mk_dbhome(DST_DBHOME)
+
+##    def tearDown(self):
+##        BerkeleyTestBase.FullTestBase.tearDown(self)
+##        self._zap_dbhome(DST_DBHOME)
+
+##    def new_dest(self):
+##        self._zap_dbhome(DST_DBHOME)
+##        return self._mk_dbhome(DST_DBHOME)
 
 
 
 def test_suite():
     suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(MinimalTest, 'check'))
-    suite.addTest(unittest.makeSuite(FullTest, 'check'))
-    suite.addTest(unittest.makeSuite(AutopackTest, 'check'))
+    if BDBStorage.is_available:
+        suite.addTest(unittest.makeSuite(FullTest, 'check'))
+##        suite.addTest(unittest.makeSuite(FullRecoveryTest, 'check'))
+        suite.addTest(unittest.makeSuite(MinimalTest, 'check'))
     return suite
 
 


=== ZODB3/BDBStorage/tests/test_virgin.py 1.10 => 1.10.6.1 ===
--- ZODB3/BDBStorage/tests/test_virgin.py:1.10	Mon Feb 11 18:40:43 2002
+++ ZODB3/BDBStorage/tests/test_virgin.py	Tue Jan  7 14:40:44 2003
@@ -16,7 +16,8 @@
 
 import unittest
 
-from ZODBTestBase import ZODBTestBase
+import BDBStorage
+from BDBStorage.tests.ZODBTestBase import ZODBTestBase
 from Persistence import PersistentMapping
         
 
@@ -34,20 +35,21 @@
 
 
 class FullNewInsertsTest(ZODBTestBase, InsertMixin):
-    from bsddb3Storage import Full
-    ConcreteStorage = Full.Full
+    from BDBStorage import BDBFullStorage
+    ConcreteStorage = BDBFullStorage.BDBFullStorage
 
 
 class MinimalNewInsertsTest(ZODBTestBase, InsertMixin):
-    from bsddb3Storage import Minimal
-    ConcreteStorage = Minimal.Minimal
+    from BDBStorage import BDBMinimalStorage
+    ConcreteStorage = BDBMinimalStorage.BDBMinimalStorage
 
 
 
 def test_suite():
     suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(MinimalNewInsertsTest, 'check'))
-    suite.addTest(unittest.makeSuite(FullNewInsertsTest, 'check'))
+    if BDBStorage.is_available:
+        suite.addTest(unittest.makeSuite(MinimalNewInsertsTest, 'check'))
+        suite.addTest(unittest.makeSuite(FullNewInsertsTest, 'check'))
     return suite
 
 


=== ZODB3/BDBStorage/tests/test_zodb_simple.py 1.8 => 1.8.4.1 ===
--- ZODB3/BDBStorage/tests/test_zodb_simple.py:1.8	Fri Aug 23 13:16:12 2002
+++ ZODB3/BDBStorage/tests/test_zodb_simple.py	Tue Jan  7 14:40:44 2003
@@ -12,17 +12,15 @@
 # 
 ##############################################################################
 
-# Test some simple ZODB level stuff common to both the Minimal and Full
-# storages, like transaction aborts and commits, changing objects, etc.
-# Doesn't test undo, versions, or packing.
+# Test some simple ZODB level stuff common to both the BDBMinimalStorage and
+# BDBFullStorage storages, like transaction aborts and commits, changing
+# objects, etc.  Doesn't test undo, versions, or packing.
 
 import time
 import unittest
-# Import this here and now so that import failures properly cause the test
-# suite to ignore these tests.
-import bsddb3
 
-from ZODBTestBase import ZODBTestBase
+import BDBStorage
+from BDBStorage.tests.ZODBTestBase import ZODBTestBase
 from Persistence import PersistentMapping
 
 
@@ -69,20 +67,21 @@
 
 
 class MinimalCommitAndRead(ZODBTestBase, CommitAndRead):
-    from bsddb3Storage import Minimal
-    ConcreteStorage = Minimal.Minimal
+    from BDBStorage import BDBMinimalStorage
+    ConcreteStorage = BDBMinimalStorage.BDBMinimalStorage
 
 
 class FullCommitAndRead(ZODBTestBase, CommitAndRead):
-    from bsddb3Storage import Full
-    ConcreteStorage = Full.Full
+    from BDBStorage import BDBFullStorage
+    ConcreteStorage = BDBFullStorage.BDBFullStorage
 
 
 
 def test_suite():
     suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(MinimalCommitAndRead, 'check'))
-    suite.addTest(unittest.makeSuite(FullCommitAndRead, 'check'))
+    if BDBStorage.is_available:
+        suite.addTest(unittest.makeSuite(MinimalCommitAndRead, 'check'))
+        suite.addTest(unittest.makeSuite(FullCommitAndRead, 'check'))
     return suite
 
 


=== ZODB3/BDBStorage/tests/timeiter.py 1.3 => 1.3.6.1 ===
--- ZODB3/BDBStorage/tests/timeiter.py:1.3	Mon Feb 11 18:40:43 2002
+++ ZODB3/BDBStorage/tests/timeiter.py	Tue Jan  7 14:40:44 2003
@@ -65,7 +65,7 @@
 from ZODB import utils
 from ZODB.TimeStamp import TimeStamp
 from ZODB.FileStorage import FileStorage
-from bsddb3Storage.Full import Full
+from BDBStorage.BDBFullStorage import BDBFullStorage
 
 PROGRAM = sys.argv[0]
 ZERO = '\0'*8
@@ -157,7 +157,7 @@
 #
     print >>sys.stderr, 'Opening destination BDB...'
     t0 = time.time()
-    dstdb = Full(options.dest)
+    dstdb = BDBFullStorage(options.dest)
     t1 = time.time()
     print >>sys.stderr, 'Opening destination BDB done. %s seconds' % (t1-t0)
 


=== ZODB3/BDBStorage/tests/timepickles.py 1.2 => 1.2.4.1 ===
--- ZODB3/BDBStorage/tests/timepickles.py:1.2	Fri Aug 23 13:16:46 2002
+++ ZODB3/BDBStorage/tests/timepickles.py	Tue Jan  7 14:40:44 2003
@@ -65,7 +65,7 @@
 from ZODB import utils
 from ZODB.TimeStamp import TimeStamp
 from ZODB.FileStorage import FileStorage
-from bsddb3Storage.Full import Full
+from BDBStorage.BDBFullStorage import BDBFullStorage
 
 PROGRAM = sys.argv[0]
 ZERO = '\0'*8
@@ -157,7 +157,7 @@
 #
     print >>sys.stderr, 'Opening destination BDB...'
     t0 = time.time()
-##    dstdb = Full(options.dest)
+##    dstdb = BDBFullStorage(options.dest)
     dstdb = None
     t1 = time.time()
     print >>sys.stderr, 'Opening destination BDB done. %s seconds' % (t1-t0)