[Zodb-checkins] CVS: ZODB3/ZODB/tests - PackableStorage.py:1.22.2.1
testFileStorage.py:1.34.2.3 testMappingStorage.py:1.6.22.1
Jeremy Hylton
cvs-admin at zope.org
Mon Nov 24 13:04:14 EST 2003
Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv20568/ZODB/tests
Modified Files:
Tag: ZODB3-mvcc-2-branch
PackableStorage.py testFileStorage.py testMappingStorage.py
Log Message:
Separate pack tests into two categories.
The first category is the small handful of tests that can work against
a storage that doesn't keep revisions, MappingStorage or
BDBMinimalStorage. The second category is all the rest. Make sure
concrete test classes mixin one or both as needed.
=== ZODB3/ZODB/tests/PackableStorage.py 1.22 => 1.22.2.1 ===
--- ZODB3/ZODB/tests/PackableStorage.py:1.22 Thu Oct 2 14:17:17 2003
+++ ZODB3/ZODB/tests/PackableStorage.py Mon Nov 24 13:04:13 2003
@@ -121,9 +121,6 @@
return u.load()
return loads
-
-
-class PackableStorage(PackableStorageBase):
def _initroot(self):
try:
self._storage.load(ZERO, '')
@@ -141,6 +138,8 @@
self._storage.tpc_vote(t)
self._storage.tpc_finish(t)
+class PackableStorage(PackableStorageBase):
+
def checkPackEmptyStorage(self):
self._storage.pack(time.time(), referencesf)
@@ -152,6 +151,62 @@
self._initroot()
self._storage.pack(time.time() - 10000, referencesf)
+ 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)
+
+class PackableUndoStorage(PackableStorageBase):
+
def checkPackAllRevisions(self):
self._initroot()
eq = self.assertEqual
@@ -381,60 +436,6 @@
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
@@ -504,6 +505,7 @@
for r in self._storage.undoLog(): print r
# what can we assert about that?
+
class ClientThread(threading.Thread):
def __init__(self, db):
@@ -517,3 +519,4 @@
get_transaction().commit()
except ConflictError:
get_transaction().abort()
+
=== ZODB3/ZODB/tests/testFileStorage.py 1.34.2.2 => 1.34.2.3 ===
--- ZODB3/ZODB/tests/testFileStorage.py:1.34.2.2 Wed Nov 12 00:45:11 2003
+++ ZODB3/ZODB/tests/testFileStorage.py Mon Nov 24 13:04:13 2003
@@ -51,6 +51,7 @@
VersionStorage.VersionStorage,
TransactionalUndoVersionStorage.TransactionalUndoVersionStorage,
PackableStorage.PackableStorage,
+ PackableStorage.PackableUndoStorage,
Synchronization.SynchronizedStorage,
ConflictResolution.ConflictResolvingStorage,
ConflictResolution.ConflictResolvingTransUndoStorage,
=== ZODB3/ZODB/tests/testMappingStorage.py 1.6 => 1.6.22.1 ===
--- ZODB3/ZODB/tests/testMappingStorage.py:1.6 Fri May 30 05:24:44 2003
+++ ZODB3/ZODB/tests/testMappingStorage.py Mon Nov 24 13:04:13 2003
@@ -14,12 +14,14 @@
import ZODB.MappingStorage
import os, unittest
-from ZODB.tests import StorageTestBase, BasicStorage, Synchronization
+from ZODB.tests \
+ import StorageTestBase, BasicStorage, Synchronization, PackableStorage
class MappingStorageTests(StorageTestBase.StorageTestBase,
- BasicStorage.BasicStorage,
- Synchronization.SynchronizedStorage,
- ):
+ BasicStorage.BasicStorage,
+ Synchronization.SynchronizedStorage,
+ PackableStorage.PackableStorage,
+ ):
def setUp(self):
self._storage = ZODB.MappingStorage.MappingStorage()
More information about the Zodb-checkins
mailing list