Commit b06abaa2 authored by Jim Fulton's avatar Jim Fulton

Some tests didn't recognize that when an object hasn't been modified

in a version, we fall back to non-version data.

Undo wasn't tested properly. The tests didn't get the undo ids
from the transaction log.
parent 421586d8
...@@ -13,8 +13,10 @@ class TransactionalUndoVersionStorage: ...@@ -13,8 +13,10 @@ class TransactionalUndoVersionStorage:
revid_a = self._dostore(oid, data=91) revid_a = self._dostore(oid, data=91)
revid_b = self._dostore(oid, revid=revid_a, data=92, version=version) revid_b = self._dostore(oid, revid=revid_a, data=92, version=version)
revid_c = self._dostore(oid, revid=revid_b, data=93, version=version) revid_c = self._dostore(oid, revid=revid_b, data=93, version=version)
info=self._storage.undoInfo()
tid=info[0]['id']
self._storage.tpc_begin(self._transaction) self._storage.tpc_begin(self._transaction)
oids = self._storage.transactionalUndo(revid_c, self._transaction) oids = self._storage.transactionalUndo(tid, self._transaction)
self._storage.tpc_vote(self._transaction) self._storage.tpc_vote(self._transaction)
self._storage.tpc_finish(self._transaction) self._storage.tpc_finish(self._transaction)
assert len(oids) == 1 assert len(oids) == 1
...@@ -32,14 +34,20 @@ class TransactionalUndoVersionStorage: ...@@ -32,14 +34,20 @@ class TransactionalUndoVersionStorage:
self._storage.tpc_finish(self._transaction) self._storage.tpc_finish(self._transaction)
assert len(oids) == 1 assert len(oids) == 1
assert oids[0] == oid assert oids[0] == oid
self.assertRaises(POSException.VersionError,
self._storage.load, #JF# No, because we fall back to non-version data.
oid, version) #JF# self.assertRaises(POSException.VersionError,
#JF# self._storage.load,
#JF# oid, version)
data, revid = self._storage.load(oid, version)
assert pickle.loads(data) == 92
data, revid = self._storage.load(oid, '') data, revid = self._storage.load(oid, '')
assert pickle.loads(data) == 92 assert pickle.loads(data) == 92
# ...and undo the commit # ...and undo the commit
info=self._storage.undoInfo()
tid=info[0]['id']
self._storage.tpc_begin(self._transaction) self._storage.tpc_begin(self._transaction)
oids = self._storage.transactionalUndo(revid, self._transaction) oids = self._storage.transactionalUndo(tid, self._transaction)
self._storage.tpc_vote(self._transaction) self._storage.tpc_vote(self._transaction)
self._storage.tpc_finish(self._transaction) self._storage.tpc_finish(self._transaction)
assert len(oids) == 1 assert len(oids) == 1
...@@ -57,14 +65,19 @@ class TransactionalUndoVersionStorage: ...@@ -57,14 +65,19 @@ class TransactionalUndoVersionStorage:
assert oids[0] == oid assert oids[0] == oid
# The object should not exist in the version now, but it should exist # The object should not exist in the version now, but it should exist
# in the non-version # in the non-version
self.assertRaises(POSException.VersionError, #JF# No, because we fall back
self._storage.load, #JF# self.assertRaises(POSException.VersionError,
oid, version) #JF# self._storage.load,
#JF# oid, version)
data, revid = self._storage.load(oid, version)
assert pickle.loads(data) == 91
data, revid = self._storage.load(oid, '') data, revid = self._storage.load(oid, '')
assert pickle.loads(data) == 91 assert pickle.loads(data) == 91
# Now undo the abort # Now undo the abort
info=self._storage.undoInfo()
tid=info[0]['id']
self._storage.tpc_begin(self._transaction) self._storage.tpc_begin(self._transaction)
oids = self._storage.transactionalUndo(revid, self._transaction) oids = self._storage.transactionalUndo(tid, self._transaction)
self._storage.tpc_vote(self._transaction) self._storage.tpc_vote(self._transaction)
self._storage.tpc_finish(self._transaction) self._storage.tpc_finish(self._transaction)
assert len(oids) == 1 assert len(oids) == 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment