Commit 9f5e14f1 authored by Julien Muchembled's avatar Julien Muchembled

client: raise NEOStorageError instead of POSException.StorageError on protocol error

parent 4039f4da
...@@ -15,12 +15,13 @@ ...@@ -15,12 +15,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from neo.lib import handler from neo.lib import handler
from ZODB.POSException import StorageError, ReadOnlyError from ..exception import NEOStorageError
from ZODB.POSException import ReadOnlyError
class AnswerBaseHandler(handler.AnswerBaseHandler): # XXX class AnswerBaseHandler(handler.AnswerBaseHandler): # XXX
def protocolError(self, conn, message): def protocolError(self, conn, message):
raise StorageError("protocol error: %s" % message) raise NEOStorageError("protocol error: %s" % message)
def readOnlyAccess(self, conn, message): def readOnlyAccess(self, conn, message):
raise ReadOnlyError(message) raise ReadOnlyError(message)
...@@ -1391,8 +1391,7 @@ class Test(NEOThreadedTest): ...@@ -1391,8 +1391,7 @@ class Test(NEOThreadedTest):
client.tpc_begin(None, txn) client.tpc_begin(None, txn)
txn_context = client._txn_container.get(txn) txn_context = client._txn_container.get(txn)
txn_context.ttid = add64(txn_context.ttid, 1) txn_context.ttid = add64(txn_context.ttid, 1)
self.assertRaises(POSException.StorageError, self.assertRaises(NEOStorageError, client.tpc_finish, txn)
client.tpc_finish, txn)
@with_cluster() @with_cluster()
def testStorageFailureDuringTpcFinish(self, cluster): def testStorageFailureDuringTpcFinish(self, cluster):
...@@ -1497,7 +1496,7 @@ class Test(NEOThreadedTest): ...@@ -1497,7 +1496,7 @@ class Test(NEOThreadedTest):
t, c = cluster.getTransaction() t, c = cluster.getTransaction()
c.root()['x'] = PCounter() # 1 store() to each storage c.root()['x'] = PCounter() # 1 store() to each storage
with Patch(cluster.client, waitStoreResponses=waitStoreResponses): with Patch(cluster.client, waitStoreResponses=waitStoreResponses):
self.assertRaises(POSException.StorageError, t.commit) self.assertRaises(NEOStorageError, t.commit)
self.assertEqual(cluster.neoctl.getClusterState(), self.assertEqual(cluster.neoctl.getClusterState(),
ClusterStates.RUNNING) ClusterStates.RUNNING)
......
...@@ -12,6 +12,7 @@ from multiprocessing.queues import SimpleQueue ...@@ -12,6 +12,7 @@ from multiprocessing.queues import SimpleQueue
from struct import Struct from struct import Struct
from netfilterqueue import NetfilterQueue from netfilterqueue import NetfilterQueue
import gevent.socket # preload for subprocesses import gevent.socket # preload for subprocesses
from neo.client.exception import NEOStorageError
from neo.client.Storage import Storage from neo.client.Storage import Storage
from neo.lib import logging, util from neo.lib import logging, util
from neo.lib.connector import SocketConnector from neo.lib.connector import SocketConnector
...@@ -149,7 +150,7 @@ class Client(Process): ...@@ -149,7 +150,7 @@ class Client(Process):
finally: finally:
self.setDSCP(nm, -1) self.setDSCP(nm, -1)
except ( except (
POSException.StorageError, # XXX: 'already connected' error NEOStorageError, # XXX: 'already connected' error
POSException.ConflictError, # XXX: same but during conflict resolution POSException.ConflictError, # XXX: same but during conflict resolution
), e: ), e:
if 'unexpected packet:' in str(e): if 'unexpected packet:' in str(e):
......
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