Skip to content

Commit 00f2f61

Browse files
author
Jaume Marhuenda
authored
Merge pull request apache#735 from datastax/python-gevent-integration-tests
Added support for different loops in integrations tests
2 parents dd9915f + 986127c commit 00f2f61

2 files changed

Lines changed: 74 additions & 11 deletions

File tree

build.yaml

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,49 @@ schedules:
33
schedule: per_commit
44
branches:
55
include: [master, /python.*/]
6+
env_vars: |
7+
EVENT_LOOP_MANAGER='libev'
8+
9+
nightly_libev:
10+
schedule: nightly
11+
branches:
12+
include: [master]
13+
env_vars: |
14+
EVENT_LOOP_MANAGER='libev'
15+
matrix:
16+
exclude:
17+
- cassandra: ['2.0', '2.1', '2.2', '3.0']
18+
19+
nightly_gevent:
20+
schedule: nightly
21+
branches:
22+
include: [master]
23+
env_vars: |
24+
EVENT_LOOP_MANAGER='gevent'
25+
matrix:
26+
exclude:
27+
- pythoon: 3.4
28+
- cassandra: ['2.0', '2.1', '2.2', '3.0']
29+
30+
nightly_eventlet:
31+
schedule: nightly
32+
branches:
33+
include: [master]
34+
env_vars: |
35+
EVENT_LOOP_MANAGER='eventlet'
36+
matrix:
37+
exclude:
38+
- cassandra: ['2.0', '2.1', '2.2', '3.0']
39+
40+
nightly_async:
41+
schedule: nightly
42+
branches:
43+
include: [master]
44+
env_vars: |
45+
EVENT_LOOP_MANAGER='async'
46+
matrix:
47+
exclude:
48+
- cassandra: ['2.0', '2.1', '2.2', '3.0']
649

750
python:
851
- 2.7
@@ -16,8 +59,6 @@ cassandra:
1659
- '3.0'
1760
- '3.11'
1861
env:
19-
EVENT_LOOP_MANAGER:
20-
- libev
2162
CYTHON:
2263
- CYTHON
2364
- NO_CYTHON
@@ -28,9 +69,7 @@ build:
2869
2970
pip install git+https://github.com/pcmanus/ccm.git
3071
# Install dependencies
31-
if [[ $EVENT_LOOP_MANAGER == 'libev' ]]; then
32-
sudo apt-get install -y libev4 libev-dev
33-
fi
72+
sudo apt-get install -y libev4 libev-dev
3473
pip install -r test-requirements.txt
3574
pip install nose-ignore-docstring
3675
FORCE_CYTHON=False
@@ -46,12 +85,12 @@ build:
4685
fi
4786
4887
echo "==========RUNNING CQLENGINE TESTS=========="
49-
CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION VERIFY_CYTHON=$FORCE_CYTHON nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=cqle_results.xml tests/integration/cqlengine/ || true
88+
EVENT_LOOP_MANAGER=$EVENT_LOOP_MANAGER CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION VERIFY_CYTHON=$FORCE_CYTHON nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=cqle_results.xml tests/integration/cqlengine/ || true
5089
5190
echo "==========RUNNING INTEGRATION TESTS=========="
52-
CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION VERIFY_CYTHON=$FORCE_CYTHON nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=standard_results.xml tests/integration/standard/ || true
91+
EVENT_LOOP_MANAGER=$EVENT_LOOP_MANAGER CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION VERIFY_CYTHON=$FORCE_CYTHON nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=standard_results.xml tests/integration/standard/ || true
5392
5493
echo "==========RUNNING LONG INTEGRATION TESTS=========="
55-
CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION VERIFY_CYTHON=$FORCE_CYTHON nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=long_results.xml tests/integration/long/ || true
94+
EVENT_LOOP_MANAGER=$EVENT_LOOP_MANAGER CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION VERIFY_CYTHON=$FORCE_CYTHON nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --with-ignore-docstrings --with-xunit --xunit-file=long_results.xml tests/integration/long/ || true
5695
- xunit:
5796
- "*_results.xml"

tests/integration/__init__.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,39 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
import os
15+
16+
from cassandra.io.geventreactor import GeventConnection
17+
from cassandra.io.libevreactor import LibevConnection
18+
from cassandra.io.asyncorereactor import AsyncoreConnection
19+
from cassandra.io.eventletreactor import EventletConnection
20+
from cassandra.io.twistedreactor import TwistedConnection
21+
22+
EVENT_LOOP_MANAGER = os.getenv('EVENT_LOOP_MANAGER', "gevent")
23+
if EVENT_LOOP_MANAGER == "gevent":
24+
import gevent.monkey
25+
gevent.monkey.patch_all()
26+
connection_class = GeventConnection
27+
elif EVENT_LOOP_MANAGER == "eventlet":
28+
from eventlet import monkey_patch
29+
monkey_patch()
30+
connection_class = EventletConnection
31+
elif EVENT_LOOP_MANAGER == "async":
32+
connection_class = AsyncoreConnection
33+
elif EVENT_LOOP_MANAGER == "twisted":
34+
connection_class = TwistedConnection
35+
else:
36+
connection_class = LibevConnection
37+
38+
from cassandra.cluster import Cluster
39+
Cluster.connection_class = connection_class
1440

1541
try:
1642
import unittest2 as unittest
1743
except ImportError:
1844
import unittest # noqa
1945
from packaging.version import Version
2046
import logging
21-
import os
2247
import socket
2348
import sys
2449
import time
@@ -30,9 +55,8 @@
3055

3156
from cassandra import OperationTimedOut, ReadTimeout, ReadFailure, WriteTimeout, WriteFailure, AlreadyExists, \
3257
InvalidRequest
33-
from cassandra.cluster import Cluster
58+
3459
from cassandra.protocol import ConfigurationException
35-
from cassandra.policies import RoundRobinPolicy
3660

3761
try:
3862
from ccmlib.cluster import Cluster as CCMCluster

0 commit comments

Comments
 (0)