Commit d8a1d43d authored by Grégory Wisniewski's avatar Grégory Wisniewski

Rename is(Server|Client|Listening)Connection without the 'Connection' suffix,

because there are Connection class atttributes.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1093 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent f532bbbc
......@@ -120,13 +120,13 @@ class BaseConnection(object):
def getUUID(self):
return None
def isListeningConnection(self):
def isListening(self):
return False
def isServerConnection(self):
def isServer(self):
return False
def isClientConnection(self):
def isClient(self):
return False
def hasPendingMessages(self):
......@@ -157,7 +157,7 @@ class ListeningConnection(BaseConnection):
def writable(self):
return False
def isListeningConnection(self):
def isListening(self):
return True
......@@ -468,14 +468,14 @@ class ClientConnection(Connection):
else:
Connection.writable(self)
def isClientConnection(self):
def isClient(self):
return True
class ServerConnection(Connection):
"""A connection from a remote node to this node."""
def isServerConnection(self):
def isServer(self):
return True
......
......@@ -52,7 +52,7 @@ def restrict_node_types(*node_types):
def client_connection_required(handler):
""" Raise UnexpectedPacketError if the packet comes from a client connection """
def wrapper(self, conn, packet, *args, **kwargs):
if conn.isServerConnection():
if conn.isServer():
raise protocol.UnexpectedPacketError
# it's a client connection, call the handler
handler(self, conn, packet, *args, **kwargs)
......@@ -61,7 +61,7 @@ def client_connection_required(handler):
def server_connection_required(handler):
""" Raise UnexpectedPacketError if the packet comes from a server connection """
def wrapper(self, conn, packet, *args, **kwargs):
if not conn.isServerConnection():
if not conn.isServer():
raise protocol.UnexpectedPacketError
# it's a server connection, call the handler
handler(self, conn, packet, *args, **kwargs)
......
......@@ -122,7 +122,7 @@ class Application(object):
except (ElectionFailure, PrimaryFailure):
# Forget all connections.
for conn in self.em.getConnectionList():
if not conn.isListeningConnection():
if not conn.isListening():
conn.close()
# Reelect a new primary master.
self.electPrimary(bootstrap = False)
......@@ -197,7 +197,7 @@ class Application(object):
self.primary = True
logging.debug('I am the primary, so sending an announcement')
for conn in em.getConnectionList():
if conn.isClientConnection():
if conn.isClient():
conn.notify(protocol.announcePrimaryMaster())
conn.abort()
closed = False
......@@ -206,12 +206,12 @@ class Application(object):
em.poll(1)
closed = True
for conn in em.getConnectionList():
if conn.isClientConnection():
if conn.isClient():
closed = False
break
if t + 10 < time():
for conn in em.getConnectionList():
if conn.isClientConnection():
if conn.isClient():
conn.close()
closed = True
else:
......@@ -227,13 +227,13 @@ class Application(object):
primary = self.primary_master_node
addr = primary.getServer()
for conn in em.getConnectionList():
if conn.isServerConnection() or conn.isClientConnection() \
if conn.isServer() or conn.isClient() \
and addr != conn.getAddress():
conn.close()
# But if there is no such connection, something wrong happened.
for conn in em.getConnectionList():
if conn.isClientConnection() and addr == conn.getAddress():
if conn.isClient() and addr == conn.getAddress():
break
else:
raise ElectionFailure, 'no connection remains to the primary'
......@@ -244,7 +244,7 @@ class Application(object):
# Ask all connected nodes to reelect a single primary master.
for conn in em.getConnectionList():
if conn.isClientConnection():
if conn.isClient():
conn.notify(protocol.reelectPrimaryMaster())
conn.abort()
......@@ -261,7 +261,7 @@ class Application(object):
closed = True
for conn in em.getConnectionList():
if conn.isClientConnection():
if conn.isClient():
# Still not closed.
closed = False
break
......@@ -272,7 +272,7 @@ class Application(object):
# Close all connections.
for conn in em.getConnectionList():
if not conn.isListeningConnection():
if not conn.isListening():
conn.close()
bootstrap = False
......@@ -666,7 +666,7 @@ class Application(object):
notification_packet = protocol.notifyClusterInformation(state)
for conn in em.getConnectionList():
node = nm.getNodeByUUID(conn.getUUID())
if conn.isListeningConnection() or node is None:
if conn.isListening() or node is None:
# not identified or listening, keep the identification handler
continue
conn.notify(notification_packet)
......
......@@ -49,7 +49,7 @@ class PrimaryMasterHandler(MasterHandler):
raise PrimaryFailure, 'primary master is dead'
def packetReceived(self, conn, packet):
if not conn.isServerConnection():
if not conn.isServer():
node = self.app.nm.getNodeByServer(conn.getAddress())
if node.getState() != BROKEN_STATE:
node.setState(RUNNING_STATE)
......
......@@ -178,7 +178,7 @@ class Application(object):
# First of all, make sure that I have no connection.
for conn in self.em.getConnectionList():
if not conn.isListeningConnection():
if not conn.isListening():
conn.close()
# search, find, connect and identify to the primary master
......@@ -296,6 +296,6 @@ class Application(object):
def shutdown(self):
"""Close all connections and exit"""
for c in self.em.getConnectionList():
if not c.isListeningConnection():
if not c.isListening():
c.close()
sys.exit("Application has been asked to shut down")
......@@ -247,7 +247,7 @@ class MasterServerElectionTests(NeoTestBase):
uuid = self.identifyToMasterNode(node_type=MASTER_NODE_TYPE, port=self.master_port)
# Without a client connection
conn = Mock({"getUUID" : uuid,
"isServerConnection" : True,
"isServer" : True,
"getAddress" : ("127.0.0.1", self.master_port),})
self.assertEqual(len(self.app.unconnected_master_node_set), 1)
self.assertEqual(len(self.app.negotiating_master_node_set), 0)
......@@ -462,7 +462,7 @@ class MasterServerElectionTests(NeoTestBase):
packet = protocol.requestNodeIdentification(*args)
# test alien cluster
conn = Mock({"_addPacket" : None, "abort" : None,
"isServerConnection" : True})
"isServer" : True})
self.checkProtocolErrorRaised(
election.handleRequestNodeIdentification,
conn,
......@@ -474,7 +474,7 @@ class MasterServerElectionTests(NeoTestBase):
name="INVALID_NAME",)
# test connection of a storage node
conn = Mock({"_addPacket" : None, "abort" : None, "expectMessage" : None,
"isServerConnection" : True})
"isServer" : True})
self.checkNotReadyErrorRaised(
election.handleRequestNodeIdentification,
conn,
......@@ -487,7 +487,7 @@ class MasterServerElectionTests(NeoTestBase):
# known node
conn = Mock({"_addPacket" : None, "abort" : None, "expectMessage" : None,
"isServerConnection" : True})
"isServer" : True})
self.assertEqual(len(self.app.nm.getMasterNodeList()), 1)
node = self.app.nm.getMasterNodeList()[0]
self.assertEqual(node.getUUID(), None)
......@@ -505,7 +505,7 @@ class MasterServerElectionTests(NeoTestBase):
self.checkAcceptNodeIdentification(conn, answered_packet=packet)
# unknown node
conn = Mock({"_addPacket" : None, "abort" : None, "expectMessage" : None,
"isServerConnection" : True})
"isServer" : True})
new_uuid = self.getNewUUID()
self.assertEqual(len(self.app.nm.getMasterNodeList()), 1)
self.assertEqual(len(self.app.unconnected_master_node_set), 1)
......@@ -523,7 +523,7 @@ class MasterServerElectionTests(NeoTestBase):
self.assertEqual(len(self.app.negotiating_master_node_set), 0)
# broken node
conn = Mock({"_addPacket" : None, "abort" : None, "expectMessage" : None,
"isServerConnection" : True})
"isServer" : True})
node = self.app.nm.getNodeByServer(("127.0.0.1", self.master_port+1))
self.assertEqual(node.getUUID(), new_uuid)
self.assertEqual(node.getState(), RUNNING_STATE)
......@@ -546,7 +546,7 @@ class MasterServerElectionTests(NeoTestBase):
packet = protocol.askPrimaryMaster()
conn = Mock({"_addPacket" : None,
"getUUID" : uuid,
"isServerConnection" : True,
"isServer" : True,
"getAddress" : ("127.0.0.1", self.master_port)})
self.assertEqual(len(self.app.nm.getMasterNodeList()), 1)
election.handleAskPrimaryMaster(conn, packet)
......@@ -561,14 +561,14 @@ class MasterServerElectionTests(NeoTestBase):
# No uuid
conn = Mock({"_addPacket" : None,
"getUUID" : None,
"isServerConnection" : True,
"isServer" : True,
"getAddress" : ("127.0.0.1", self.master_port)})
self.assertEqual(len(self.app.nm.getMasterNodeList()), 1)
self.checkIdenficationRequired(election.handleAnnouncePrimaryMaster, conn, packet)
# announce
conn = Mock({"_addPacket" : None,
"getUUID" : uuid,
"isServerConnection" : True,
"isServer" : True,
"getAddress" : ("127.0.0.1", self.master_port)})
self.assertEqual(self.app.primary, None)
self.assertEqual(self.app.primary_master_node, None)
......@@ -578,7 +578,7 @@ class MasterServerElectionTests(NeoTestBase):
# set current as primary, and announce another, must raise
conn = Mock({"_addPacket" : None,
"getUUID" : uuid,
"isServerConnection" : True,
"isServer" : True,
"getAddress" : ("127.0.0.1", self.master_port)})
self.app.primary = True
self.assertEqual(self.app.primary, True)
......@@ -592,7 +592,7 @@ class MasterServerElectionTests(NeoTestBase):
# No uuid
conn = Mock({"_addPacket" : None,
"getUUID" : None,
"isServerConnection" : True,
"isServer" : True,
"getAddress" : ("127.0.0.1", self.master_port)})
self.assertRaises(ElectionFailure, election.handleReelectPrimaryMaster, conn, packet)
......
......@@ -36,7 +36,7 @@ class StorageClientHandlerTests(NeoTestBase):
def checkHandleUnexpectedPacket(self, _call, _msg_type, _listening=True, **kwargs):
conn = Mock({
"getAddress" : ("127.0.0.1", self.master_port),
"isServerConnection": _listening,
"isServer": _listening,
})
packet = Packet(msg_type=_msg_type)
# hook
......
......@@ -70,7 +70,7 @@ class StorageInitializationHandlerTests(NeoTestBase):
uuid = self.getNewUUID()
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServerConnection" : False})
"isServer" : False})
self.assertRaises(PrimaryFailure, self.verification.timeoutExpired, conn,)
# nothing happens
self.checkNoPacketSent(conn)
......@@ -80,7 +80,7 @@ class StorageInitializationHandlerTests(NeoTestBase):
uuid = self.getNewUUID()
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServerConnection" : False})
"isServer" : False})
self.assertRaises(PrimaryFailure, self.verification.connectionClosed, conn,)
# nothing happens
self.checkNoPacketSent(conn)
......@@ -90,7 +90,7 @@ class StorageInitializationHandlerTests(NeoTestBase):
uuid = self.getNewUUID()
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServerConnection" : False})
"isServer" : False})
self.assertRaises(PrimaryFailure, self.verification.peerBroken, conn,)
# nothing happens
self.checkNoPacketSent(conn)
......@@ -101,7 +101,7 @@ class StorageInitializationHandlerTests(NeoTestBase):
# send a table
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServerConnection" : False})
"isServer" : False})
self.app.pt = PartitionTable(3, 2)
node_1 = self.getNewUUID()
......
......@@ -35,7 +35,7 @@ class StorageMasterHandlerTests(NeoTestBase):
def checkHandleUnexpectedPacket(self, _call, _msg_type, _listening=True, **kwargs):
conn = Mock({
"getAddress" : ("127.0.0.1", self.master_port),
"isServerConnection": _listening,
"isServer": _listening,
})
packet = Packet(msg_type=_msg_type)
# hook
......@@ -100,7 +100,7 @@ class StorageMasterHandlerTests(NeoTestBase):
# old partition change -> do nothing
app = self.app
conn = Mock({
"isServerConnection": False,
"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
app.replicator = Mock({})
......@@ -125,7 +125,7 @@ class StorageMasterHandlerTests(NeoTestBase):
)
# context
conn = Mock({
"isServerConnection": False,
"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
packet = Packet(msg_type=NOTIFY_PARTITION_CHANGES)
......@@ -163,13 +163,13 @@ class StorageMasterHandlerTests(NeoTestBase):
def test_16_handleStopOperation1(self):
# OperationFailure
conn = Mock({ 'isServerConnection': False })
conn = Mock({ 'isServer': False })
packet = Packet(msg_type=STOP_OPERATION)
self.assertRaises(OperationFailure, self.operation.handleStopOperation, conn, packet)
def test_22_handleLockInformation2(self):
# load transaction informations
conn = Mock({ 'isServerConnection': False, })
conn = Mock({ 'isServer': False, })
self.app.dm = Mock({ })
packet = Packet(msg_type=LOCK_INFORMATION)
transaction = Mock({ 'getObjectList': ((0, ), ), })
......@@ -181,13 +181,13 @@ class StorageMasterHandlerTests(NeoTestBase):
self.checkNotifyInformationLocked(conn, answered_packet=packet)
# transaction not in transaction_dict -> KeyError
transaction = Mock({ 'getObjectList': ((0, ), ), })
conn = Mock({ 'isServerConnection': False, })
conn = Mock({ 'isServer': False, })
self.operation.handleLockInformation(conn, packet, '\x01' * 8)
self.checkNotifyInformationLocked(conn, answered_packet=packet)
def test_23_handleUnlockInformation2(self):
# delete transaction informations
conn = Mock({ 'isServerConnection': False, })
conn = Mock({ 'isServer': False, })
self.app.dm = Mock({ })
packet = Packet(msg_type=LOCK_INFORMATION)
transaction = Mock({ 'getObjectList': ((0, ), ), })
......@@ -203,7 +203,7 @@ class StorageMasterHandlerTests(NeoTestBase):
calls[0].checkArgs(INVALID_TID)
# transaction not in transaction_dict -> KeyError
transaction = Mock({ 'getObjectList': ((0, ), ), })
conn = Mock({ 'isServerConnection': False, })
conn = Mock({ 'isServer': False, })
self.operation.handleLockInformation(conn, packet, '\x01' * 8)
self.checkNotifyInformationLocked(conn, answered_packet=packet)
......
......@@ -33,7 +33,7 @@ class StorageStorageHandlerTests(NeoTestBase):
def checkHandleUnexpectedPacket(self, _call, _msg_type, _listening=True, **kwargs):
conn = Mock({
"getAddress" : ("127.0.0.1", self.master_port),
"isServerConnection": _listening,
"isServer": _listening,
})
packet = Packet(msg_type=_msg_type)
# hook
......
......@@ -72,7 +72,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
uuid = self.getNewUUID()
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServerConnection" : False})
"isServer" : False})
self.assertRaises(PrimaryFailure, self.verification.timeoutExpired, conn,)
# nothing happens
self.checkNoPacketSent(conn)
......@@ -82,7 +82,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
uuid = self.getNewUUID()
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServerConnection" : False})
"isServer" : False})
self.assertRaises(PrimaryFailure, self.verification.connectionClosed, conn,)
# nothing happens
self.checkNoPacketSent(conn)
......@@ -92,7 +92,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
uuid = self.getNewUUID()
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServerConnection" : False})
"isServer" : False})
self.assertRaises(PrimaryFailure, self.verification.peerBroken, conn,)
# nothing happens
self.checkNoPacketSent(conn)
......@@ -103,7 +103,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
# return invalid if db store nothing
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServerConnection" : False})
"isServer" : False})
self.verification.handleAskLastIDs(conn, packet)
oid, tid, ptid = self.checkAnswerLastIDs(conn, decode=True)
self.assertEqual(oid, INVALID_OID)
......@@ -114,7 +114,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
# insert some oid
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServerConnection" : False})
"isServer" : False})
self.app.dm.begin()
self.app.dm.query("""insert into obj (oid, serial, compression,
checksum, value) values (3, 'A', 0, 0, '')""")
......@@ -151,7 +151,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
self.assertEqual(len(self.app.pt.getCellList(1)), 0)
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServerConnection" : False})
"isServer" : False})
self.verification.handleAskPartitionTable(conn, packet, [1,])
ptid, row_list = self.checkAnswerPartitionTable(conn, decode=True)
self.assertEqual(len(row_list), 1)
......@@ -165,7 +165,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
self.assertTrue(self.app.pt.hasOffset(1))
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServerConnection" : False})
"isServer" : False})
self.verification.handleAskPartitionTable(conn, packet, [1,])
ptid, row_list = self.checkAnswerPartitionTable(conn, decode=True)
self.assertEqual(len(row_list), 1)
......@@ -176,7 +176,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
def test_10_handleNotifyPartitionChanges(self):
# old partition change
conn = Mock({
"isServerConnection": False,
"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
packet = Packet(msg_type=NOTIFY_PARTITION_CHANGES)
......@@ -186,7 +186,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
# new node
conn = Mock({
"isServerConnection": False,
"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
packet = Packet(msg_type=NOTIFY_PARTITION_CHANGES)
......@@ -206,7 +206,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
def test_11_handleStartOperation(self):
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServerConnection': False })
'isServer': False })
self.assertFalse(self.app.operational)
packet = Packet(msg_type=STOP_OPERATION)
self.verification.handleStartOperation(conn, packet)
......@@ -214,14 +214,14 @@ class StorageVerificationHandlerTests(NeoTestBase):
def test_12_handleStopOperation(self):
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServerConnection': False })
'isServer': False })
packet = Packet(msg_type=STOP_OPERATION)
self.assertRaises(OperationFailure, self.verification.handleStopOperation, conn, packet)
def test_13_handleAskUnfinishedTransactions(self):
# client connection with no data
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServerConnection': False})
'isServer': False})
packet = Packet(msg_type=ASK_UNFINISHED_TRANSACTIONS)
self.verification.handleAskUnfinishedTransactions(conn, packet)
(tid_list, ) = self.checkAnswerUnfinishedTransactions(conn, decode=True)
......@@ -233,7 +233,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
checksum, value) values (0, 4, 0, 0, '')""")
self.app.dm.commit()
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServerConnection': False})
'isServer': False})
packet = Packet(msg_type=ASK_UNFINISHED_TRANSACTIONS)
self.verification.handleAskUnfinishedTransactions(conn, packet)
(tid_list, ) = self.checkAnswerUnfinishedTransactions(conn, decode=True)
......@@ -243,7 +243,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
def test_14_handleAskTransactionInformation(self):
# ask from client conn with no data
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServerConnection': False })
'isServer': False })
packet = Packet(msg_type=ASK_TRANSACTION_INFORMATION)
self.verification.handleAskTransactionInformation(conn, packet, p64(1))
code, message = self.checkErrorPacket(conn, decode=True)
......@@ -258,7 +258,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
self.app.dm.commit()
# object from trans
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServerConnection': False })
'isServer': False })
packet = Packet(msg_type=ASK_TRANSACTION_INFORMATION)
self.verification.handleAskTransactionInformation(conn, packet, p64(1))
tid, user, desc, ext, oid_list = self.checkAnswerTransactionInformation(conn, decode=True)
......@@ -270,7 +270,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
self.assertEqual(u64(oid_list[0]), 2)
# object from ttrans
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServerConnection': False })
'isServer': False })
packet = Packet(msg_type=ASK_TRANSACTION_INFORMATION)
self.verification.handleAskTransactionInformation(conn, packet, p64(3))
tid, user, desc, ext, oid_list = self.checkAnswerTransactionInformation(conn, decode=True)
......@@ -283,7 +283,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
# input some tmp data and ask from server, must find one transaction
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServerConnection': True })
'isServer': True })
# find the one in trans
packet = Packet(msg_type=ASK_TRANSACTION_INFORMATION)
self.verification.handleAskTransactionInformation(conn, packet, p64(1))
......@@ -296,7 +296,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
self.assertEqual(u64(oid_list[0]), 2)
# do not find the one in ttrans
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServerConnection': True })
'isServer': True })
packet = Packet(msg_type=ASK_TRANSACTION_INFORMATION)
self.verification.handleAskTransactionInformation(conn, packet, p64(3))
code, message = self.checkErrorPacket(conn, decode=True)
......@@ -305,7 +305,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
def test_15_handleAskObjectPresent(self):
# client connection with no data
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServerConnection': False})
'isServer': False})
packet = Packet(msg_type=ASK_OBJECT_PRESENT)
self.verification.handleAskObjectPresent(conn, packet, p64(1), p64(2))
code, message = self.checkErrorPacket(conn, decode=True)
......@@ -317,7 +317,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
checksum, value) values (1, 2, 0, 0, '')""")
self.app.dm.commit()
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServerConnection': False})
'isServer': False})
packet = Packet(msg_type=ASK_OBJECT_PRESENT)
self.verification.handleAskObjectPresent(conn, packet, p64(1), p64(2))
oid, tid = self.checkAnswerObjectPresent(conn, decode=True)
......@@ -327,7 +327,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
def test_16_handleDeleteTransaction(self):
# client connection with no data
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServerConnection': False})
'isServer': False})
packet = Packet(msg_type=ASK_OBJECT_PRESENT)
self.verification.handleDeleteTransaction(conn, packet, p64(1))
# client connection with data
......@@ -342,7 +342,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
def test_17_handleCommitTransaction(self):
# commit a transaction
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port),
'isServerConnection': False })
'isServer': False })
dm = Mock()
self.app.dm = dm
packet = Packet(msg_type=COMMIT_TRANSACTION)
......
......@@ -100,7 +100,7 @@ class BootstrapManagerTests(NeoTestBase):
def test_04_timeoutExpired(self):
conn = Mock({
"isServerConnection": False,
"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
# pmn connection has expired
......@@ -120,7 +120,7 @@ class BootstrapManagerTests(NeoTestBase):
def test_05_connectionClosed(self):
conn = Mock({
"isServerConnection": False,
"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
# pmn connection is closed
......@@ -140,7 +140,7 @@ class BootstrapManagerTests(NeoTestBase):
def test_06_peerBroken(self):
conn = Mock({
"isServerConnection": False,
"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
# the primary is broken
......@@ -161,7 +161,7 @@ class BootstrapManagerTests(NeoTestBase):
def test_07_handleNotReady(self):
# the primary is not ready
conn = Mock({
"isServerConnection": False,
"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
self.app.trying_master_node = self.trying_master_node
......@@ -172,7 +172,7 @@ class BootstrapManagerTests(NeoTestBase):
self.checkClosed(conn)
# another master is not ready
conn = Mock({
"isServerConnection": False,
"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
self.app.trying_master_node = self.trying_master_node
......@@ -186,7 +186,7 @@ class BootstrapManagerTests(NeoTestBase):
def test_09_handleAcceptNodeIdentification2(self):
# not a master node -> rejected
conn = Mock({"isServerConnection": False,
conn = Mock({"isServer": False,
"getAddress" : ("127.0.0.1", self.storage_port), })
self.app.trying_master_node = self.trying_master_node
packet = Packet(msg_type=ACCEPT_NODE_IDENTIFICATION)
......@@ -209,7 +209,7 @@ class BootstrapManagerTests(NeoTestBase):
def test_09_handleAcceptNodeIdentification3(self):
# bad address -> rejected
conn = Mock({"isServerConnection": False,
conn = Mock({"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port), })
self.app.trying_master_node = self.trying_master_node
packet = Packet(msg_type=ACCEPT_NODE_IDENTIFICATION)
......@@ -229,7 +229,7 @@ class BootstrapManagerTests(NeoTestBase):
def test_09_handleAcceptNodeIdentification4(self):
# bad number of replicas/partitions
conn = Mock({"isServerConnection": False,
conn = Mock({"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port), })
self.app.trying_master_node = self.trying_master_node
packet = Packet(msg_type=ACCEPT_NODE_IDENTIFICATION)
......@@ -261,7 +261,7 @@ class BootstrapManagerTests(NeoTestBase):
self.assertNotEquals(uuid, your_uuid)
self.app.num_partitions = None # will create a partition table
self.app.num_replicas = None
conn = Mock({"isServerConnection": False,
conn = Mock({"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port), })
self.app.trying_master_node = self.trying_master_node
self.assertNotEquals(self.app.trying_master_node.getUUID(), uuid)
......@@ -295,7 +295,7 @@ class BootstrapManagerTests(NeoTestBase):
existing_master = ('127.0.0.1', self.master_port, self.getNewUUID(), )
new_master = ('192.168.0.1', 10001, self.getNewUUID(), )
known_masters = (existing_master, new_master, )
conn = Mock({"isServerConnection": False,
conn = Mock({"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_type=ANSWER_PRIMARY_MASTER)
self.assertTrue(existing_master[:2] in self.app.nm.server_dict)
......@@ -318,7 +318,7 @@ class BootstrapManagerTests(NeoTestBase):
def test_10_handleAnswerPrimaryMaster03(self):
# invalid primary master uuid -> close connection
conn = Mock({"isServerConnection": False,
conn = Mock({"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_type=ANSWER_PRIMARY_MASTER)
pmn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port))
......@@ -338,7 +338,7 @@ class BootstrapManagerTests(NeoTestBase):
def test_10_handleAnswerPrimaryMaster04(self):
# trying_master_node is not pmn -> close connection
conn = Mock({"isServerConnection": False,
conn = Mock({"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_type=ANSWER_PRIMARY_MASTER)
pmn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port))
......@@ -360,7 +360,7 @@ class BootstrapManagerTests(NeoTestBase):
def test_10_handleAnswerPrimaryMaster05(self):
# trying_master_node is pmn -> set verification handler
conn = Mock({"isServerConnection": False,
conn = Mock({"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_type=ANSWER_PRIMARY_MASTER)
pmn = self.app.nm.getNodeByServer(('127.0.0.1', self.master_port))
......@@ -380,7 +380,7 @@ class BootstrapManagerTests(NeoTestBase):
def test_10_handleAnswerPrimaryMaster06(self):
# primary_uuid not known -> nothing happen
conn = Mock({"isServerConnection": False,
conn = Mock({"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port), })
packet = Packet(msg_type=ANSWER_PRIMARY_MASTER)
self.app.primary_master_node = None
......
......@@ -186,7 +186,7 @@ class ConnectionTests(unittest.TestCase):
# test abort
bc.abort()
self.assertEqual(bc.aborted, True)
self.assertRaises(NotImplementedError, bc.isServerConnection)
self.assertRaises(NotImplementedError, bc.isServer)
def test_04_Connection_pending(self):
em = Mock()
......@@ -763,7 +763,7 @@ class ConnectionTests(unittest.TestCase):
addr=("127.0.0.7", 93413))
# check connector created and connection initialize
self.assertFalse(bc.connecting)
self.assertFalse(bc.isServerConnection())
self.assertFalse(bc.isServer())
self.assertNotEqual(bc.getConnector(), None)
conn = bc.getConnector()
self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1)
......@@ -794,7 +794,7 @@ class ConnectionTests(unittest.TestCase):
DoNothingConnector.makeClientConnection = makeClientConnection_org
# check connector created and connection initialize
self.assertTrue(bc.connecting)
self.assertFalse(bc.isServerConnection())
self.assertFalse(bc.isServer())
self.assertNotEqual(bc.getConnector(), None)
conn = bc.getConnector()
self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1)
......@@ -992,7 +992,7 @@ class ConnectionTests(unittest.TestCase):
# test abort
bc.abort()
self.assertEqual(bc.aborted, True)
self.assertTrue(bc.isServerConnection())
self.assertTrue(bc.isServer())
def test_15_MTClientConnection(self):
......@@ -1007,7 +1007,7 @@ class ConnectionTests(unittest.TestCase):
addr=("127.0.0.7", 93413), dispatcher=dispatcher)
# check connector created and connection initialize
self.assertFalse(bc.connecting)
self.assertFalse(bc.isServerConnection())
self.assertFalse(bc.isServer())
self.assertNotEqual(bc.getConnector(), None)
conn = bc.getConnector()
self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1)
......@@ -1037,7 +1037,7 @@ class ConnectionTests(unittest.TestCase):
DoNothingConnector.makeClientConnection = makeClientConnection_org
# check connector created and connection initialize
self.assertTrue(bc.connecting)
self.assertFalse(bc.isServerConnection())
self.assertFalse(bc.isServer())
self.assertNotEqual(bc.getConnector(), None)
conn = bc.getConnector()
self.assertEquals(len(conn.mockGetNamedCalls("makeClientConnection")), 1)
......@@ -1116,7 +1116,7 @@ class ConnectionTests(unittest.TestCase):
# test abort
bc.abort()
self.assertEqual(bc.aborted, True)
self.assertTrue(bc.isServerConnection())
self.assertTrue(bc.isServer())
# XXX check locking ???
......
......@@ -118,11 +118,11 @@ class HandlerDecoratorsTests(NeoTestBase):
handler = Mock({})
wrapped = decorators.client_connection_required(handler)
# server connection -> fail
conn = Mock({ 'isServerConnection': True, })
conn = Mock({ 'isServer': True, })
self.assertRaises(UnexpectedPacketError, wrapped, self, conn, packet)
self.checkHandlerNotCalled(handler)
# client connection -> ok
conn = Mock({ 'isServerConnection': False, })
conn = Mock({ 'isServer': False, })
wrapped(self, conn, packet)
self.checkHandlerCalled(handler)
......@@ -131,11 +131,11 @@ class HandlerDecoratorsTests(NeoTestBase):
handler = Mock({})
wrapped = decorators.server_connection_required(handler)
# client connection -> fail
conn = Mock({ 'isServerConnection': False, })
conn = Mock({ 'isServer': False, })
self.assertRaises(UnexpectedPacketError, wrapped, self, conn, packet)
self.checkHandlerNotCalled(handler)
# server connection -> ok
conn = Mock({ 'isServerConnection': True, })
conn = Mock({ 'isServer': True, })
wrapped(self, conn, packet)
self.checkHandlerCalled(handler)
......
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