Commit c536ed31 authored by Jim Fulton's avatar Jim Fulton

save cache verification status for tests

parent 01d74173
...@@ -454,6 +454,7 @@ class Client: ...@@ -454,6 +454,7 @@ class Client:
self.register_failed_poll + local_random.random(), self.register_failed_poll + local_random.random(),
self.try_connecting) self.try_connecting)
verify_result = None # for tests
def verify(self, last_transaction_promise): def verify(self, last_transaction_promise):
protocol = self.protocol protocol = self.protocol
...@@ -463,21 +464,25 @@ class Client: ...@@ -463,21 +464,25 @@ class Client:
if cache: if cache:
cache_tid = cache.getLastTid() cache_tid = cache.getLastTid()
if not cache_tid: if not cache_tid:
self.verify_result = "Non-empty cache w/o tid"
logger.error("Non-empty cache w/o tid -- clearing") logger.error("Non-empty cache w/o tid -- clearing")
cache.clear() cache.clear()
self.client.invalidateCache() self.client.invalidateCache()
self.finished_verify(server_tid) self.finished_verify(server_tid)
elif cache_tid > server_tid: elif cache_tid > server_tid:
self.verify_result = "Cache newer than server"
logger.critical( logger.critical(
'Client has seen newer transactions than server!') 'Client has seen newer transactions than server!')
raise AssertionError("Server behind client, %r < %r, %s", raise AssertionError("Server behind client, %r < %r, %s",
server_tid, cache_tid, protocol) server_tid, cache_tid, protocol)
elif cache_tid == server_tid: elif cache_tid == server_tid:
self.verify_result = "Cache up to date"
self.finished_verify(server_tid) self.finished_verify(server_tid)
else: else:
@protocol.promise('getInvalidations', cache_tid) @protocol.promise('getInvalidations', cache_tid)
def verify_invalidations(vdata): def verify_invalidations(vdata):
if vdata: if vdata:
self.verify_result = "quick verification"
tid, oids = vdata tid, oids = vdata
for oid in oids: for oid in oids:
cache.invalidate(oid, None) cache.invalidate(oid, None)
...@@ -485,6 +490,7 @@ class Client: ...@@ -485,6 +490,7 @@ class Client:
return tid return tid
else: else:
# cache is too old # cache is too old
self.verify_result = "cache too old, clearing"
try: try:
ZODB.event.notify( ZODB.event.notify(
ZEO.interfaces.StaleCache(self.client)) ZEO.interfaces.StaleCache(self.client))
...@@ -503,6 +509,7 @@ class Client: ...@@ -503,6 +509,7 @@ class Client:
self.connected.set_exception, self.connected.set_exception,
) )
else: else:
self.verify_result = "empty cache"
self.finished_verify(server_tid) self.finished_verify(server_tid)
@finish_verify.catch @finish_verify.catch
......
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