[Zodb-checkins] CVS: ZODB3/ZODB/tests - testFileStorage.py:1.32.8.1 testConfig.py:1.10.20.1 testCache.py:1.13.10.1 VersionStorage.py:1.23.8.1 RecoveryStorage.py:1.8.6.1 PackableStorage.py:1.20.6.1

Jeremy Hylton jeremy at zope.com
Mon Sep 15 14:03:28 EDT 2003


Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv13599/ZODB/tests

Modified Files:
      Tag: Zope-2_7-branch
	testFileStorage.py testConfig.py testCache.py 
	VersionStorage.py RecoveryStorage.py PackableStorage.py 
Log Message:
Take two: Merge changes from ZODB3-3_2-branch to Zope-2_7-branch.

Please make all future changes on the Zope-2_7-branch instead.

The previous attempt used "cvs up -j ZODB3-3_2-branch", but appeared
to get only a small fraction of the changes.  This attempt is based on
copying a checkout of ZODB3-3_2-branch over top of a checkout of
Zope-2_7-branch.


=== ZODB3/ZODB/tests/testFileStorage.py 1.32 => 1.32.8.1 ===
--- ZODB3/ZODB/tests/testFileStorage.py:1.32	Fri May  2 10:50:21 2003
+++ ZODB3/ZODB/tests/testFileStorage.py	Mon Sep 15 14:02:57 2003
@@ -88,7 +88,7 @@
 
         class OldFileStorage(ZODB.FileStorage.FileStorage):
             def _newIndexes(self):
-                return {}, {}, {}, {}
+                return {}, {}, {}, {}, {}, {}, {}
 
 
         from ZODB.fsIndex import fsIndex
@@ -113,7 +113,7 @@
 
         class OldFileStorage(ZODB.FileStorage.FileStorage):
             def _newIndexes(self):
-                return {}, {}, {}, {}
+                return {}, {}, {}, {}, {}, {}, {}
 
 
         from ZODB.fsIndex import fsIndex


=== ZODB3/ZODB/tests/testConfig.py 1.10 => 1.10.20.1 ===
--- ZODB3/ZODB/tests/testConfig.py:1.10	Thu Jan 23 10:39:43 2003
+++ ZODB3/ZODB/tests/testConfig.py	Mon Sep 15 14:02:57 2003
@@ -123,7 +123,7 @@
         cfg = """
         <zodb>
           <fullstorage>
-            name %s
+             envdir %s
           </fullstorage>
         </zodb>
         """ % self._path
@@ -133,7 +133,7 @@
         cfg = """
         <zodb>
           <minimalstorage>
-            name %s
+            envdir %s
           </minimalstorage>
         </zodb>
         """ % self._path


=== ZODB3/ZODB/tests/testCache.py 1.13 => 1.13.10.1 ===
--- ZODB3/ZODB/tests/testCache.py:1.13	Mon Apr  7 18:26:04 2003
+++ ZODB3/ZODB/tests/testCache.py	Mon Sep 15 14:02:57 2003
@@ -185,9 +185,7 @@
         self.assertEquals(len(details), CONNS)
         for d in details:
             self.assertEquals(d['ngsize'], CACHE_SIZE)
-            # the root is also in the cache as ghost, because
-            # the connection holds a reference to it
-            self.assertEquals(d['size'], CACHE_SIZE + 1)
+            self.assertEquals(d['size'], CACHE_SIZE)
 
     def checkDetail(self):
         CACHE_SIZE = 10


=== ZODB3/ZODB/tests/VersionStorage.py 1.23 => 1.23.8.1 ===
--- ZODB3/ZODB/tests/VersionStorage.py:1.23	Thu May  1 13:11:03 2003
+++ ZODB3/ZODB/tests/VersionStorage.py	Mon Sep 15 14:02:57 2003
@@ -488,6 +488,7 @@
 
         root["d"] = MinPO("d")
         get_transaction().commit()
+        snooze()
 
         self._storage.pack(time.time(), referencesf)
         cn.sync()


=== ZODB3/ZODB/tests/RecoveryStorage.py 1.8 => 1.8.6.1 ===
--- ZODB3/ZODB/tests/RecoveryStorage.py:1.8	Fri May 30 16:05:46 2003
+++ ZODB3/ZODB/tests/RecoveryStorage.py	Mon Sep 15 14:02:57 2003
@@ -15,7 +15,7 @@
 
 from ZODB.Transaction import Transaction
 from ZODB.tests.IteratorStorage import IteratorDeepCompare
-from ZODB.tests.StorageTestBase import MinPO, zodb_unpickle
+from ZODB.tests.StorageTestBase import MinPO, zodb_unpickle, snooze
 from ZODB import DB
 from ZODB.referencesf import referencesf
 
@@ -154,3 +154,31 @@
         it.close()
         self._dst.tpc_vote(final)
         self._dst.tpc_finish(final)
+
+    def checkPackWithGCOnDestinationAfterRestore(self):
+        raises = self.assertRaises
+        db = DB(self._storage)
+        conn = db.open()
+        root = conn.root()
+        root.obj = obj1 = MinPO(1)
+        txn = get_transaction()
+        txn.note('root -> obj')
+        txn.commit()
+        root.obj.obj = obj2 = MinPO(2)
+        txn = get_transaction()
+        txn.note('root -> obj -> obj')
+        txn.commit()
+        del root.obj
+        txn = get_transaction()
+        txn.note('root -X->')
+        txn.commit()
+        # Now copy the transactions to the destination
+        self._dst.copyTransactionsFrom(self._storage)
+        # Now pack the destination.
+        snooze()
+        self._dst.pack(time.time(),  referencesf)
+        # And check to see that the root object exists, but not the other
+        # objects.
+        data, serial = self._dst.load(root._p_oid, '')
+        raises(KeyError, self._dst.load, obj1._p_oid, '')
+        raises(KeyError, self._dst.load, obj2._p_oid, '')


=== ZODB3/ZODB/tests/PackableStorage.py 1.20 => 1.20.6.1 ===
--- ZODB3/ZODB/tests/PackableStorage.py:1.20	Fri May 30 15:04:54 2003
+++ ZODB3/ZODB/tests/PackableStorage.py	Mon Sep 15 14:02:57 2003
@@ -381,6 +381,60 @@
 
         eq(root['obj'].value, 7)
 
+    def _PackWhileWriting(self, pack_now=0):
+        # A storage should allow some reading and writing during
+        # a pack.  This test attempts to exercise locking code
+        # in the storage to test that it is safe.  It generates
+        # a lot of revisions, so that pack takes a long time.
+
+        db = DB(self._storage)
+        conn = db.open()
+        root = conn.root()
+
+        for i in range(10):
+            root[i] = MinPO(i)
+        get_transaction().commit()
+
+        snooze()
+        packt = time.time()
+
+        for j in range(10):
+            for i in range(10):
+                root[i].value = MinPO(i)
+                get_transaction().commit()
+
+        threads = [ClientThread(db) for i in range(4)]
+        for t in threads:
+            t.start()
+
+        if pack_now:
+            db.pack(time.time())
+        else:
+            db.pack(packt)
+
+        for t in threads:
+            t.join(30)
+        for t in threads:
+            t.join(1)
+            self.assert_(not t.isAlive())
+
+        # Iterate over the storage to make sure it's sane, but not every
+        # storage supports iterators.
+        if not hasattr(self._storage, "iterator"):
+            return
+
+        iter = self._storage.iterator()
+        for txn in iter:
+            for data in txn:
+                pass
+        iter.close()
+
+    def checkPackWhileWriting(self):
+        self._PackWhileWriting(pack_now=0)
+
+    def checkPackNowWhileWriting(self):
+        self._PackWhileWriting(pack_now=1)
+
     def checkPackUndoLog(self):
         self._initroot()
         eq = self.assertEqual
@@ -449,47 +503,6 @@
         print '\nafter packing undoLog was'
         for r in self._storage.undoLog(): print r
         # what can we assert about that?
-
-    def checkPackWhileWriting(self):
-        # A storage should allow some reading and writing during
-        # a pack.  This test attempts to exercise locking code
-        # in the storage to test that it is safe.  It generates
-        # a lot of revisions, so that pack takes a long time.
-
-        db = DB(self._storage)
-        conn = db.open()
-        root = conn.root()
-
-        for i in range(10):
-            root[i] = MinPO(i)
-        get_transaction().commit()
-
-        snooze()
-        packt = time.time()
-
-        for j in range(10):
-            for i in range(10):
-                root[i].value = MinPO(i)
-                get_transaction().commit()
-
-        threads = [ClientThread(db) for i in range(4)]
-        for t in threads:
-            t.start()
-        db.pack(packt)
-        for t in threads:
-            t.join(30)
-        for t in threads:
-            t.join(1)
-            self.assert_(not t.isAlive())
-
-        # iterator over the storage to make sure it's sane
-        if not hasattr(self._storage, "iterator"):
-            return
-        iter = self._storage.iterator()
-        for txn in iter:
-            for data in txn:
-                pass
-        iter.close()
 
 class ClientThread(threading.Thread):
 




More information about the Zodb-checkins mailing list