[Zope-Checkins] CVS: ZODB3/ZODB/tests - HistoryStorage.py:1.11.2.1
IteratorStorage.py:1.17.2.4 RecoveryStorage.py:1.10.2.2
RevisionStorage.py:1.4.2.9 StorageTestBase.py:1.29.2.4
TransactionalUndoStorage.py:1.33.2.4
TransactionalUndoVersionStorage.py:1.12.2.4
VersionStorage.py:1.25.2.9 testDemoStorage.py:1.7.22.2
testFileStorage.py:1.34.2.5
Jeremy Hylton
cvs-admin at zope.org
Tue Dec 2 02:10:33 EST 2003
Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv24432/ZODB/tests
Modified Files:
Tag: ZODB3-mvcc-2-branch
HistoryStorage.py IteratorStorage.py RecoveryStorage.py
RevisionStorage.py StorageTestBase.py
TransactionalUndoStorage.py TransactionalUndoVersionStorage.py
VersionStorage.py testDemoStorage.py testFileStorage.py
Log Message:
First cut at removal of serial numbers.
Rename loadNonCurrent() to loadBefore() (Jim's suggestion).
A few tests fail, but it's close enough to share the code with Tim.
In all case, the _p_serial attribute of a Persistent object matches
the id of the transaction that wrote the current revision. Within the
storage API, we eliminate the abortVersion case where the txn id is
greater than the serial number.
Rename as many variables and attributes from serial to tid, with the
exception of store() and restore() arguments. They're being passed in
from a client, which is getting the value from _p_serial; it makes
some sense there.
When tid and serial were both returned, eliminate serial and just use
tid.
Replace "serial" with "tid" in some methods names, but not all. I'll
get to the rest tomorrow. The remaining ones are just used a lot.
Add XXX comment about now-bogus ZEO protocol that passes identical
serialnos for every object committed.
=== ZODB3/ZODB/tests/HistoryStorage.py 1.11 => 1.11.2.1 ===
--- ZODB3/ZODB/tests/HistoryStorage.py:1.11 Thu Oct 2 14:17:17 2003
+++ ZODB3/ZODB/tests/HistoryStorage.py Tue Dec 2 02:10:32 2003
@@ -36,40 +36,40 @@
h = self._storage.history(oid, size=1)
eq(len(h), 1)
d = h[0]
- eq(d['serial'], revid3)
+ eq(d['tid'], revid3)
eq(d['version'], '')
# Try to get 2 historical revisions
h = self._storage.history(oid, size=2)
eq(len(h), 2)
d = h[0]
- eq(d['serial'], revid3)
+ eq(d['tid'], revid3)
eq(d['version'], '')
d = h[1]
- eq(d['serial'], revid2)
+ eq(d['tid'], revid2)
eq(d['version'], '')
# Try to get all 3 historical revisions
h = self._storage.history(oid, size=3)
eq(len(h), 3)
d = h[0]
- eq(d['serial'], revid3)
+ eq(d['tid'], revid3)
eq(d['version'], '')
d = h[1]
- eq(d['serial'], revid2)
+ eq(d['tid'], revid2)
eq(d['version'], '')
d = h[2]
- eq(d['serial'], revid1)
+ eq(d['tid'], revid1)
eq(d['version'], '')
# There should be no more than 3 revisions
h = self._storage.history(oid, size=4)
eq(len(h), 3)
d = h[0]
- eq(d['serial'], revid3)
+ eq(d['tid'], revid3)
eq(d['version'], '')
d = h[1]
- eq(d['serial'], revid2)
+ eq(d['tid'], revid2)
eq(d['version'], '')
d = h[2]
- eq(d['serial'], revid1)
+ eq(d['tid'], revid1)
eq(d['version'], '')
def checkVersionHistory(self):
@@ -94,22 +94,22 @@
h = self._storage.history(oid, version, 100)
eq(len(h), 6)
d = h[0]
- eq(d['serial'], revid6)
+ eq(d['tid'], revid6)
eq(d['version'], version)
d = h[1]
- eq(d['serial'], revid5)
+ eq(d['tid'], revid5)
eq(d['version'], version)
d = h[2]
- eq(d['serial'], revid4)
+ eq(d['tid'], revid4)
eq(d['version'], version)
d = h[3]
- eq(d['serial'], revid3)
+ eq(d['tid'], revid3)
eq(d['version'], '')
d = h[4]
- eq(d['serial'], revid2)
+ eq(d['tid'], revid2)
eq(d['version'], '')
d = h[5]
- eq(d['serial'], revid1)
+ eq(d['tid'], revid1)
eq(d['version'], '')
def checkHistoryAfterVersionCommit(self):
@@ -151,25 +151,25 @@
h = self._storage.history(oid, version, 100)
eq(len(h), 7)
d = h[0]
- eq(d['serial'], revid7)
+ eq(d['tid'], revid7)
eq(d['version'], '')
d = h[1]
- eq(d['serial'], revid6)
+ eq(d['tid'], revid6)
eq(d['version'], version)
d = h[2]
- eq(d['serial'], revid5)
+ eq(d['tid'], revid5)
eq(d['version'], version)
d = h[3]
- eq(d['serial'], revid4)
+ eq(d['tid'], revid4)
eq(d['version'], version)
d = h[4]
- eq(d['serial'], revid3)
+ eq(d['tid'], revid3)
eq(d['version'], '')
d = h[5]
- eq(d['serial'], revid2)
+ eq(d['tid'], revid2)
eq(d['version'], '')
d = h[6]
- eq(d['serial'], revid1)
+ eq(d['tid'], revid1)
eq(d['version'], '')
def checkHistoryAfterVersionAbort(self):
@@ -211,23 +211,23 @@
h = self._storage.history(oid, version, 100)
eq(len(h), 7)
d = h[0]
- eq(d['serial'], revid7)
+ eq(d['tid'], revid7)
eq(d['version'], '')
d = h[1]
- eq(d['serial'], revid6)
+ eq(d['tid'], revid6)
eq(d['version'], version)
d = h[2]
- eq(d['serial'], revid5)
+ eq(d['tid'], revid5)
eq(d['version'], version)
d = h[3]
- eq(d['serial'], revid4)
+ eq(d['tid'], revid4)
eq(d['version'], version)
d = h[4]
- eq(d['serial'], revid3)
+ eq(d['tid'], revid3)
eq(d['version'], '')
d = h[5]
- eq(d['serial'], revid2)
+ eq(d['tid'], revid2)
eq(d['version'], '')
d = h[6]
- eq(d['serial'], revid1)
+ eq(d['tid'], revid1)
eq(d['version'], '')
=== ZODB3/ZODB/tests/IteratorStorage.py 1.17.2.3 => 1.17.2.4 ===
--- ZODB3/ZODB/tests/IteratorStorage.py:1.17.2.3 Thu Nov 20 16:01:11 2003
+++ ZODB3/ZODB/tests/IteratorStorage.py Tue Dec 2 02:10:32 2003
@@ -33,7 +33,7 @@
eq(reciter.tid, revid)
for rec in reciter:
eq(rec.oid, oid)
- eq(rec.serial, revid)
+ eq(rec.tid, revid)
eq(rec.version, '')
eq(zodb_unpickle(rec.data), MinPO(val))
val = val + 1
@@ -150,16 +150,12 @@
def checkLoadEx(self):
oid = self._storage.new_oid()
self._dostore(oid, data=42)
- data, serial, tid, ver = self._storage.loadEx(oid, "")
+ data, tid, ver = self._storage.loadEx(oid, "")
self.assertEqual(zodb_unpickle(data), MinPO(42))
- # In most storages, serial == tid, but that's not a required
- # part of the API. The API goes out of its way to avoid
- # exposing the transaction. The best we can do is get it
- # from an iterator.
match = False
for txn in self._storage.iterator():
for rec in txn:
- if rec.oid == oid and rec.serial == serial:
+ if rec.oid == oid and rec.tid == tid:
self.assertEqual(txn.tid, tid)
match = True
if not match:
@@ -220,7 +216,7 @@
eq(txn1._extension, txn2._extension)
for rec1, rec2 in zip(txn1, txn2):
eq(rec1.oid, rec2.oid)
- eq(rec1.serial, rec2.serial)
+ eq(rec1.tid, rec2.tid)
eq(rec1.version, rec2.version)
eq(rec1.data, rec2.data)
# Make sure there are no more records left in rec1 and rec2,
=== ZODB3/ZODB/tests/RecoveryStorage.py 1.10.2.1 => 1.10.2.2 ===
--- ZODB3/ZODB/tests/RecoveryStorage.py:1.10.2.1 Tue Oct 7 01:10:31 2003
+++ ZODB3/ZODB/tests/RecoveryStorage.py Tue Dec 2 02:10:32 2003
@@ -149,7 +149,7 @@
final = list(it)[-1]
self._dst.tpc_begin(final, final.tid, final.status)
for r in final:
- self._dst.restore(r.oid, r.serial, r.data, r.version, r.data_txn,
+ self._dst.restore(r.oid, r.tid, r.data, r.version, r.data_txn,
final)
it.close()
self._dst.tpc_vote(final)
=== ZODB3/ZODB/tests/RevisionStorage.py 1.4.2.8 => 1.4.2.9 ===
--- ZODB3/ZODB/tests/RevisionStorage.py:1.4.2.8 Mon Dec 1 10:15:02 2003
+++ ZODB3/ZODB/tests/RevisionStorage.py Tue Dec 2 02:10:32 2003
@@ -33,7 +33,7 @@
data = self._storage.loadSerial(oid, revid)
self.assertEqual(zodb_unpickle(data), value)
- def checkLoadNonCurrent(self):
+ def checkLoadBefore(self):
# Store 10 revisions of one object and then make sure that we
# can get all the non-current revisions back.
oid = self._storage.new_oid()
@@ -51,44 +51,44 @@
revid = self._dostore(oid, revid, data=MinPO(i))
revs.append(self._storage.loadEx(oid, ""))
- prev = u64(revs[0][2])
+ prev = u64(revs[0][1])
for i in range(1, 10):
- tid = revs[i][2]
+ tid = revs[i][1]
cur = u64(tid)
middle = prev + (cur - prev) // 2
assert prev < middle < cur # else the snooze() trick failed
prev = cur
- t = self._storage.loadNonCurrent(oid, p64(middle))
+ t = self._storage.loadBefore(oid, p64(middle))
self.assert_(t is not None)
- data, serial, start, end = t
+ data, start, end = t
self.assertEqual(revs[i-1][0], data)
self.assertEqual(tid, end)
- def checkLoadNonCurrentEdges(self):
+ def checkLoadBeforeEdges(self):
# Check the edges cases for a non-current load.
oid = self._storage.new_oid()
- self.assertRaises(KeyError, self._storage.loadNonCurrent,
+ self.assertRaises(KeyError, self._storage.loadBefore,
oid, p64(0))
revid1 = self._dostore(oid, data=MinPO(1))
- self.assertEqual(self._storage.loadNonCurrent(oid, p64(0)), None)
- self.assertEqual(self._storage.loadNonCurrent(oid, revid1), None)
+ self.assertEqual(self._storage.loadBefore(oid, p64(0)), None)
+ self.assertEqual(self._storage.loadBefore(oid, revid1), None)
cur = p64(u64(revid1) + 1)
- data, serial, start, end = self._storage.loadNonCurrent(oid, cur)
+ data, start, end = self._storage.loadBefore(oid, cur)
self.assertEqual(zodb_unpickle(data), MinPO(1))
self.assertEqual(start, revid1)
self.assertEqual(end, None)
revid2 = self._dostore(oid, revid=revid1, data=MinPO(2))
- data, serial, start, end = self._storage.loadNonCurrent(oid, cur)
+ data, start, end = self._storage.loadBefore(oid, cur)
self.assertEqual(zodb_unpickle(data), MinPO(1))
self.assertEqual(start, revid1)
self.assertEqual(end, revid2)
- def checkLoadNonCurrentOld(self):
+ def checkLoadBeforeOld(self):
# Look for a very old revision. With the BaseStorage implementation
# this should require multple history() calls.
oid = self._storage.new_oid()
@@ -98,7 +98,7 @@
revid = self._dostore(oid, revid, data=MinPO(i))
revs.append(revid)
- data, serial, start, end = self._storage.loadNonCurrent(oid, revs[12])
+ data, start, end = self._storage.loadBefore(oid, revs[12])
self.assertEqual(zodb_unpickle(data), MinPO(11))
self.assertEqual(start, revs[11])
self.assertEqual(end, revs[12])
@@ -107,7 +107,7 @@
# XXX Is it okay to assume everyone testing against RevisionStorage
# implements undo?
- def checkLoadNonCurrentUndo(self):
+ def checkLoadBeforeUndo(self):
# Do several transactions then undo them.
oid = self._storage.new_oid()
revid = None
@@ -123,24 +123,16 @@
revs.append(self._storage.loadEx(oid, ""))
prev_tid = None
- for i, (data, serial, tid, ver) in enumerate(revs):
- t = self._storage.loadNonCurrent(oid, p64(u64(tid) + 1))
+ for i, (data, tid, ver) in enumerate(revs):
+ t = self._storage.loadBefore(oid, p64(u64(tid) + 1))
self.assertEqual(data, t[0])
- self.assertEqual(tid, t[2])
+ self.assertEqual(tid, t[1])
if prev_tid:
- self.assert_(prev_tid < t[2])
- prev_tid = t[2]
+ self.assert_(prev_tid < t[1])
+ prev_tid = t[1]
if i < 3:
- self.assertEqual(revs[i+1][2], t[3])
+ self.assertEqual(revs[i+1][1], t[2])
else:
- self.assertEqual(None, t[3])
-
- # The API doesn't say exactly what the serial number
- # should be, only that it should return the right
- # data and be less than the current serial number.
-
- data1 = self._storage.loadSerial(oid, serial)
- data2 = self._storage.loadSerial(oid, t[1])
- self.assertEqual(data1, data2)
+ self.assertEqual(None, t[2])
# XXX There are other edge cases to handle, including pack.
=== ZODB3/ZODB/tests/StorageTestBase.py 1.29.2.3 => 1.29.2.4 ===
--- ZODB3/ZODB/tests/StorageTestBase.py:1.29.2.3 Wed Nov 12 00:21:03 2003
+++ ZODB3/ZODB/tests/StorageTestBase.py Tue Dec 2 02:10:32 2003
@@ -206,7 +206,7 @@
self._storage.tpc_vote(t)
self._storage.tpc_finish(t)
if expected_oids is not None:
- self.assertEqual(len(oids), len(expected_oids))
+ self.assertEqual(len(oids), len(expected_oids), repr(oids))
for oid in expected_oids:
self.assert_(oid in oids)
return self._storage.lastTransaction()
=== ZODB3/ZODB/tests/TransactionalUndoStorage.py 1.33.2.3 => 1.33.2.4 ===
--- ZODB3/ZODB/tests/TransactionalUndoStorage.py:1.33.2.3 Mon Dec 1 10:16:11 2003
+++ ZODB3/ZODB/tests/TransactionalUndoStorage.py Tue Dec 2 02:10:32 2003
@@ -648,7 +648,7 @@
tid = p64(i + 1)
eq(txn.tid, tid)
- L1 = [(rec.oid, rec.serial, rec.data_txn) for rec in txn]
+ L1 = [(rec.oid, rec.tid, rec.data_txn) for rec in txn]
L2 = [(oid, revid, None) for _tid, oid, revid in orig
if _tid == tid]
=== ZODB3/ZODB/tests/TransactionalUndoVersionStorage.py 1.12.2.3 => 1.12.2.4 ===
--- ZODB3/ZODB/tests/TransactionalUndoVersionStorage.py:1.12.2.3 Thu Nov 20 16:01:11 2003
+++ ZODB3/ZODB/tests/TransactionalUndoVersionStorage.py Tue Dec 2 02:10:32 2003
@@ -64,7 +64,7 @@
self._undo(info[0]['id'], [oid])
data, revid = self._storage.load(oid, '')
- eq(revid, revid_a)
+## eq(revid, revid_a)
eq(zodb_unpickle(data), MinPO(91))
data, revid = self._storage.load(oid, version)
unless(revid > revid_b and revid > revid_c)
@@ -136,15 +136,18 @@
self.assertEqual(load_value(oid1), 0)
self.assertEqual(load_value(oid1, version), 2)
- data, serial, tid, ver = self._storage.loadEx(oid1, "")
+
+ data, tid, ver = self._storage.loadEx(oid1, "")
# After undoing the version commit, the non-version data
# once again becomes the non-version data from 'create1'.
self.assertEqual(tid, self._storage.lastTransaction())
+ self.assertEqual(ver, "")
# The current version data comes from an undo record, which
- # means that it gets data via the backpointer but serial
- # and tid from the current txn.
- data, serial, tid, ver = self._storage.loadEx(oid1, version)
+ # means that it gets data via the backpointer but tid from the
+ # current txn.
+ data, tid, ver = self._storage.loadEx(oid1, version)
+ self.assertEqual(ver, version)
self.assertEqual(tid, self._storage.lastTransaction())
def checkUndoAbortVersion(self):
=== ZODB3/ZODB/tests/VersionStorage.py 1.25.2.8 => 1.25.2.9 ===
--- ZODB3/ZODB/tests/VersionStorage.py:1.25.2.8 Mon Dec 1 10:16:11 2003
+++ ZODB3/ZODB/tests/VersionStorage.py Tue Dec 2 02:10:32 2003
@@ -44,22 +44,18 @@
revid1 = self._dostore(oid, data=MinPO(12))
revid2 = self._dostore(oid, revid=revid1, data=MinPO(13),
version="version")
- data, serial, tid, ver = self._storage.loadEx(oid, "version")
- self.assertEqual(revid2, serial)
+ data, tid, ver = self._storage.loadEx(oid, "version")
+ self.assertEqual(revid2, tid)
self.assertEqual(zodb_unpickle(data), MinPO(13))
- self.assertEqual(tid, serial)
oids = self._abortVersion("version")
self.assertEqual([oid], oids)
data, revid3 = self._storage.load(oid, "")
# use repr() to avoid getting binary data in a traceback on error
- self.assertEqual(`revid1`, `revid3`)
- self.assertNotEqual(`revid2`, `revid3`)
- data, serial, tid, ver = self._storage.loadEx(oid, "")
- self.assertEqual(revid3, serial)
+ self.assertNotEqual(revid1, revid3)
+ self.assertNotEqual(revid2, revid3)
+ data, tid, ver = self._storage.loadEx(oid, "")
+ self.assertEqual(revid3, tid)
self.assertEqual(zodb_unpickle(data), MinPO(12))
- # The storage API doesn't expose the tid as part of the
- # commit, so there's no
- self.assert_(tid > serial)
self.assertEqual(tid, self._storage.lastTransaction())
def checkVersionedStoreAndLoad(self):
@@ -85,14 +81,12 @@
if hasattr(self._storage, 'getSerial'):
s = self._storage.getSerial(oid)
eq(s, max(revid, vrevid))
- data, serial, tid, ver = self._storage.loadEx(oid, version)
+ data, tid, ver = self._storage.loadEx(oid, version)
eq(zodb_unpickle(data), MinPO(15))
- eq(serial, revid2)
eq(tid, revid2)
- data, serial, tid, ver = self._storage.loadEx(oid, "other version")
+ data, tid, ver = self._storage.loadEx(oid, "other version")
eq(zodb_unpickle(data), MinPO(12))
eq(tid, revid2)
- eq(serial, revid1)
def checkVersionedLoadErrors(self):
oid = self._storage.new_oid()
@@ -198,16 +192,16 @@
# after a version is aborted.
oid, version = self._setup_version()
self._abortVersion(version)
- data, serial, tid, ver = self._storage.loadEx(oid, "")
+ data, tid, ver = self._storage.loadEx(oid, "")
# write a new revision of oid so that the aborted-version txn
# is not current
- self._dostore(oid, revid=serial, data=MinPO(17))
+ self._dostore(oid, revid=tid, data=MinPO(17))
ltid = self._storage.lastTransaction()
-
- ncdata, ncserial, start, end = self._storage.loadNonCurrent(oid, ltid)
+
+ ncdata, ncstart, end = self._storage.loadBefore(oid, ltid)
self.assertEqual(data, ncdata)
- self.assertEqual(serial, ncserial)
+ self.assertEqual(tid, ncstart)
def checkAbortVersionErrors(self):
eq = self.assertEqual
@@ -254,17 +248,17 @@
def checkNewSerialOnCommitVersionToVersion(self):
eq = self.assertEqual
oid, version = self._setup_version()
- data, vserial = self._storage.load(oid, version)
- data, nserial = self._storage.load(oid, '')
+ data, vtid = self._storage.load(oid, version)
+ data, ntid = self._storage.load(oid, '')
version2 = 'test version 2'
self._commitVersion(version, version2)
- data, serial = self._storage.load(oid, version2)
+ data, tid = self._storage.load(oid, version2)
- self.failUnless(serial != vserial and serial != nserial,
- "New serial, %r, should be different from the old "
- "version, %r, and non-version, %r, serials."
- % (serial, vserial, nserial))
+ self.failUnless(tid != vtid and tid != ntid,
+ "New tid, %r, should be different from the old "
+ "version, %r, and non-version, %r, tids."
+ % (tid, vtid, ntid))
def checkModifyAfterAbortVersion(self):
eq = self.assertEqual
=== ZODB3/ZODB/tests/testDemoStorage.py 1.7.22.1 => 1.7.22.2 ===
--- ZODB3/ZODB/tests/testDemoStorage.py:1.7.22.1 Tue Nov 25 00:47:20 2003
+++ ZODB3/ZODB/tests/testDemoStorage.py Tue Dec 2 02:10:32 2003
@@ -36,7 +36,7 @@
pass
def checkAbortVersionNonCurrent(self):
- # XXX Need to implement a real loadNonCurrent for DemoStorage?
+ # XXX Need to implement a real loadBefore for DemoStorage?
pass
=== ZODB3/ZODB/tests/testFileStorage.py 1.34.2.4 => 1.34.2.5 ===
--- ZODB3/ZODB/tests/testFileStorage.py:1.34.2.4 Mon Dec 1 10:16:11 2003
+++ ZODB3/ZODB/tests/testFileStorage.py Tue Dec 2 02:10:32 2003
@@ -179,8 +179,8 @@
):
def setUp(self):
- self._storage = ZODB.FileStorage.FileStorage('Source.fs')
- self._dst = ZODB.FileStorage.FileStorage('Dest.fs')
+ self._storage = ZODB.FileStorage.FileStorage("Source.fs", create=True)
+ self._dst = ZODB.FileStorage.FileStorage("Dest.fs", create=True)
def tearDown(self):
self._storage.close()
More information about the Zope-Checkins
mailing list