Commit 8552935d authored by Vincent Pelletier's avatar Vincent Pelletier

Use consistent port/node relationship in tests.

parent 62f142d3
...@@ -559,7 +559,7 @@ class ClientApplicationTests(NeoUnitTestBase): ...@@ -559,7 +559,7 @@ class ClientApplicationTests(NeoUnitTestBase):
conn = Mock({ conn = Mock({
'getNextId': 1, 'getNextId': 1,
'fakeReceived': transaction_info, 'fakeReceived': transaction_info,
'getAddress': ('127.0.0.1', 10010), 'getAddress': ('127.0.0.1', 10020),
}) })
node = app.nm.createStorage(address=conn.getAddress()) node = app.nm.createStorage(address=conn.getAddress())
app.cp = Mock({ app.cp = Mock({
...@@ -742,7 +742,7 @@ class ClientApplicationTests(NeoUnitTestBase): ...@@ -742,7 +742,7 @@ class ClientApplicationTests(NeoUnitTestBase):
'getUUID': ReturnValues(uuid1, uuid2), 'getUUID': ReturnValues(uuid1, uuid2),
'fakeGetApp': app, 'fakeGetApp': app,
'fakeReceived': ReturnValues(p3, p4), 'fakeReceived': ReturnValues(p3, p4),
'getAddress': ('127.0.0.1', 10010), 'getAddress': ('127.0.0.1', 10021),
}) })
storage_1_conn = Mock() storage_1_conn = Mock()
storage_2_conn = Mock() storage_2_conn = Mock()
......
...@@ -43,9 +43,12 @@ class MasterClientHandlerTests(NeoUnitTestBase): ...@@ -43,9 +43,12 @@ class MasterClientHandlerTests(NeoUnitTestBase):
self.master_address = ('127.0.0.1', self.master_port) self.master_address = ('127.0.0.1', self.master_port)
self.client_address = ('127.0.0.1', self.client_port) self.client_address = ('127.0.0.1', self.client_port)
self.storage_address = ('127.0.0.1', self.storage_port) self.storage_address = ('127.0.0.1', self.storage_port)
self.storage_uuid = self.getNewUUID()
# register the storage # register the storage
kw = {'uuid':self.getNewUUID(), 'address': self.master_address} self.app.nm.createStorage(
self.app.nm.createStorage(**kw) uuid=self.storage_uuid,
address=self.storage_address,
)
def getLastUUID(self): def getLastUUID(self):
return self.uuid return self.uuid
...@@ -109,16 +112,14 @@ class MasterClientHandlerTests(NeoUnitTestBase): ...@@ -109,16 +112,14 @@ class MasterClientHandlerTests(NeoUnitTestBase):
def test_09_askFinishTransaction(self): def test_09_askFinishTransaction(self):
service = self.service service = self.service
uuid = self.identifyToMasterNode()
# do the right job # do the right job
client_uuid = self.identifyToMasterNode(node_type=NodeTypes.CLIENT, port=self.client_port) client_uuid = self.identifyToMasterNode(node_type=NodeTypes.CLIENT, port=self.client_port)
storage_uuid = self.identifyToMasterNode() storage_uuid = self.storage_uuid
storage_conn = self.getFakeConnection(storage_uuid, self.storage_address) storage_conn = self.getFakeConnection(storage_uuid, self.storage_address)
storage2_uuid = self.identifyToMasterNode() storage2_uuid = self.identifyToMasterNode(port=10022)
storage2_conn = self.getFakeConnection(storage2_uuid, storage2_conn = self.getFakeConnection(storage2_uuid,
(self.storage_address[0], self.storage_address[1] + 1)) (self.storage_address[0], self.storage_address[1] + 1))
self.app.setStorageReady(storage2_uuid) self.app.setStorageReady(storage2_uuid)
self.assertNotEqual(uuid, client_uuid)
conn = self.getFakeConnection(client_uuid, self.client_address) conn = self.getFakeConnection(client_uuid, self.client_address)
self.app.pt = Mock({ self.app.pt = Mock({
'getPartition': 0, 'getPartition': 0,
...@@ -182,7 +183,7 @@ class MasterClientHandlerTests(NeoUnitTestBase): ...@@ -182,7 +183,7 @@ class MasterClientHandlerTests(NeoUnitTestBase):
tid = self.getNextTID() tid = self.getNextTID()
peer_id = 42 peer_id = 42
conn = self.getFakeConnection(peer_id=peer_id) conn = self.getFakeConnection(peer_id=peer_id)
storage_uuid = self.identifyToMasterNode() storage_uuid = self.storage_uuid
storage_conn = self.getFakeConnection(storage_uuid, storage_conn = self.getFakeConnection(storage_uuid,
self.storage_address) self.storage_address)
self.app.nm.getByUUID(storage_uuid).setConnection(storage_conn) self.app.nm.getByUUID(storage_uuid).setConnection(storage_conn)
...@@ -195,7 +196,7 @@ class MasterClientHandlerTests(NeoUnitTestBase): ...@@ -195,7 +196,7 @@ class MasterClientHandlerTests(NeoUnitTestBase):
self.assertEqual(self.app.packing[1], peer_id) self.assertEqual(self.app.packing[1], peer_id)
self.assertEqual(self.app.packing[2], set([storage_uuid, ])) self.assertEqual(self.app.packing[2], set([storage_uuid, ]))
# Asking again to pack will cause an immediate error # Asking again to pack will cause an immediate error
storage_uuid = self.identifyToMasterNode() storage_uuid = self.identifyToMasterNode(port=10022)
storage_conn = self.getFakeConnection(storage_uuid, storage_conn = self.getFakeConnection(storage_uuid,
self.storage_address) self.storage_address)
self.app.nm.getByUUID(storage_uuid).setConnection(storage_conn) self.app.nm.getByUUID(storage_uuid).setConnection(storage_conn)
......
...@@ -159,7 +159,7 @@ class MasterStorageHandlerTests(NeoUnitTestBase): ...@@ -159,7 +159,7 @@ class MasterStorageHandlerTests(NeoUnitTestBase):
state = NodeStates.TEMPORARILY_DOWN state = NodeStates.TEMPORARILY_DOWN
# define two nodes # define two nodes
node1, conn1 = self.identifyToMasterNode() node1, conn1 = self.identifyToMasterNode()
node2, conn2 = self.identifyToMasterNode() node2, conn2 = self.identifyToMasterNode(port=10022)
node1.setRunning() node1.setRunning()
node2.setRunning() node2.setRunning()
self.assertEqual(node1.getState(), NodeStates.RUNNING) self.assertEqual(node1.getState(), NodeStates.RUNNING)
......
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