Skip to content

Commit

Permalink
Tests: Always pass bytes for the previous serial param of storage.sto…
Browse files Browse the repository at this point in the history
…re().

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

RelStorage previously had a special case just for these tests.
  • Loading branch information
jamadden committed Sep 27, 2019
1 parent 8388009 commit 23fca83
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 47 deletions.
61 changes: 24 additions & 37 deletions src/ZODB/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,43 +774,30 @@ def sortKey():
def store(oid, serial, data, version, transaction):
"""Store data for the object id, oid.
Arguments:
oid
The object identifier. This is either a string
consisting of 8 nulls or a string previously returned by
new_oid.
serial
The serial of the data that was read when the object was
loaded from the database. If the object was created in
the current transaction this will be a string consisting
of 8 nulls.
data
The data record. This is opaque to the storage.
version
This must be an empty string. It exists for backward compatibility.
transaction
The object passed to tpc_begin
Several different exceptions may be raised when an error occurs.
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.
:param bytes oid: The object identifier. This is either a
string consisting of 8 nulls or a string previously
returned by new_oid.
:param bytes serial: The serial of the data that was read when
the object was loaded from the database. If the object was
created in the current transaction this will be a string
consisting of 8 nulls.
:param bytes data: The data record. This is opaque to the
storage.
:param version: This must be an empty string. It exists for
backward compatibility.
:param transaction: The object passed to tpc_begin
:raises ConflictError: Raised when serial does not match the
most recent serial number for object oid and the conflict
was not resolved by the storage. Note that this may be deferred
to :meth:`tpc_vote`.
:raises StorageTransactionError: Raised when transaction does
not match the current transaction.
:raises StorageError: Raised when an internal error occurs
while the storage is handling the store() call. Most often this
is a descriptive subclass.
"""

def tpc_abort(transaction):
Expand Down
8 changes: 4 additions & 4 deletions src/ZODB/scripts/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@
import marshal
import profile

from persistent.timestamp import TimeStamp
from ZODB import utils
from ZODB import StorageTypes
from ZODB.TimeStamp import TimeStamp
from ZODB import StorageTypes # XXX: This import does not exist


PROGRAM = sys.argv[0]
ZERO = '\0'*8


def usage(code, msg=''):
Expand Down Expand Up @@ -283,7 +283,7 @@ def doit(srcdb, dstdb, options):
else:
vstr = r.version
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)
newrevids.store(oid, result)
t2 = time.time()
Expand Down
3 changes: 1 addition & 2 deletions src/ZODB/tests/BasicStorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from ZODB.Connection import TransactionMetaData
from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_unpickle, zodb_pickle
from ZODB.tests.StorageTestBase import ZERO

import threading
import time
Expand All @@ -30,8 +31,6 @@

from .. import utils

ZERO = b'\0'*8

class BasicStorage(object):
def checkBasics(self):
self.assertEqual(self._storage.lastTransaction(), ZERO)
Expand Down
3 changes: 2 additions & 1 deletion src/ZODB/tests/IteratorStorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from ZODB.Connection import TransactionMetaData
from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle
from ZODB.tests.StorageTestBase import ZERO
from ZODB.utils import U64, p64, load_current

import ZODB.blob
Expand Down Expand Up @@ -126,7 +127,7 @@ def checkIterationIntraTransaction(self):
data = zodb_pickle(MinPO(0))
try:
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)
# Don't do tpc_finish yet
it = self._storage.iterator()
Expand Down
2 changes: 1 addition & 1 deletion src/ZODB/tests/RevisionStorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
from ZODB.Connection import TransactionMetaData
from ZODB.tests.MinPO import MinPO
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.tests.util import time_monotonically_increases

ZERO = '\0'*8

class RevisionStorage(object):

Expand Down
2 changes: 1 addition & 1 deletion src/ZODB/tests/StorageTestBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import ZODB.tests.util


ZERO = b'\0'*8
ZERO = z64

def snooze():
# In Windows, it's possible that two successive time.time() calls return
Expand Down
2 changes: 1 addition & 1 deletion src/ZODB/tests/TransactionalUndoStorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle
from ZODB.tests.StorageTestBase import ZERO

ZERO = '\0'*8

class C(Persistent):
pass
Expand Down

0 comments on commit 23fca83

Please sign in to comment.