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

Update tests for recovery manager.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1593 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent e6193579
...@@ -20,7 +20,7 @@ from struct import pack, unpack ...@@ -20,7 +20,7 @@ from struct import pack, unpack
from neo.tests import NeoTestBase from neo.tests import NeoTestBase
from neo.protocol import Packets from neo.protocol import Packets
from neo.protocol import NodeTypes, NodeStates, CellStates from neo.protocol import NodeTypes, NodeStates, CellStates
from neo.master.handlers.recovery import RecoveryHandler from neo.master.recovery import RecoveryManager
from neo.master.app import Application from neo.master.app import Application
class MasterRecoveryTests(NeoTestBase): class MasterRecoveryTests(NeoTestBase):
...@@ -30,7 +30,7 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -30,7 +30,7 @@ class MasterRecoveryTests(NeoTestBase):
config = self.getMasterConfiguration() config = self.getMasterConfiguration()
self.app = Application(config) self.app = Application(config)
self.app.pt.clear() self.app.pt.clear()
self.recovery = RecoveryHandler(self.app) self.recovery = RecoveryManager(self.app)
self.app.unconnected_master_node_set = set() self.app.unconnected_master_node_set = set()
self.app.negotiating_master_node_set = set() self.app.negotiating_master_node_set = set()
for node in self.app.nm.getMasterList(): for node in self.app.nm.getMasterList():
...@@ -111,12 +111,10 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -111,12 +111,10 @@ class MasterRecoveryTests(NeoTestBase):
self.assertTrue(new_ptid > self.app.pt.getID()) self.assertTrue(new_ptid > self.app.pt.getID())
self.assertTrue(new_oid > self.app.loid) self.assertTrue(new_oid > self.app.loid)
self.assertTrue(new_tid > self.app.tm.getLastTID()) self.assertTrue(new_tid > self.app.tm.getLastTID())
self.assertEquals(self.app.target_uuid, None)
recovery.answerLastIDs(conn, new_oid, new_tid, new_ptid) recovery.answerLastIDs(conn, new_oid, new_tid, new_ptid)
self.assertEquals(new_oid, self.app.loid) self.assertEquals(new_oid, self.app.loid)
self.assertEquals(new_tid, self.app.tm.getLastTID()) self.assertEquals(new_tid, self.app.tm.getLastTID())
self.assertEquals(new_ptid, self.app.pt.getID()) self.assertEquals(new_ptid, self.app.pt.getID())
self.assertEquals(self.app.target_uuid,uuid)
def test_10_answerPartitionTable(self): def test_10_answerPartitionTable(self):
...@@ -125,7 +123,6 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -125,7 +123,6 @@ class MasterRecoveryTests(NeoTestBase):
# not from target node, ignore # not from target node, ignore
uuid = self.identifyToMasterNode(NodeTypes.STORAGE, port=self.storage_port) uuid = self.identifyToMasterNode(NodeTypes.STORAGE, port=self.storage_port)
conn = self.getFakeConnection(uuid, self.storage_port) conn = self.getFakeConnection(uuid, self.storage_port)
self.assertNotEquals(self.app.target_uuid, uuid)
offset = 1 offset = 1
cell_list = [(offset, uuid, CellStates.UP_TO_DATE)] cell_list = [(offset, uuid, CellStates.UP_TO_DATE)]
cells = self.app.pt.getRow(offset) cells = self.app.pt.getRow(offset)
...@@ -137,9 +134,6 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -137,9 +134,6 @@ class MasterRecoveryTests(NeoTestBase):
self.assertEquals(state, CellStates.OUT_OF_DATE) self.assertEquals(state, CellStates.OUT_OF_DATE)
# from target node, taken into account # from target node, taken into account
conn = self.getFakeConnection(uuid, self.storage_port) conn = self.getFakeConnection(uuid, self.storage_port)
self.assertNotEquals(self.app.target_uuid, uuid)
self.app.target_uuid = uuid
self.assertEquals(self.app.target_uuid, uuid)
offset = 1 offset = 1
cell_list = [(offset, ((uuid, CellStates.UP_TO_DATE,),),)] cell_list = [(offset, ((uuid, CellStates.UP_TO_DATE,),),)]
cells = self.app.pt.getRow(offset) cells = self.app.pt.getRow(offset)
...@@ -150,8 +144,8 @@ class MasterRecoveryTests(NeoTestBase): ...@@ -150,8 +144,8 @@ class MasterRecoveryTests(NeoTestBase):
for cell, state in cells: for cell, state in cells:
self.assertEquals(state, CellStates.UP_TO_DATE) self.assertEquals(state, CellStates.UP_TO_DATE)
# give a bad offset, must send error # give a bad offset, must send error
self.recovery.target_uuid = uuid
conn = self.getFakeConnection(uuid, self.storage_port) conn = self.getFakeConnection(uuid, self.storage_port)
self.assertEquals(self.app.target_uuid, uuid)
offset = 1000000 offset = 1000000
self.assertFalse(self.app.pt.hasOffset(offset)) self.assertFalse(self.app.pt.hasOffset(offset))
cell_list = [(offset, ((uuid, NodeStates.DOWN,),),)] cell_list = [(offset, ((uuid, NodeStates.DOWN,),),)]
......
...@@ -40,7 +40,7 @@ UNIT_TEST_MODULES = [ ...@@ -40,7 +40,7 @@ UNIT_TEST_MODULES = [
'neo.tests.master.testElectionHandler', 'neo.tests.master.testElectionHandler',
'neo.tests.master.testMasterApp', 'neo.tests.master.testMasterApp',
'neo.tests.master.testMasterPT', 'neo.tests.master.testMasterPT',
'neo.tests.master.testRecoveryHandler', 'neo.tests.master.testRecovery',
'neo.tests.master.testStorageHandler', 'neo.tests.master.testStorageHandler',
'neo.tests.master.testVerification', 'neo.tests.master.testVerification',
'neo.tests.master.testTransactions', 'neo.tests.master.testTransactions',
......
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