diff --git a/erp5/tests/testERP5TestNode.py b/erp5/tests/testERP5TestNode.py index 3bbbbeab3073978845323ca5bac87d96d4495056..89c299e0a2b88f37576a3ea9210cce771cc8981c 100644 --- a/erp5/tests/testERP5TestNode.py +++ b/erp5/tests/testERP5TestNode.py @@ -606,4 +606,41 @@ branch = foo # then we set keep time to 0, folder will be deleted test_node.max_temp_time = 0 test_node._cleanupTemporaryFiles() - check(set(['something'])) \ No newline at end of file + check(set(['something'])) + + def test_18_resetSoftwareAfterManyBuildFailures(self): + """ + Check that after several building failures that the software is resetted + """ + initial_initializeSlapOSControler = \ + SlapOSControler.initializeSlapOSControler + initial_runSoftwareRelease = SlapOSControler.runSoftwareRelease + test_node = self.getTestNode() + node_test_suite = test_node.getNodeTestSuite('foo') + init_call_kw_list = [] + def initializeSlapOSControler(self, **kw): + init_call_kw_list.append(kw) + def runSoftwareRelease(self, *args, **kw): + return {"status_code": 1} + SlapOSControler.initializeSlapOSControler = initializeSlapOSControler + SlapOSControler.runSoftwareRelease = runSoftwareRelease + def callPrepareSlapOS(): + test_node._prepareSlapOS(self.working_directory, node_test_suite, + test_node.log, create_partition=0) + def callRaisingPrepareSlapos(): + self.assertRaises(SubprocessError, callPrepareSlapOS) + self.assertEquals(node_test_suite.retry_software_count, 0) + for x in xrange(0,11): + callRaisingPrepareSlapos() + self.assertEquals(len(init_call_kw_list), 11) + self.assertEquals(init_call_kw_list[-1]['reset_software'], False) + self.assertEquals(node_test_suite.retry_software_count, 11) + callRaisingPrepareSlapos() + self.assertEquals(init_call_kw_list[-1]['reset_software'], True) + self.assertEquals(node_test_suite.retry_software_count, 1) + callRaisingPrepareSlapos() + self.assertEquals(init_call_kw_list[-1]['reset_software'], False) + self.assertEquals(node_test_suite.retry_software_count, 2) + SlapOSControler.initializeSlapOSControler = \ + initial_initializeSlapOSControler + SlapOSControler.runSoftwareRelease = initial_runSoftwareRelease diff --git a/erp5/util/testnode/testnode.py b/erp5/util/testnode/testnode.py index 6f6c131f44f2070dffefaf862244e4b2ba5a40b8..289af7d881027d6860326f8bf5b46f78b0309059 100644 --- a/erp5/util/testnode/testnode.py +++ b/erp5/util/testnode/testnode.py @@ -149,6 +149,7 @@ class TestNode(object): for y in to_remove_reference_set: fpath = os.path.join(config['working_directory'],y) self.delNodeTestSuite(y) + self.log("testnode.checkOldTestSuite, DELETING : %r" % (fpath,)) if os.path.isdir(fpath): shutil.rmtree(fpath) else: @@ -290,6 +291,8 @@ branch = %(branch)s 'slapproxy.log') log('Configured slapproxy log to %r' % slapproxy_log) reset_software = slapos_instance.retry_software_count > 10 + if reset_software: + slapos_instance.retry_software_count = 0 log('testnode, retry_software_count : %r' % \ slapos_instance.retry_software_count) self.slapos_controler = SlapOSControler.SlapOSControler(