Commit bf255041 authored by Julien Muchembled's avatar Julien Muchembled

tests: fix possible freezes when threaded unit test ends

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2822 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 0bed5cd0
...@@ -24,6 +24,7 @@ import tempfile ...@@ -24,6 +24,7 @@ import tempfile
import unittest import unittest
import MySQLdb import MySQLdb
import neo import neo
import transaction
from mock import Mock from mock import Mock
from neo.lib import debug, logger, protocol, setupLog from neo.lib import debug, logger, protocol, setupLog
...@@ -122,6 +123,10 @@ class NeoTestBase(unittest.TestCase): ...@@ -122,6 +123,10 @@ class NeoTestBase(unittest.TestCase):
setupLog(test_method, log_file, True) setupLog(test_method, log_file, True)
def tearDown(self): def tearDown(self):
# Kill all unfinished transactions for next test.
# Note we don't even abort them because it may require a valid
# connection to a master node (see Storage.sync()).
transaction.manager.__init__()
unittest.TestCase.tearDown(self) unittest.TestCase.tearDown(self)
sys.stdout.write('\n') sys.stdout.write('\n')
sys.stdout.flush() sys.stdout.flush()
......
...@@ -30,7 +30,6 @@ import tempfile ...@@ -30,7 +30,6 @@ import tempfile
import traceback import traceback
import threading import threading
import psutil import psutil
import transaction
import neo.scripts import neo.scripts
from neo.neoctl.neoctl import NeoCTL, NotReadyException from neo.neoctl.neoctl import NeoCTL, NotReadyException
...@@ -614,13 +613,6 @@ class NEOCluster(object): ...@@ -614,13 +613,6 @@ class NEOCluster(object):
class NEOFunctionalTest(NeoTestBase): class NEOFunctionalTest(NeoTestBase):
def tearDown(self):
# Kill all unfinished transactions for next test.
# Note we don't even abort them because it may require a valid
# connection to a master node (see Storage.sync()).
transaction.manager.__init__()
NeoTestBase.tearDown(self)
def setupLog(self): def setupLog(self):
log_file = os.path.join(self.getTempDirectory(), 'test.log') log_file = os.path.join(self.getTempDirectory(), 'test.log')
setupLog('TEST', log_file, True) setupLog('TEST', log_file, True)
......
...@@ -32,7 +32,7 @@ from neo.lib.connector import SocketConnector, \ ...@@ -32,7 +32,7 @@ from neo.lib.connector import SocketConnector, \
from neo.lib.event import EventManager from neo.lib.event import EventManager
from neo.lib.protocol import CellStates, ClusterStates, NodeStates, NodeTypes from neo.lib.protocol import CellStates, ClusterStates, NodeStates, NodeTypes
from neo.lib.util import SOCKET_CONNECTORS_DICT, parseMasterList from neo.lib.util import SOCKET_CONNECTORS_DICT, parseMasterList
from neo.tests import NeoUnitTestBase, getTempDirectory, setupMySQLdb, \ from neo.tests import NeoTestBase, getTempDirectory, setupMySQLdb, \
ADDRESS_TYPE, IP_VERSION_FORMAT_DICT, DB_PREFIX, DB_USER ADDRESS_TYPE, IP_VERSION_FORMAT_DICT, DB_PREFIX, DB_USER
BIND = IP_VERSION_FORMAT_DICT[ADDRESS_TYPE], 0 BIND = IP_VERSION_FORMAT_DICT[ADDRESS_TYPE], 0
...@@ -327,7 +327,8 @@ class NEOCluster(object): ...@@ -327,7 +327,8 @@ class NEOCluster(object):
self.remote_addr = addr self.remote_addr = addr
def send(self, msg): def send(self, msg):
result = cls.SocketConnector_send(self, msg) result = cls.SocketConnector_send(self, msg)
Serialized.pending = 1 if Serialized.pending is not None:
Serialized.pending = 1
return result return result
# TODO: 'sleep' should 'tic' in a smart way, so that storages can be # TODO: 'sleep' should 'tic' in a smart way, so that storages can be
# safely started even if the cluster isn't. # safely started even if the cluster isn't.
...@@ -493,7 +494,7 @@ class NEOCluster(object): ...@@ -493,7 +494,7 @@ class NEOCluster(object):
return txn, self.db.open(transaction_manager=txn) return txn, self.db.open(transaction_manager=txn)
class NEOThreadedTest(NeoUnitTestBase): class NEOThreadedTest(NeoTestBase):
def setupLog(self): def setupLog(self):
log_file = os.path.join(getTempDirectory(), self.id() + '.log') log_file = os.path.join(getTempDirectory(), self.id() + '.log')
......
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