2023-01-12 00:17:21 |
Corey Bryant |
description |
============================== short test summary info =============================== [231/9704]
FAILED test/unit/common/test_db.py::TestGreenDBConnection::test_execute_when_locked - AssertionError: Timeout not raised by execute
FAILED test/unit/common/test_db.py::TestDatabaseBroker::test_get - AssertionError: DatabaseError not raised
FAILED test/unit/common/test_db.py::TestDatabaseBroker::test_lock - sqlite3.OperationalError: database is locked
====== 3 failed, 6566 passed, 1809 skipped, 17783 warnings in 586.14s (0:09:46) ======
================================ test session starts =================================
platform linux -- Python 3.11.1, pytest-7.2.0, pluggy-1.0.0 -- /home/corey/pkg/antelope/upstream/swift/.tox/py3/bin/python
cachedir: .tox/py3/.pytest_cache
rootdir: /home/corey/pkg/antelope/upstream/swift, configfile: tox.ini
plugins: cov-4.0.0, requests-mock-1.10.0
collected 8378 items / 8375 deselected / 3 selected
run-last-failure: rerun previous 3 failures
test/unit/common/test_db.py::TestGreenDBConnection::test_execute_when_locked FAILED [ 33%]
test/unit/common/test_db.py::TestDatabaseBroker::test_get FAILED [ 66%]
test/unit/common/test_db.py::TestDatabaseBroker::test_lock FAILED [100%]
====================================== FAILURES ======================================
___________________ TestGreenDBConnection.test_execute_when_locked ___________________
self = <test.unit.common.test_db.TestGreenDBConnection testMethod=test_execute_when_locked>
def test_execute_when_locked(self):
# This test is dependent on the code under test calling execute and
# commit as sqlite3.Cursor.execute in a subclass.
class InterceptCursor(sqlite3.Cursor):
pass
db_error = sqlite3.OperationalError('database is locked')
InterceptCursor.execute = MagicMock(side_effect=db_error)
with patch('sqlite3.Cursor', new=InterceptCursor):
conn = sqlite3.connect(':memory:', check_same_thread=False,
factory=GreenDBConnection, timeout=0.1)
> self.assertRaises(Timeout, conn.execute, 'select 1')
E AssertionError: Timeout not raised by execute
test/unit/common/test_db.py:160: AssertionError
____________________________ TestDatabaseBroker.test_get _____________________________
self = <test.unit.common.test_db.TestDatabaseBroker testMethod=test_get>
def test_get(self):
broker = DatabaseBroker(':memory:')
with self.assertRaises(DatabaseConnectionError) as raised, \
broker.get() as conn:
conn.execute('SELECT 1')
self.assertEqual(
str(raised.exception),
"DB connection error (:memory:, 0):\nDB doesn't exist")
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'))
with self.assertRaises(DatabaseConnectionError) as raised, \
broker.get() as conn:
conn.execute('SELECT 1')
self.assertEqual(
str(raised.exception),
"DB connection error (%s, 0):\nDB doesn't exist" % broker.db_file)
def stub(*args, **kwargs):
pass
broker._initialize = stub
broker.initialize(normalize_timestamp('1'))
with broker.get() as conn:
conn.execute('CREATE TABLE test (one TEXT)')
try:
with broker.get() as conn:
conn.execute('INSERT INTO test (one) VALUES ("1")')
raise Exception('test')
conn.commit()
except Exception:
pass
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'))
with broker.get() as conn:
self.assertEqual(
[r[0] for r in conn.execute('SELECT * FROM test')], [])
with broker.get() as conn:
conn.execute('INSERT INTO test (one) VALUES ("1")')
conn.commit()
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'))
with broker.get() as conn:
self.assertEqual(
[r[0] for r in conn.execute('SELECT * FROM test')], ['1'])
dbpath = os.path.join(self.testdir, 'dev', 'dbs', 'par', 'pre', 'db')
mkdirs(dbpath)
qpath = os.path.join(self.testdir, 'dev', 'quarantined', 'tests', 'db')
with patch('swift.common.db.renamer', lambda a, b,
fsync: b):
# Test malformed database
copy(os.path.join(os.path.dirname(__file__),
'malformed_example.db'),
os.path.join(dbpath, '1.db'))
broker = DatabaseBroker(os.path.join(dbpath, '1.db'))
broker.db_type = 'test'
> with self.assertRaises(sqlite3.DatabaseError) as raised, \
broker.get() as conn:
E AssertionError: DatabaseError not raised
test/unit/common/test_db.py:846: AssertionError
____________________________ TestDatabaseBroker.test_lock ____________________________
self = <test.unit.common.test_db.TestDatabaseBroker testMethod=test_lock>
def test_lock(self):
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'), timeout=.1)
with self.assertRaises(DatabaseConnectionError) as raised, \
broker.lock():
pass
self.assertEqual(
str(raised.exception),
"DB connection error (%s, 0):\nDB doesn't exist" % broker.db_file)
def stub(*args, **kwargs):
pass
broker._initialize = stub
broker.initialize(normalize_timestamp('1'))
with broker.lock():
pass
with broker.lock():
pass
with self.assertRaises(RuntimeError) as raised, broker.lock():
raise RuntimeError('boom!')
self.assertEqual(raised.exception.args[0], 'boom!')
broker2 = DatabaseBroker(os.path.join(self.testdir, '1.db'),
timeout=.1)
broker2._initialize = stub
with broker.lock():
# broker2 raises the timeout
with self.assertRaises(LockTimeout) as raised:
> with broker2.lock():
test/unit/common/test_db.py:928:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.11/contextlib.py:137: in __enter__
return next(self.gen)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@contextmanager
def lock(self):
"""Use with the "with" statement; locks a database."""
if not self.conn:
if self.db_file != ':memory:' and os.path.exists(self.db_file):
self.conn = get_db_connection(self.db_file, self.timeout,
self.logger)
else:
raise DatabaseConnectionError(self.db_file, "DB doesn't exist")
conn = self.conn
self.conn = None
orig_isolation_level = conn.isolation_level
conn.isolation_level = None
> conn.execute('BEGIN IMMEDIATE')
E sqlite3.OperationalError: database is locked
swift/common/db.py:581: OperationalError
================================== warnings summary ==================================
.tox/py3/lib/python3.11/site-packages/eventlet/support/greenlets.py:6
/home/corey/pkg/antelope/upstream/swift/.tox/py3/lib/python3.11/site-packages/eventlet/support/greenlets.py:6: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
preserves_excinfo = (distutils.version.LooseVersion(greenlet.__version__)
.tox/py3/lib/python3.11/site-packages/eventlet/support/greenlets.py:7
/home/corey/pkg/antelope/upstream/swift/.tox/py3/lib/python3.11/site-packages/eventlet/support/greenlets.py:7: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
>= distutils.version.LooseVersion('0.3.2'))
swift/common/middleware/crypto/crypto_utils.py:30
/home/corey/pkg/antelope/upstream/swift/swift/common/middleware/crypto/crypto_utils.py:30: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
from cgi import parse_header
test/unit/common/test_db_replicator.py:290
/home/corey/pkg/antelope/upstream/swift/test/unit/common/test_db_replicator.py:290: PytestCollectionWarning: cannot collect test class 'TestReplicator' because it has a __init__ constructor (from: test/unit/common/test_db_replicator.py)
class TestReplicator(db_replicator.Replicator):
test/unit/common/middleware/s3api/test_s3token.py:75
/home/corey/pkg/antelope/upstream/swift/test/unit/common/middleware/s3api/test_s3token.py:75: PytestCollectionWarning: cannot collect test class 'TestResponse' because it has a __init__ constructor (from: test/unit/common/middleware/s3api/test_s3token.py)
class TestResponse(requests.Response):
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
---------- coverage: platform linux, python 3.11.1-final-0 -----------
...
============================== short test summary info =============================== FAILED test/unit/common/test_db.py::TestGreenDBConnection::test_execute_when_locked - AssertionError: Timeout not raised by execute FAILED test/unit/common/test_db.py::TestDatabaseBroker::test_get - AssertionError: DatabaseError not raised
FAILED test/unit/common/test_db.py::TestDatabaseBroker::test_lock - sqlite3.OperationalError: database is locked
================== 3 failed, 8375 deselected, 5 warnings in 30.84s =================== ERROR: InvocationError for command /usr/bin/bash -ec 'pytest test/unit || pytest --last-failed test/unit' (exited with code 1) ______________________________________ summary _______________________________________ |
There are 3 test failures with python3.11:
============================== short test summary info =============================== [231/9704]
FAILED test/unit/common/test_db.py::TestGreenDBConnection::test_execute_when_locked - AssertionError: Timeout not raised by execute
FAILED test/unit/common/test_db.py::TestDatabaseBroker::test_get - AssertionError: DatabaseError not raised
FAILED test/unit/common/test_db.py::TestDatabaseBroker::test_lock - sqlite3.OperationalError: database is locked
====== 3 failed, 6566 passed, 1809 skipped, 17783 warnings in 586.14s (0:09:46) ======
================================ test session starts =================================
platform linux -- Python 3.11.1, pytest-7.2.0, pluggy-1.0.0 -- /home/corey/pkg/antelope/upstream/swift/.tox/py3/bin/python
cachedir: .tox/py3/.pytest_cache
rootdir: /home/corey/pkg/antelope/upstream/swift, configfile: tox.ini
plugins: cov-4.0.0, requests-mock-1.10.0
collected 8378 items / 8375 deselected / 3 selected
run-last-failure: rerun previous 3 failures
test/unit/common/test_db.py::TestGreenDBConnection::test_execute_when_locked FAILED [ 33%]
test/unit/common/test_db.py::TestDatabaseBroker::test_get FAILED [ 66%]
test/unit/common/test_db.py::TestDatabaseBroker::test_lock FAILED [100%]
====================================== FAILURES ======================================
___________________ TestGreenDBConnection.test_execute_when_locked ___________________
self = <test.unit.common.test_db.TestGreenDBConnection testMethod=test_execute_when_locked>
def test_execute_when_locked(self):
# This test is dependent on the code under test calling execute and
# commit as sqlite3.Cursor.execute in a subclass.
class InterceptCursor(sqlite3.Cursor):
pass
db_error = sqlite3.OperationalError('database is locked')
InterceptCursor.execute = MagicMock(side_effect=db_error)
with patch('sqlite3.Cursor', new=InterceptCursor):
conn = sqlite3.connect(':memory:', check_same_thread=False,
factory=GreenDBConnection, timeout=0.1)
> self.assertRaises(Timeout, conn.execute, 'select 1')
E AssertionError: Timeout not raised by execute
test/unit/common/test_db.py:160: AssertionError
____________________________ TestDatabaseBroker.test_get _____________________________
self = <test.unit.common.test_db.TestDatabaseBroker testMethod=test_get>
def test_get(self):
broker = DatabaseBroker(':memory:')
with self.assertRaises(DatabaseConnectionError) as raised, \
broker.get() as conn:
conn.execute('SELECT 1')
self.assertEqual(
str(raised.exception),
"DB connection error (:memory:, 0):\nDB doesn't exist")
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'))
with self.assertRaises(DatabaseConnectionError) as raised, \
broker.get() as conn:
conn.execute('SELECT 1')
self.assertEqual(
str(raised.exception),
"DB connection error (%s, 0):\nDB doesn't exist" % broker.db_file)
def stub(*args, **kwargs):
pass
broker._initialize = stub
broker.initialize(normalize_timestamp('1'))
with broker.get() as conn:
conn.execute('CREATE TABLE test (one TEXT)')
try:
with broker.get() as conn:
conn.execute('INSERT INTO test (one) VALUES ("1")')
raise Exception('test')
conn.commit()
except Exception:
pass
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'))
with broker.get() as conn:
self.assertEqual(
[r[0] for r in conn.execute('SELECT * FROM test')], [])
with broker.get() as conn:
conn.execute('INSERT INTO test (one) VALUES ("1")')
conn.commit()
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'))
with broker.get() as conn:
self.assertEqual(
[r[0] for r in conn.execute('SELECT * FROM test')], ['1'])
dbpath = os.path.join(self.testdir, 'dev', 'dbs', 'par', 'pre', 'db')
mkdirs(dbpath)
qpath = os.path.join(self.testdir, 'dev', 'quarantined', 'tests', 'db')
with patch('swift.common.db.renamer', lambda a, b,
fsync: b):
# Test malformed database
copy(os.path.join(os.path.dirname(__file__),
'malformed_example.db'),
os.path.join(dbpath, '1.db'))
broker = DatabaseBroker(os.path.join(dbpath, '1.db'))
broker.db_type = 'test'
> with self.assertRaises(sqlite3.DatabaseError) as raised, \
broker.get() as conn:
E AssertionError: DatabaseError not raised
test/unit/common/test_db.py:846: AssertionError
____________________________ TestDatabaseBroker.test_lock ____________________________
self = <test.unit.common.test_db.TestDatabaseBroker testMethod=test_lock>
def test_lock(self):
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'), timeout=.1)
with self.assertRaises(DatabaseConnectionError) as raised, \
broker.lock():
pass
self.assertEqual(
str(raised.exception),
"DB connection error (%s, 0):\nDB doesn't exist" % broker.db_file)
def stub(*args, **kwargs):
pass
broker._initialize = stub
broker.initialize(normalize_timestamp('1'))
with broker.lock():
pass
with broker.lock():
pass
with self.assertRaises(RuntimeError) as raised, broker.lock():
raise RuntimeError('boom!')
self.assertEqual(raised.exception.args[0], 'boom!')
broker2 = DatabaseBroker(os.path.join(self.testdir, '1.db'),
timeout=.1)
broker2._initialize = stub
with broker.lock():
# broker2 raises the timeout
with self.assertRaises(LockTimeout) as raised:
> with broker2.lock():
test/unit/common/test_db.py:928:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.11/contextlib.py:137: in __enter__
return next(self.gen)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@contextmanager
def lock(self):
"""Use with the "with" statement; locks a database."""
if not self.conn:
if self.db_file != ':memory:' and os.path.exists(self.db_file):
self.conn = get_db_connection(self.db_file, self.timeout,
self.logger)
else:
raise DatabaseConnectionError(self.db_file, "DB doesn't exist")
conn = self.conn
self.conn = None
orig_isolation_level = conn.isolation_level
conn.isolation_level = None
> conn.execute('BEGIN IMMEDIATE')
E sqlite3.OperationalError: database is locked
swift/common/db.py:581: OperationalError
================================== warnings summary ==================================
.tox/py3/lib/python3.11/site-packages/eventlet/support/greenlets.py:6
/home/corey/pkg/antelope/upstream/swift/.tox/py3/lib/python3.11/site-packages/eventlet/support/greenlets.py:6: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
preserves_excinfo = (distutils.version.LooseVersion(greenlet.__version__)
.tox/py3/lib/python3.11/site-packages/eventlet/support/greenlets.py:7
/home/corey/pkg/antelope/upstream/swift/.tox/py3/lib/python3.11/site-packages/eventlet/support/greenlets.py:7: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
>= distutils.version.LooseVersion('0.3.2'))
swift/common/middleware/crypto/crypto_utils.py:30
/home/corey/pkg/antelope/upstream/swift/swift/common/middleware/crypto/crypto_utils.py:30: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
from cgi import parse_header
test/unit/common/test_db_replicator.py:290
/home/corey/pkg/antelope/upstream/swift/test/unit/common/test_db_replicator.py:290: PytestCollectionWarning: cannot collect test class 'TestReplicator' because it has a __init__ constructor (from: test/unit/common/test_db_replicator.py)
class TestReplicator(db_replicator.Replicator):
test/unit/common/middleware/s3api/test_s3token.py:75
/home/corey/pkg/antelope/upstream/swift/test/unit/common/middleware/s3api/test_s3token.py:75: PytestCollectionWarning: cannot collect test class 'TestResponse' because it has a __init__ constructor (from: test/unit/common/middleware/s3api/test_s3token.py)
class TestResponse(requests.Response):
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
---------- coverage: platform linux, python 3.11.1-final-0 -----------
...
============================== short test summary info =============================== FAILED test/unit/common/test_db.py::TestGreenDBConnection::test_execute_when_locked - AssertionError: Timeout not raised by execute FAILED test/unit/common/test_db.py::TestDatabaseBroker::test_get - AssertionError: DatabaseError not raised
FAILED test/unit/common/test_db.py::TestDatabaseBroker::test_lock - sqlite3.OperationalError: database is locked
================== 3 failed, 8375 deselected, 5 warnings in 30.84s =================== ERROR: InvocationError for command /usr/bin/bash -ec 'pytest test/unit || pytest --last-failed test/unit' (exited with code 1) ______________________________________ summary _______________________________________ |
|