Commit 5bb2b846 authored by Sebastien Robin's avatar Sebastien Robin

runUnitTest: fixed weird "Duplicate tpc_begin calls for same transaction"

While launching an new portal component test, a "Duplicate tpc_begin
calls for same transaction" error was raised. This was coming from
the finally clause in runUnitTestList, in the commit of
ProcessingNodeTestCase.unregisterNode.

After long investigations, we found out that a new app was created
while the transaction was still opened. After more investigations,
it was discovered that the runUnitTestList code was raising an
exception, and this exception was hidden by the exception in the
finally close.

So this patch provides:
1 - a cancellation of the transaction to avoid "duplicate tpc_begin
    calls" error.
2 - a print of the exception before the finally clause is launched
    to make sure we have information on possible exceptions
parent 89eae304
...@@ -10,6 +10,7 @@ import signal ...@@ -10,6 +10,7 @@ import signal
import shutil import shutil
import errno import errno
import random import random
import transaction
from glob import glob from glob import glob
import backportUnittest import backportUnittest
...@@ -675,6 +676,14 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None): ...@@ -675,6 +676,14 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
root_logger.handlers.append(loghandler.StreamHandler(sys.stderr)) root_logger.handlers.append(loghandler.StreamHandler(sys.stderr))
_print('done (%.3fs)\n' % (time.time() - _start)) _print('done (%.3fs)\n' % (time.time() - _start))
result = TestRunner(verbosity=verbosity).run(suite) result = TestRunner(verbosity=verbosity).run(suite)
transaction.commit()
except:
import traceback
print "runUnitTestList Exception : %r" % (traceback.print_exc(),)
# finally does not expect opened transaction, even in the
# case of a Ctrl-C.
transaction.abort()
raise
finally: finally:
ProcessingNodeTestCase.unregisterNode() ProcessingNodeTestCase.unregisterNode()
Storage.close() Storage.close()
......
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