Commit 96659e2c authored by Jim Fulton's avatar Jim Fulton

use ZODB.utils.maxtid rather than z64

parent 64635ddb
...@@ -51,9 +51,6 @@ import ZEO.cache ...@@ -51,9 +51,6 @@ import ZEO.cache
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# max signed 64-bit value ~ infinity :) Signed cuz LBTree and TimeStamp
m64 = b'\x7f\xff\xff\xff\xff\xff\xff\xff'
def tid2time(tid): def tid2time(tid):
return str(TimeStamp(tid)) return str(TimeStamp(tid))
...@@ -498,7 +495,7 @@ class ClientStorage(ZODB.ConflictResolution.ConflictResolvingStorage): ...@@ -498,7 +495,7 @@ class ClientStorage(ZODB.ConflictResolution.ConflictResolvingStorage):
return self._call('loadSerial', oid, serial) return self._call('loadSerial', oid, serial)
def load(self, oid, version=''): def load(self, oid, version=''):
result = self.loadBefore(oid, m64) result = self.loadBefore(oid, utils.maxtid)
if result is None: if result is None:
raise POSException.POSKeyError(oid) raise POSException.POSKeyError(oid)
return result[:2] return result[:2]
......
...@@ -9,6 +9,7 @@ from zope.testing import setupstack ...@@ -9,6 +9,7 @@ from zope.testing import setupstack
from concurrent.futures import Future from concurrent.futures import Future
import mock import mock
from ZODB.POSException import ReadOnlyError from ZODB.POSException import ReadOnlyError
from ZODB.utils import maxtid
import collections import collections
import logging import logging
...@@ -16,7 +17,6 @@ import struct ...@@ -16,7 +17,6 @@ import struct
import unittest import unittest
from ..Exceptions import ClientDisconnected, ProtocolError from ..Exceptions import ClientDisconnected, ProtocolError
from ..ClientStorage import m64
from .testing import Loop from .testing import Loop
from .client import ClientRunner, Fallback from .client import ClientRunner, Fallback
...@@ -192,17 +192,18 @@ class ClientTests(Base, setupstack.TestCase, ClientRunner): ...@@ -192,17 +192,18 @@ class ClientTests(Base, setupstack.TestCase, ClientRunner):
self.assertEqual(self.pop(), (0, True, 'bar', (3, 4))) self.assertEqual(self.pop(), (0, True, 'bar', (3, 4)))
# Loading objects gets special handling to leverage the cache. # Loading objects gets special handling to leverage the cache.
loaded = self.load_before(b'1'*8, m64) loaded = self.load_before(b'1'*8, maxtid)
# The data wasn't in the cache, so we made a server call: # The data wasn't in the cache, so we made a server call:
self.assertEqual(self.pop(), self.assertEqual(
((b'1'*8, m64), False, 'loadBefore', (b'1'*8, m64))) self.pop(),
((b'1'*8, maxtid), False, 'loadBefore', (b'1'*8, maxtid)))
# Note load_before uses the oid as the message id. # Note load_before uses the oid as the message id.
self.respond((b'1'*8, m64), (b'data', b'a'*8, None)) self.respond((b'1'*8, maxtid), (b'data', b'a'*8, None))
self.assertEqual(loaded.result(), (b'data', b'a'*8, None)) self.assertEqual(loaded.result(), (b'data', b'a'*8, None))
# If we make another request, it will be satisfied from the cache: # If we make another request, it will be satisfied from the cache:
loaded = self.load_before(b'1'*8, m64) loaded = self.load_before(b'1'*8, maxtid)
self.assertEqual(loaded.result(), (b'data', b'a'*8, None)) self.assertEqual(loaded.result(), (b'data', b'a'*8, None))
self.assertFalse(transport.data) self.assertFalse(transport.data)
...@@ -210,15 +211,16 @@ class ClientTests(Base, setupstack.TestCase, ClientRunner): ...@@ -210,15 +211,16 @@ class ClientTests(Base, setupstack.TestCase, ClientRunner):
self.send('invalidateTransaction', b'b'*8, [b'1'*8]) self.send('invalidateTransaction', b'b'*8, [b'1'*8])
# Now, if we try to load current again, we'll make a server request. # Now, if we try to load current again, we'll make a server request.
loaded = self.load_before(b'1'*8, m64) loaded = self.load_before(b'1'*8, maxtid)
# Note that if we make another request for the same object, # Note that if we make another request for the same object,
# the requests will be collapsed: # the requests will be collapsed:
loaded2 = self.load_before(b'1'*8, m64) loaded2 = self.load_before(b'1'*8, maxtid)
self.assertEqual(self.pop(), self.assertEqual(
((b'1'*8, m64), False, 'loadBefore', (b'1'*8, m64))) self.pop(),
self.respond((b'1'*8, m64), (b'data2', b'b'*8, None)) ((b'1'*8, maxtid), False, 'loadBefore', (b'1'*8, maxtid)))
self.respond((b'1'*8, maxtid), (b'data2', b'b'*8, None))
self.assertEqual(loaded.result(), (b'data2', b'b'*8, None)) self.assertEqual(loaded.result(), (b'data2', b'b'*8, None))
self.assertEqual(loaded2.result(), (b'data2', b'b'*8, None)) self.assertEqual(loaded2.result(), (b'data2', b'b'*8, None))
...@@ -267,11 +269,12 @@ class ClientTests(Base, setupstack.TestCase, ClientRunner): ...@@ -267,11 +269,12 @@ class ClientTests(Base, setupstack.TestCase, ClientRunner):
# If the protocol is disconnected, it will reconnect and will # If the protocol is disconnected, it will reconnect and will
# resolve outstanding requests with exceptions: # resolve outstanding requests with exceptions:
loaded = self.load_before(b'1'*8, m64) loaded = self.load_before(b'1'*8, maxtid)
f1 = self.call('foo', 1, 2) f1 = self.call('foo', 1, 2)
self.assertFalse(loaded.done() or f1.done()) self.assertFalse(loaded.done() or f1.done())
self.assertEqual(self.pop(), self.assertEqual(
[((b'1'*8, m64), False, 'loadBefore', (b'1'*8, m64)), self.pop(),
[((b'1'*8, maxtid), False, 'loadBefore', (b'1'*8, maxtid)),
(6, False, 'foo', (1, 2))], (6, False, 'foo', (1, 2))],
) )
exc = TypeError(43) exc = TypeError(43)
......
...@@ -16,7 +16,7 @@ from __future__ import print_function ...@@ -16,7 +16,7 @@ from __future__ import print_function
import multiprocessing import multiprocessing
import re import re
from ZEO.ClientStorage import ClientStorage, m64 from ZEO.ClientStorage import ClientStorage
from ZEO.tests import forker, Cache, CommitLockTests, ThreadTests from ZEO.tests import forker, Cache, CommitLockTests, ThreadTests
from ZEO.tests import IterationTests from ZEO.tests import IterationTests
from ZEO._compat import PY3 from ZEO._compat import PY3
...@@ -26,7 +26,7 @@ from ZODB.tests import StorageTestBase, BasicStorage, \ ...@@ -26,7 +26,7 @@ from ZODB.tests import StorageTestBase, BasicStorage, \
MTStorage, ReadOnlyStorage, IteratorStorage, RecoveryStorage MTStorage, ReadOnlyStorage, IteratorStorage, RecoveryStorage
from ZODB.tests.MinPO import MinPO from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_unpickle from ZODB.tests.StorageTestBase import zodb_unpickle
from ZODB.utils import p64, u64, z64 from ZODB.utils import maxtid, p64, u64, z64
from zope.testing import renormalizing from zope.testing import renormalizing
import doctest import doctest
...@@ -1401,7 +1401,7 @@ Now we'll try to use the connection, mainly to wait for everything to ...@@ -1401,7 +1401,7 @@ Now we'll try to use the connection, mainly to wait for everything to
get processed. Before we fixed this by making tpc_finish a synchronous get processed. Before we fixed this by making tpc_finish a synchronous
call to the server. we'd get some sort of error here. call to the server. we'd get some sort of error here.
>>> _ = client._call('loadBefore', b'\0'*8, m64) >>> _ = client._call('loadBefore', b'\0'*8, maxtid)
>>> c.close() >>> c.close()
......
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