Commit a5f2f604 authored by Julien Muchembled's avatar Julien Muchembled

tests: review report and mark known failures as expected

parent d250deca
This diff is collapsed.
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
import __builtin__ import __builtin__
import errno import errno
import functools
import os import os
import random import random
import socket import socket
...@@ -31,11 +32,28 @@ from neo.lib.protocol import NodeTypes, Packets, UUID_NAMESPACES ...@@ -31,11 +32,28 @@ from neo.lib.protocol import NodeTypes, Packets, UUID_NAMESPACES
from neo.lib.util import getAddressType from neo.lib.util import getAddressType
from time import time from time import time
from struct import pack, unpack from struct import pack, unpack
from unittest.case import _ExpectedFailure, _UnexpectedSuccess
try: try:
from ZODB.utils import newTid from ZODB.utils import newTid
except ImportError: except ImportError:
pass pass
def expectedFailure(exception=AssertionError):
def decorator(func):
def wrapper(*args, **kw):
try:
func(*args, **kw)
except exception, e:
# XXX: passing sys.exc_info() causes deadlocks
raise _ExpectedFailure((type(e), None, None))
raise _UnexpectedSuccess
return functools.wraps(func)(wrapper)
if callable(exception) and not isinstance(exception, type):
func = exception
exception = Exception
return decorator(func)
return decorator
DB_PREFIX = os.getenv('NEO_DB_PREFIX', 'test_neo') DB_PREFIX = os.getenv('NEO_DB_PREFIX', 'test_neo')
DB_ADMIN = os.getenv('NEO_DB_ADMIN', 'root') DB_ADMIN = os.getenv('NEO_DB_ADMIN', 'root')
DB_PASSWD = os.getenv('NEO_DB_PASSWD', '') DB_PASSWD = os.getenv('NEO_DB_PASSWD', '')
...@@ -117,8 +135,6 @@ def setupMySQLdb(db_list, user=DB_USER, password='', clear_databases=True): ...@@ -117,8 +135,6 @@ def setupMySQLdb(db_list, user=DB_USER, password='', clear_databases=True):
class NeoTestBase(unittest.TestCase): class NeoTestBase(unittest.TestCase):
def setUp(self): def setUp(self):
sys.stdout.write(' * %s ' % (self.id(), ))
sys.stdout.flush()
logging.name = self.setupLog() logging.name = self.setupLog()
unittest.TestCase.setUp(self) unittest.TestCase.setUp(self)
...@@ -126,17 +142,15 @@ class NeoTestBase(unittest.TestCase): ...@@ -126,17 +142,15 @@ class NeoTestBase(unittest.TestCase):
test_case, logging.name = self.id().rsplit('.', 1) test_case, logging.name = self.id().rsplit('.', 1)
logging.setup(os.path.join(getTempDirectory(), test_case + '.log')) logging.setup(os.path.join(getTempDirectory(), test_case + '.log'))
def tearDown(self, def tearDown(self):
success='ok' if sys.version_info < (2, 7) else 'success'):
assert self.tearDown.im_func is NeoTestBase.tearDown.im_func assert self.tearDown.im_func is NeoTestBase.tearDown.im_func
self._tearDown(sys._getframe(1).f_locals[success]) self._tearDown(sys._getframe(1).f_locals['success'])
def _tearDown(self, success): def _tearDown(self, success):
# Kill all unfinished transactions for next test. # Kill all unfinished transactions for next test.
# Note we don't even abort them because it may require a valid # Note we don't even abort them because it may require a valid
# connection to a master node (see Storage.sync()). # connection to a master node (see Storage.sync()).
transaction.manager.__init__() transaction.manager.__init__()
print
class failureException(AssertionError): class failureException(AssertionError):
def __init__(self, msg=None): def __init__(self, msg=None):
......
...@@ -26,6 +26,7 @@ from ZODB.FileStorage import FileStorage ...@@ -26,6 +26,7 @@ from ZODB.FileStorage import FileStorage
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from ZODB.tests.StorageTestBase import zodb_pickle from ZODB.tests.StorageTestBase import zodb_pickle
from persistent import Persistent from persistent import Persistent
from .. import expectedFailure
from . import NEOCluster, NEOFunctionalTest from . import NEOCluster, NEOFunctionalTest
TREE_SIZE = 6 TREE_SIZE = 6
...@@ -220,6 +221,7 @@ class ClientTests(NEOFunctionalTest): ...@@ -220,6 +221,7 @@ class ClientTests(NEOFunctionalTest):
self.__checkTree(root['trees']) self.__checkTree(root['trees'])
@expectedFailure(AttributeError)
def testExportFileStorageBug(self): def testExportFileStorageBug(self):
# currently fails due to a bug in ZODB.FileStorage # currently fails due to a bug in ZODB.FileStorage
self.testExport(True) self.testExport(True)
......
...@@ -26,6 +26,7 @@ from neo.storage.transactions import TransactionManager, \ ...@@ -26,6 +26,7 @@ from neo.storage.transactions import TransactionManager, \
from neo.lib.connection import ConnectionClosed, MTClientConnection from neo.lib.connection import ConnectionClosed, MTClientConnection
from neo.lib.protocol import CellStates, ClusterStates, NodeStates, Packets, \ from neo.lib.protocol import CellStates, ClusterStates, NodeStates, Packets, \
ZERO_TID ZERO_TID
from .. import expectedFailure, _UnexpectedSuccess
from . import ClientApplication, NEOCluster, NEOThreadedTest, Patch from . import ClientApplication, NEOCluster, NEOThreadedTest, Patch
from neo.lib.util import add64, makeChecksum from neo.lib.util import add64, makeChecksum
from neo.client.pool import CELL_CONNECTED, CELL_GOOD from neo.client.pool import CELL_CONNECTED, CELL_GOOD
...@@ -237,6 +238,7 @@ class Test(NEOThreadedTest): ...@@ -237,6 +238,7 @@ class Test(NEOThreadedTest):
self.assertEqual(self._testDeadlockAvoidance([2, 4]), self.assertEqual(self._testDeadlockAvoidance([2, 4]),
[DelayedError, DelayedError, ConflictError, ConflictError]) [DelayedError, DelayedError, ConflictError, ConflictError])
@expectedFailure(POSException.ConflictError)
def testDeadlockAvoidance(self): def testDeadlockAvoidance(self):
# This test fail because deadlock avoidance is not fully implemented. # This test fail because deadlock avoidance is not fully implemented.
# 0: C1 -> S1 # 0: C1 -> S1
...@@ -717,9 +719,13 @@ class Test(NEOThreadedTest): ...@@ -717,9 +719,13 @@ class Test(NEOThreadedTest):
# XXX: This is an expected failure. A ttid column was added to # XXX: This is an expected failure. A ttid column was added to
# 'trans' table to permit recovery, by checking that the # 'trans' table to permit recovery, by checking that the
# transaction was really committed. # transaction was really committed.
self.assertRaises(ConnectionClosed, t.commit) try:
t.commit()
raise _UnexpectedSuccess
except ConnectionClosed:
pass
t.begin() t.begin()
c.root()['x'] expectedFailure(self.assertIn)('x', c.root())
finally: finally:
cluster.stop() cluster.stop()
......
...@@ -16,14 +16,11 @@ ...@@ -16,14 +16,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest import unittest
try: from ZODB.tests.PackableStorage import \
from ZODB.tests.PackableStorage import PackableStorageWithOptionalGC PackableStorageWithOptionalGC, PackableUndoStorage
except ImportError:
from ZODB.tests.PackableStorage import PackableStorage as \
PackableStorageWithOptionalGC
from ZODB.tests.PackableStorage import PackableUndoStorage
from ZODB.tests.StorageTestBase import StorageTestBase from ZODB.tests.StorageTestBase import StorageTestBase
from .. import expectedFailure
from . import ZODBTestCase from . import ZODBTestCase
class PackableTests(ZODBTestCase, StorageTestBase, class PackableTests(ZODBTestCase, StorageTestBase,
...@@ -32,6 +29,10 @@ class PackableTests(ZODBTestCase, StorageTestBase, ...@@ -32,6 +29,10 @@ class PackableTests(ZODBTestCase, StorageTestBase,
def setUp(self): def setUp(self):
super(PackableTests, self).setUp(cluster_kw={'adapter': 'MySQL'}) super(PackableTests, self).setUp(cluster_kw={'adapter': 'MySQL'})
checkPackAllRevisions = expectedFailure()(
PackableStorageWithOptionalGC.checkPackAllRevisions)
checkPackUndoLog = expectedFailure()(PackableUndoStorage.checkPackUndoLog)
if __name__ == "__main__": if __name__ == "__main__":
suite = unittest.makeSuite(PackableTests, 'check') suite = unittest.makeSuite(PackableTests, 'check')
unittest.main(defaultTest='suite') unittest.main(defaultTest='suite')
......
...@@ -19,11 +19,14 @@ from ZODB.tests.StorageTestBase import StorageTestBase ...@@ -19,11 +19,14 @@ from ZODB.tests.StorageTestBase import StorageTestBase
from ZODB.tests.TransactionalUndoStorage import TransactionalUndoStorage from ZODB.tests.TransactionalUndoStorage import TransactionalUndoStorage
from ZODB.tests.ConflictResolution import ConflictResolvingTransUndoStorage from ZODB.tests.ConflictResolution import ConflictResolvingTransUndoStorage
from .. import expectedFailure
from . import ZODBTestCase from . import ZODBTestCase
class UndoTests(ZODBTestCase, StorageTestBase, TransactionalUndoStorage, class UndoTests(ZODBTestCase, StorageTestBase, TransactionalUndoStorage,
ConflictResolvingTransUndoStorage): ConflictResolvingTransUndoStorage):
pass
checkTransactionalUndoAfterPack = expectedFailure()(
TransactionalUndoStorage.checkTransactionalUndoAfterPack)
# Don't run this test. It cannot run with pipelined store, and is not executed # Don't run this test. It cannot run with pipelined store, and is not executed
# on Zeo - but because Zeo doesn't have an iterator, while Neo has. # on Zeo - but because Zeo doesn't have an iterator, while Neo has.
......
...@@ -85,7 +85,7 @@ def main(): ...@@ -85,7 +85,7 @@ def main():
revision[:7], os.path.basename(test_home), backend) revision[:7], os.path.basename(test_home), backend)
if tests: if tests:
subprocess.call([os.path.join(bin, 'neotestrunner'), subprocess.call([os.path.join(bin, 'neotestrunner'),
'-' + tests, '--title', 'NEO tests ' + title, '-v' + tests, '--title', 'NEO tests ' + title,
] + sys.argv[1:arg_count]) ] + sys.argv[1:arg_count])
if 'm' in tasks: if 'm' in tasks:
subprocess.call([os.path.join(bin, 'python'), subprocess.call([os.path.join(bin, 'python'),
......
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