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
import unittest
import MySQLdb
import neo
import transaction
from mock import Mock
from neo.lib import debug, logger, protocol, setupLog
......@@ -122,6 +123,10 @@ class NeoTestBase(unittest.TestCase):
setupLog(test_method, log_file, True)
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)
sys.stdout.write('\n')
sys.stdout.flush()
......
......@@ -30,7 +30,6 @@ import tempfile
import traceback
import threading
import psutil
import transaction
import neo.scripts
from neo.neoctl.neoctl import NeoCTL, NotReadyException
......@@ -614,13 +613,6 @@ class NEOCluster(object):
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):
log_file = os.path.join(self.getTempDirectory(), 'test.log')
setupLog('TEST', log_file, True)
......
......@@ -32,7 +32,7 @@ from neo.lib.connector import SocketConnector, \
from neo.lib.event import EventManager
from neo.lib.protocol import CellStates, ClusterStates, NodeStates, NodeTypes
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
BIND = IP_VERSION_FORMAT_DICT[ADDRESS_TYPE], 0
......@@ -327,6 +327,7 @@ class NEOCluster(object):
self.remote_addr = addr
def send(self, msg):
result = cls.SocketConnector_send(self, msg)
if Serialized.pending is not None:
Serialized.pending = 1
return result
# TODO: 'sleep' should 'tic' in a smart way, so that storages can be
......@@ -493,7 +494,7 @@ class NEOCluster(object):
return txn, self.db.open(transaction_manager=txn)
class NEOThreadedTest(NeoUnitTestBase):
class NEOThreadedTest(NeoTestBase):
def setupLog(self):
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