Commit 23fca836 authored by Jason Madden's avatar Jason Madden

Tests: Always pass bytes for the previous serial param of storage.store().

This is consistent with what persistent.Persistent and Connection actually do.

RelStorage previously had a special case just for these tests.
parent 8388009c
...@@ -774,43 +774,30 @@ class IStorage(Interface): ...@@ -774,43 +774,30 @@ class IStorage(Interface):
def store(oid, serial, data, version, transaction): def store(oid, serial, data, version, transaction):
"""Store data for the object id, oid. """Store data for the object id, oid.
Arguments: :param bytes oid: The object identifier. This is either a
string consisting of 8 nulls or a string previously
oid returned by new_oid.
The object identifier. This is either a string :param bytes serial: The serial of the data that was read when
consisting of 8 nulls or a string previously returned by the object was loaded from the database. If the object was
new_oid. created in the current transaction this will be a string
consisting of 8 nulls.
serial :param bytes data: The data record. This is opaque to the
The serial of the data that was read when the object was storage.
loaded from the database. If the object was created in :param version: This must be an empty string. It exists for
the current transaction this will be a string consisting backward compatibility.
of 8 nulls. :param transaction: The object passed to tpc_begin
data :raises ConflictError: Raised when serial does not match the
The data record. This is opaque to the storage. most recent serial number for object oid and the conflict
was not resolved by the storage. Note that this may be deferred
version to :meth:`tpc_vote`.
This must be an empty string. It exists for backward compatibility.
:raises StorageTransactionError: Raised when transaction does
transaction not match the current transaction.
The object passed to tpc_begin
:raises StorageError: Raised when an internal error occurs
Several different exceptions may be raised when an error occurs. while the storage is handling the store() call. Most often this
is a descriptive subclass.
ConflictError
is raised when serial does not match the most recent serial
number for object oid and the conflict was not resolved by
the storage.
StorageTransactionError
is raised when transaction does not match the current
transaction.
StorageError or, more often, a subclass of it
is raised when an internal error occurs while the storage is
handling the store() call.
""" """
def tpc_abort(transaction): def tpc_abort(transaction):
......
...@@ -80,12 +80,12 @@ import getopt ...@@ -80,12 +80,12 @@ import getopt
import marshal import marshal
import profile import profile
from persistent.timestamp import TimeStamp
from ZODB import utils from ZODB import utils
from ZODB import StorageTypes from ZODB import StorageTypes # XXX: This import does not exist
from ZODB.TimeStamp import TimeStamp
PROGRAM = sys.argv[0] PROGRAM = sys.argv[0]
ZERO = '\0'*8
def usage(code, msg=''): def usage(code, msg=''):
...@@ -283,7 +283,7 @@ def doit(srcdb, dstdb, options): ...@@ -283,7 +283,7 @@ def doit(srcdb, dstdb, options):
else: else:
vstr = r.version vstr = r.version
print(utils.U64(oid), vstr, len(r.data)) print(utils.U64(oid), vstr, len(r.data))
oldrevid = prevrevids.get(oid, ZERO) oldrevid = prevrevids.get(oid, utils.z64)
result = dstdb.store(oid, oldrevid, r.data, r.version, txn) result = dstdb.store(oid, oldrevid, r.data, r.version, txn)
newrevids.store(oid, result) newrevids.store(oid, result)
t2 = time.time() t2 = time.time()
......
...@@ -22,6 +22,7 @@ from ZODB import POSException ...@@ -22,6 +22,7 @@ from ZODB import POSException
from ZODB.Connection import TransactionMetaData from ZODB.Connection import TransactionMetaData
from ZODB.tests.MinPO import MinPO from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_unpickle, zodb_pickle from ZODB.tests.StorageTestBase import zodb_unpickle, zodb_pickle
from ZODB.tests.StorageTestBase import ZERO
import threading import threading
import time import time
...@@ -30,8 +31,6 @@ import zope.interface.verify ...@@ -30,8 +31,6 @@ import zope.interface.verify
from .. import utils from .. import utils
ZERO = b'\0'*8
class BasicStorage(object): class BasicStorage(object):
def checkBasics(self): def checkBasics(self):
self.assertEqual(self._storage.lastTransaction(), ZERO) self.assertEqual(self._storage.lastTransaction(), ZERO)
......
...@@ -21,6 +21,7 @@ all these tests. ...@@ -21,6 +21,7 @@ all these tests.
from ZODB.Connection import TransactionMetaData from ZODB.Connection import TransactionMetaData
from ZODB.tests.MinPO import MinPO from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle
from ZODB.tests.StorageTestBase import ZERO
from ZODB.utils import U64, p64, load_current from ZODB.utils import U64, p64, load_current
import ZODB.blob import ZODB.blob
...@@ -126,7 +127,7 @@ class IteratorStorage(IteratorCompare): ...@@ -126,7 +127,7 @@ class IteratorStorage(IteratorCompare):
data = zodb_pickle(MinPO(0)) data = zodb_pickle(MinPO(0))
try: try:
self._storage.tpc_begin(t) self._storage.tpc_begin(t)
self._storage.store(oid, '\0'*8, data, '', t) self._storage.store(oid, ZERO, data, '', t)
self._storage.tpc_vote(t) self._storage.tpc_vote(t)
# Don't do tpc_finish yet # Don't do tpc_finish yet
it = self._storage.iterator() it = self._storage.iterator()
......
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
from ZODB.Connection import TransactionMetaData from ZODB.Connection import TransactionMetaData
from ZODB.tests.MinPO import MinPO from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_unpickle, zodb_pickle, snooze from ZODB.tests.StorageTestBase import zodb_unpickle, zodb_pickle, snooze
from ZODB.tests.StorageTestBase import ZERO
from ZODB.utils import p64, u64, load_current from ZODB.utils import p64, u64, load_current
from ZODB.tests.util import time_monotonically_increases from ZODB.tests.util import time_monotonically_increases
ZERO = '\0'*8
class RevisionStorage(object): class RevisionStorage(object):
......
...@@ -29,7 +29,7 @@ from ZODB._compat import PersistentPickler, Unpickler, BytesIO, _protocol ...@@ -29,7 +29,7 @@ from ZODB._compat import PersistentPickler, Unpickler, BytesIO, _protocol
import ZODB.tests.util import ZODB.tests.util
ZERO = b'\0'*8 ZERO = z64
def snooze(): def snooze():
# In Windows, it's possible that two successive time.time() calls return # In Windows, it's possible that two successive time.time() calls return
......
...@@ -31,8 +31,8 @@ from ZODB import DB ...@@ -31,8 +31,8 @@ from ZODB import DB
from ZODB.tests.MinPO import MinPO from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle
from ZODB.tests.StorageTestBase import ZERO
ZERO = '\0'*8
class C(Persistent): class C(Persistent):
pass pass
......
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