[Zope-Checkins] CVS: ZODB3/ZODB/tests - testFileStorage.py:1.28 VersionStorage.py:1.21
Jeremy Hylton
jeremy@zope.com
Mon, 17 Mar 2003 13:59:03 -0500
Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv12678/tests
Modified Files:
testFileStorage.py VersionStorage.py
Log Message:
Add two new pack+undo+versions tests, one of which fails for FileStorage.
=== ZODB3/ZODB/tests/testFileStorage.py 1.27 => 1.28 ===
--- ZODB3/ZODB/tests/testFileStorage.py:1.27 Fri Jan 3 18:01:25 2003
+++ ZODB3/ZODB/tests/testFileStorage.py Mon Mar 17 13:59:02 2003
@@ -167,6 +167,11 @@
self.failUnless(self._storage._records_before_save > 20)
+ def checkPackVersionsInPast(self):
+ # FileStorage can't cope with backpointers to objects
+ # created in versions. Must fix.
+ pass
+
class FileStorageRecoveryTest(
StorageTestBase.StorageTestBase,
RecoveryStorage.RecoveryStorage,
=== ZODB3/ZODB/tests/VersionStorage.py 1.20 => 1.21 ===
--- ZODB3/ZODB/tests/VersionStorage.py:1.20 Thu Dec 5 19:00:53 2002
+++ ZODB3/ZODB/tests/VersionStorage.py Mon Mar 17 13:59:02 2003
@@ -20,10 +20,14 @@
# They were introduced when Jim reviewed the original version of the
# code. Barry and Jeremy didn't understand versions then.
+import time
+
from ZODB import POSException
+from ZODB.referencesf import referencesf
from ZODB.Transaction import Transaction
from ZODB.tests.MinPO import MinPO
-from ZODB.tests.StorageTestBase import zodb_unpickle
+from ZODB.tests.StorageTestBase import zodb_unpickle, snooze
+from ZODB import DB
class VersionStorage:
@@ -376,3 +380,91 @@
self._storage.tpc_vote(t)
self._storage.tpc_finish(t)
self.assertEqual(oids, [oid])
+
+ def checkPackVersions(self):
+ db = DB(self._storage)
+ cn = db.open(version="testversion")
+ root = cn.root()
+
+ obj = root["obj"] = MinPO("obj")
+ root["obj2"] = MinPO("obj2")
+ txn = get_transaction()
+ txn.note("create 2 objs in version")
+ txn.commit()
+
+ obj.value = "77"
+ txn = get_transaction()
+ txn.note("modify obj in version")
+ txn.commit()
+
+ # undo the modification to generate a mix of backpointers
+ # and versions for pack to chase
+ info = db.undoInfo()
+ db.undo(info[0]["id"])
+ txn = get_transaction()
+ txn.note("undo modification")
+ txn.commit()
+
+ snooze()
+ self._storage.pack(time.time(), referencesf)
+
+ db.commitVersion("testversion")
+ txn = get_transaction()
+ txn.note("commit version")
+ txn.commit()
+
+ cn = db.open()
+ root = cn.root()
+ root["obj"] = "no version"
+
+ txn = get_transaction()
+ txn.note("modify obj")
+ txn.commit()
+
+ self._storage.pack(time.time(), referencesf)
+
+ def checkPackVersionsInPast(self):
+ db = DB(self._storage)
+ cn = db.open(version="testversion")
+ root = cn.root()
+
+ obj = root["obj"] = MinPO("obj")
+ root["obj2"] = MinPO("obj2")
+ txn = get_transaction()
+ txn.note("create 2 objs in version")
+ txn.commit()
+
+ obj.value = "77"
+ txn = get_transaction()
+ txn.note("modify obj in version")
+ txn.commit()
+
+ t0 = time.time()
+ snooze()
+
+ # undo the modification to generate a mix of backpointers
+ # and versions for pack to chase
+ info = db.undoInfo()
+ db.undo(info[0]["id"])
+ txn = get_transaction()
+ txn.note("undo modification")
+ txn.commit()
+
+ self._storage.pack(t0, referencesf)
+
+ db.commitVersion("testversion")
+ txn = get_transaction()
+ txn.note("commit version")
+ txn.commit()
+
+ cn = db.open()
+ root = cn.root()
+ root["obj"] = "no version"
+
+ txn = get_transaction()
+ txn.note("modify obj")
+ txn.commit()
+
+ self._storage.pack(time.time(), referencesf)
+
+