Commit 0e0e240f authored by Jérome Perrin's avatar Jérome Perrin

testERP5TestNode: make tests properly isolated

Some tests where patching SlapOSControler to replace methods by a no-op,
but this was never reset. I believe we should rewrite this using mock
which takes care of un-doing the patches for us and makes this testing
easier, but for now I'm just reseting the missing methods like all
others were already reseted.
parent 4b752bdb
...@@ -624,6 +624,10 @@ shared = true ...@@ -624,6 +624,10 @@ shared = true
"kw": kw}) "kw": kw})
return {"status_code": self.status_code} return {"status_code": self.status_code}
original_SlapOSControler_initializeSlapOSControler = SlapOSControler.initializeSlapOSControler
original_SlapOSControler_runSoftwareRelease = SlapOSControler.runSoftwareRelease
original_SlapOSControler_runComputerPartition = SlapOSControler.runComputerPartition
try:
SlapOSControler.initializeSlapOSControler = Patch("initializeSlapOSControler") SlapOSControler.initializeSlapOSControler = Patch("initializeSlapOSControler")
SlapOSControler.runSoftwareRelease = Patch("runSoftwareRelease") SlapOSControler.runSoftwareRelease = Patch("runSoftwareRelease")
SlapOSControler.runComputerPartition = Patch("runComputerPartition") SlapOSControler.runComputerPartition = Patch("runComputerPartition")
...@@ -643,6 +647,10 @@ shared = true ...@@ -643,6 +647,10 @@ shared = true
# TODO : write a test for scalability case # TODO : write a test for scalability case
self.assertRaises(SubprocessError, runner.prepareSlapOSForTestSuite, self.assertRaises(SubprocessError, runner.prepareSlapOSForTestSuite,
node_test_suite) node_test_suite)
finally:
SlapOSControler.initializeSlapOSControler = original_SlapOSControler_initializeSlapOSControler
SlapOSControler.runSoftwareRelease = original_SlapOSControler_runSoftwareRelease
SlapOSControler.runComputerPartition = original_SlapOSControler_runComputerPartition
def test_11_run(self, my_test_type='UnitTest', grade='master'): def test_11_run(self, my_test_type='UnitTest', grade='master'):
def doNothing(self, *args, **kw): def doNothing(self, *args, **kw):
...@@ -738,6 +746,8 @@ shared = true ...@@ -738,6 +746,8 @@ shared = true
RunnerClass._updateInstanceXML = doNothing RunnerClass._updateInstanceXML = doNothing
SlapOSMasterCommunicator.__init__ = doNothing SlapOSMasterCommunicator.__init__ = doNothing
original_generateConfiguration = TaskDistributor.generateConfiguration original_generateConfiguration = TaskDistributor.generateConfiguration
original_initializeSlapOSControler = SlapOSControler.initializeSlapOSControler
TaskDistributor.generateConfiguration = patch_generateConfiguration TaskDistributor.generateConfiguration = patch_generateConfiguration
original_startTestSuite = TaskDistributor.startTestSuite original_startTestSuite = TaskDistributor.startTestSuite
original_subscribeNode = TaskDistributor.subscribeNode original_subscribeNode = TaskDistributor.subscribeNode
...@@ -778,6 +788,7 @@ shared = true ...@@ -778,6 +788,7 @@ shared = true
TaskDistributor.getTestType = original_getTestType TaskDistributor.getTestType = original_getTestType
RunnerClass._prepareSlapOS = original_prepareSlapOS RunnerClass._prepareSlapOS = original_prepareSlapOS
RunnerClass.runTestSuite = original_runTestSuite RunnerClass.runTestSuite = original_runTestSuite
SlapOSControler.initializeSlapOSControler = original_initializeSlapOSControler
def test_12_spawn(self): def test_12_spawn(self):
def _checkCorrectStatus(expected_status,*args): def _checkCorrectStatus(expected_status,*args):
...@@ -911,8 +922,8 @@ shared = true ...@@ -911,8 +922,8 @@ shared = true
del test_node.suiteLog del test_node.suiteLog
# Change UnitTestRunner class methods # Change UnitTestRunner class methods
original_prepareSlapOS = RunnerClass._prepareSlapOS original_prepareSlapOS = RunnerClass._prepareSlapOS
original_runTestSuite = RunnerClass.runTestSuite original_runTestSuite = RunnerClass.runTestSuite
original_initializeSlapOSControler = SlapOSControler.initializeSlapOSControler
if my_test_type == "ScalabilityTest": if my_test_type == "ScalabilityTest":
RunnerClass.runTestSuite = patch_runTestSuite RunnerClass.runTestSuite = patch_runTestSuite
...@@ -945,6 +956,7 @@ shared = true ...@@ -945,6 +956,7 @@ shared = true
TaskDistributor.getTestType = original_getTestType TaskDistributor.getTestType = original_getTestType
RunnerClass._prepareSlapOS = original_prepareSlapOS RunnerClass._prepareSlapOS = original_prepareSlapOS
RunnerClass.runTestSuite = original_runTestSuite RunnerClass.runTestSuite = original_runTestSuite
SlapOSControler.initializeSlapOSControler = original_initializeSlapOSControler
def test_16_cleanupLogDirectory(self): def test_16_cleanupLogDirectory(self):
# Make sure that we are able to cleanup old log folders # Make sure that we are able to cleanup old log folders
......
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