CI: test under py311
Jammy only offers a py311 RC, so include the __slots__ hack to avoid the segfault from https://github.com/python/cpython/issues/99886. Fix up a test to work with the slotted connection. Change-Id: I0e928bcb3810e391297300f4949024db3cf87d05
This commit is contained in:
parent
0235db3d31
commit
f955e81043
19
.zuul.yaml
19
.zuul.yaml
@ -136,6 +136,22 @@
|
||||
python_version: '3.10'
|
||||
post-run: tools/playbooks/common/cover-post.yaml
|
||||
|
||||
- job:
|
||||
name: swift-tox-py311
|
||||
parent: swift-tox-base
|
||||
nodeset: ubuntu-jammy
|
||||
description: |
|
||||
Run unit-tests for swift under cPython version 3.11.
|
||||
|
||||
Uses tox with the ``py311`` environment.
|
||||
It sets TMPDIR to an XFS mount point created via
|
||||
tools/test-setup.sh.
|
||||
vars:
|
||||
tox_envlist: py311
|
||||
bindep_profile: test py311
|
||||
python_version: '3.11'
|
||||
post-run: tools/playbooks/common/cover-post.yaml
|
||||
|
||||
- job:
|
||||
name: swift-tox-func-py27
|
||||
parent: swift-tox-base
|
||||
@ -700,6 +716,8 @@
|
||||
irrelevant-files: *unittest-irrelevant-files
|
||||
- swift-tox-py310:
|
||||
irrelevant-files: *unittest-irrelevant-files
|
||||
- swift-tox-py311:
|
||||
irrelevant-files: *unittest-irrelevant-files
|
||||
|
||||
# Functional tests
|
||||
- swift-tox-func-py27:
|
||||
@ -788,6 +806,7 @@
|
||||
- swift-tox-py36
|
||||
- swift-tox-py39
|
||||
- swift-tox-py310
|
||||
- swift-tox-py311
|
||||
- swift-tox-func-py27
|
||||
- swift-tox-func-encryption-py27
|
||||
- swift-tox-func-ec-py27
|
||||
|
@ -129,6 +129,9 @@ class DatabaseAlreadyExists(sqlite3.DatabaseError):
|
||||
|
||||
class GreenDBConnection(sqlite3.Connection):
|
||||
"""SQLite DB Connection handler that plays well with eventlet."""
|
||||
# slots are needed for python 3.11.0 (there's an issue fixed in 3.11.1,
|
||||
# see https://github.com/python/cpython/issues/99886)
|
||||
__slots__ = ('timeout', 'db_file')
|
||||
|
||||
def __init__(self, database, timeout=None, *args, **kwargs):
|
||||
if timeout is None:
|
||||
@ -157,6 +160,9 @@ class GreenDBConnection(sqlite3.Connection):
|
||||
|
||||
class GreenDBCursor(sqlite3.Cursor):
|
||||
"""SQLite Cursor handler that plays well with eventlet."""
|
||||
# slots are needed for python 3.11.0 (there's an issue fixed in 3.11.1,
|
||||
# see https://github.com/python/cpython/issues/99886)
|
||||
__slots__ = ('timeout', 'db_file')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.timeout = args[0].timeout
|
||||
|
@ -1521,23 +1521,37 @@ class TestAccountBrokerBeforeSPI(TestAccountBroker):
|
||||
real_get = broker.get
|
||||
called = []
|
||||
|
||||
class ExpectedError(Exception):
|
||||
'''Expected error to be raised during the test'''
|
||||
|
||||
@contextmanager
|
||||
def mock_get():
|
||||
with real_get() as conn:
|
||||
|
||||
def mock_executescript(script):
|
||||
if called:
|
||||
raise Exception('kaboom!')
|
||||
called.append(script)
|
||||
class MockConn(object):
|
||||
def __init__(self, real_conn):
|
||||
self.real_conn = real_conn
|
||||
|
||||
conn.executescript = mock_executescript
|
||||
yield conn
|
||||
@property
|
||||
def cursor(self):
|
||||
return self.real_conn.cursor
|
||||
|
||||
@property
|
||||
def execute(self):
|
||||
return self.real_conn.execute
|
||||
|
||||
def executescript(self, script):
|
||||
if called:
|
||||
raise ExpectedError('kaboom!')
|
||||
called.append(script)
|
||||
|
||||
yield MockConn(conn)
|
||||
|
||||
broker.get = mock_get
|
||||
|
||||
try:
|
||||
broker._commit_puts()
|
||||
except Exception:
|
||||
except ExpectedError:
|
||||
pass
|
||||
else:
|
||||
self.fail('mock exception was not raised')
|
||||
|
Loading…
Reference in New Issue
Block a user