Commit bb69f48b authored by Julien Muchembled's avatar Julien Muchembled

Fix storage exiting with non-zero status in testDropNodeThenRestartCluster

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2736 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 15308c68
......@@ -368,4 +368,5 @@ class Application(object):
pass
# clear database to avoid polluting the cluster at restart
self.dm.setup(reset=erase)
sys.exit("Application has been asked to shut down")
neo.lib.logging.info("Application has been asked to shut down")
sys.exit()
......@@ -103,6 +103,33 @@ class PortAllocator(object):
__del__ = reset
class ChildException(KeyboardInterrupt):
"""Wrap any exception into an exception that is not catched by TestCase.run
The exception is not wrapped and re-raised immediately if there is no need
to wrap.
"""
def __init__(self, type, value, tb):
code = unittest.TestCase.run.im_func.func_code
f = tb.tb_frame
while f is not None:
if f.f_code is code:
break
f = f.f_back
else:
raise type, value, tb
super(ChildException, self).__init__(type, value, tb)
def __call__(self):
"""Re-raise wrapped exception"""
type, value, tb = self.args
if type is KeyboardInterrupt:
sys.exit(1)
raise type, value, tb
class NEOProcess(object):
pid = 0
......@@ -137,14 +164,8 @@ class NEOProcess(object):
try:
sys.argv = [command] + args
getattr(neo.scripts, command).main()
except (SystemExit, KeyboardInterrupt):
self._exit()
except:
print traceback.format_exc()
# If we reach this line, exec call failed (is it possible to reach
# it without going through above "except" branch ?).
print 'Error executing %r.' % (command + ' ' + ' '.join(args), )
self._exit(-1)
raise ChildException(*sys.exc_info())
def _exit(self, status=0):
sys.stdout = sys.stderr = open('/dev/null', 'w')
......@@ -622,6 +643,12 @@ class NEOFunctionalTest(NeoTestBase):
os.makedirs(temp_dir)
return temp_dir
def run(self, *args, **kw):
try:
return super(NEOFunctionalTest, self).run(*args, **kw)
except ChildException, e:
e()
def runWithTimeout(self, timeout, method, args=(), kwargs=None):
if kwargs is None:
kwargs = {}
......
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