Commit fe3fd5c3 authored by Julien Muchembled's avatar Julien Muchembled

Allow ZODB tests to be run either in functional mode or in threaded mode

Threaded mode is the fastest so it's the default for neotestrunner.
Speed is not so important for the test bot, so it keeps running them in
functional mode by default.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2824 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 2ed8fb0b
...@@ -16,36 +16,40 @@ ...@@ -16,36 +16,40 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import os import os
import unittest
from neo.tests.functional import NEOCluster, NEOFunctionalTest from neo.tests import DB_PREFIX
import neo.lib functional = int(os.getenv('NEO_TEST_ZODB_FUNCTIONAL', 0))
if functional:
from neo.tests.functional import NEOCluster, NEOFunctionalTest as TestCase
else:
from neo.tests.threaded import NEOCluster, NEOThreadedTest as TestCase
class ZODBTestCase(NEOFunctionalTest): class ZODBTestCase(TestCase):
def setUp(self, cluster_kw={}): def setUp(self, cluster_kw={}):
NEOFunctionalTest.setUp(self) super(ZODBTestCase, self).setUp()
masters = int(os.environ.get('NEO_TEST_ZODB_MASTERS', 1)) storages = int(os.getenv('NEO_TEST_ZODB_STORAGES', 1))
storages = int(os.environ.get('NEO_TEST_ZODB_STORAGES', 1)) kw = {
replicas = int(os.environ.get('NEO_TEST_ZODB_REPLICAS', 0)) 'master_count': int(os.getenv('NEO_TEST_ZODB_MASTERS', 1)),
partitions = int(os.environ.get('NEO_TEST_ZODB_PARTITIONS', 1)) 'replicas': int(os.getenv('NEO_TEST_ZODB_REPLICAS', 0)),
self.neo = NEOCluster( 'partitions': int(os.getenv('NEO_TEST_ZODB_PARTITIONS', 1)),
db_list=['test_neo%d' % x for x in xrange(storages)], 'db_list': ['%s%u' % (DB_PREFIX, i) for i in xrange(storages)],
partitions=partitions, }
replicas=replicas, kw.update(cluster_kw)
master_count=masters, if functional:
temp_dir=self.getTempDirectory(), kw['temp_dir'] = self.getTempDirectory()
**cluster_kw) self.neo = NEOCluster(**kw)
self.neo.start() self.neo.start()
self._storage = self.neo.getZODBStorage() self._storage = self.neo.getZODBStorage()
def tearDown(self): def tearDown(self):
self._storage.cleanup() self._storage.cleanup()
self.neo.stop() self.neo.stop()
NEOFunctionalTest.tearDown(self) del self.neo, self._storage
super(ZODBTestCase, self).tearDown()
assertEquals = failUnlessEqual = NEOFunctionalTest.assertEqual assertEquals = failUnlessEqual = TestCase.assertEqual
assertNotEquals = failIfEqual = NEOFunctionalTest.assertNotEqual assertNotEquals = failIfEqual = TestCase.assertNotEqual
def open(self, read_only=False): def open(self, read_only=False):
# required for some tests (see PersitentTests), no-op for NEO ? # required for some tests (see PersitentTests), no-op for NEO ?
......
...@@ -12,6 +12,7 @@ def clean(): ...@@ -12,6 +12,7 @@ def clean():
def main(): def main():
if 'LANG' in os.environ: if 'LANG' in os.environ:
del os.environ['LANG'] del os.environ['LANG']
os.environ.setdefault('NEO_TEST_ZODB_FUNCTIONAL', '1')
arg_count = 1 arg_count = 1
while arg_count < len(sys.argv): while arg_count < len(sys.argv):
......
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