Skip to content

Commit aa2699b

Browse files
authored
Merge pull request datastax#979 from datastax/python-test-dse-support
Add test-dse and mapped_cassandra_version support
2 parents b1b3f86 + 580a122 commit aa2699b

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

build.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ schedules:
9090
matrix:
9191
exclude:
9292
- python: [3.4, 3.6]
93-
- cassandra: ['2.0', '2.1', '2.2', '3.0']
93+
- cassandra: ['2.0', '2.1', '2.2', '3.0', 'test-dse']
9494

9595
python:
9696
- 2.7
@@ -106,6 +106,7 @@ cassandra:
106106
- '2.2'
107107
- '3.0'
108108
- '3.11'
109+
- 'test-dse'
109110

110111
env:
111112
CYTHON:
@@ -122,7 +123,7 @@ build:
122123
pip install --upgrade pip
123124
pip install -U setuptools
124125
125-
pip install git+https://github.com/riptano/ccm.git
126+
pip install git+ssh://git@github.com/riptano/ccm-private.git
126127
127128
pip install -r test-requirements.txt
128129
pip install nose-ignore-docstring
@@ -160,18 +161,18 @@ build:
160161
echo "Running with event loop manager: $EVENT_LOOP_MANAGER"
161162
echo "==========RUNNING SIMULACRON TESTS=========="
162163
SIMULACRON_JAR="$HOME/simulacron.jar"
163-
SIMULACRON_JAR=$SIMULACRON_JAR EVENT_LOOP_MANAGER=$EVENT_LOOP_MANAGER CASSANDRA_DIR=$CCM_INSTALL_DIR DSE_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=simulacron_results.xml tests/integration/simulacron/ || true
164+
SIMULACRON_JAR=$SIMULACRON_JAR EVENT_LOOP_MANAGER=$EVENT_LOOP_MANAGER CASSANDRA_DIR=$CCM_INSTALL_DIR CCM_ARGS="$CCM_ARGS" DSE_VERSION=$CCM_CASSANDRA_VERSION MAPPED_CASSANDRA_VERSION=$MAPPED_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=simulacron_results.xml tests/integration/simulacron/ || true
164165
165166
echo "Running with event loop manager: $EVENT_LOOP_MANAGER"
166167
echo "==========RUNNING CQLENGINE TESTS=========="
167-
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
168+
EVENT_LOOP_MANAGER=$EVENT_LOOP_MANAGER CCM_ARGS="$CCM_ARGS" CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION MAPPED_CASSANDRA_VERSION=$MAPPED_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
168169
169170
echo "==========RUNNING INTEGRATION TESTS=========="
170-
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
171+
EVENT_LOOP_MANAGER=$EVENT_LOOP_MANAGER CCM_ARGS="$CCM_ARGS" CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION MAPPED_CASSANDRA_VERSION=$MAPPED_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
171172
172173
if [ -z "$EXCLUDE_LONG" ]; then
173174
echo "==========RUNNING LONG INTEGRATION TESTS=========="
174-
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" --exclude-dir=tests/integration/long/upgrade --with-ignore-docstrings --with-xunit --xunit-file=long_results.xml tests/integration/long/ || true
175+
EVENT_LOOP_MANAGER=$EVENT_LOOP_MANAGER CCM_ARGS="$CCM_ARGS" CASSANDRA_VERSION=$CCM_CASSANDRA_VERSION MAPPED_CASSANDRA_VERSION=$MAPPED_CASSANDRA_VERSION VERIFY_CYTHON=$FORCE_CYTHON nosetests -s -v --logging-format="[%(levelname)s] %(asctime)s %(thread)d: %(message)s" --exclude-dir=tests/integration/long/upgrade --with-ignore-docstrings --with-xunit --xunit-file=long_results.xml tests/integration/long/ || true
175176
fi
176177
- xunit:
177178
- "*_results.xml"

tests/integration/__init__.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ def _tuple_version(version_string):
9292
return tuple([int(p) for p in version_string.split('.')])
9393

9494

95+
def cmd_line_args_to_dict(env_var):
96+
cmd_args_env = os.environ.get(env_var, None)
97+
args = {}
98+
if cmd_args_env:
99+
cmd_args = cmd_args_env.strip().split(' ')
100+
while cmd_args:
101+
cmd_arg = cmd_args.pop(0)
102+
cmd_arg_value = True if cmd_arg.startswith('--') else cmd_args.pop(0)
103+
args[cmd_arg.lstrip('-')] = cmd_arg_value
104+
return args
105+
106+
95107
def _get_dse_version_from_cass(cass_version):
96108
if cass_version.startswith('2.1'):
97109
dse_ver = "4.8.15"
@@ -106,7 +118,6 @@ def _get_dse_version_from_cass(cass_version):
106118
dse_ver = "2.1"
107119
return dse_ver
108120

109-
110121
USE_CASS_EXTERNAL = bool(os.getenv('USE_CASS_EXTERNAL', False))
111122
KEEP_TEST_CLUSTER = bool(os.getenv('KEEP_TEST_CLUSTER', False))
112123
SIMULACRON_JAR = os.getenv('SIMULACRON_JAR', None)
@@ -115,7 +126,15 @@ def _get_dse_version_from_cass(cass_version):
115126
CASSANDRA_DIR = os.getenv('CASSANDRA_DIR', None)
116127

117128
default_cassandra_version = '3.11'
118-
CASSANDRA_VERSION = Version(os.getenv('CASSANDRA_VERSION', default_cassandra_version))
129+
cv_string = os.getenv('CASSANDRA_VERSION', default_cassandra_version)
130+
mcv_string = os.getenv('MAPPED_CASSANDRA_VERSION', None)
131+
try:
132+
cassandra_version = Version(cv_string) # env var is set to test-dse
133+
except:
134+
# fallback to MAPPED_CASSANDRA_VERSION
135+
cassandra_version = Version(mcv_string)
136+
CASSANDRA_VERSION = Version(mcv_string) if mcv_string else cassandra_version
137+
CCM_VERSION = cassandra_version if mcv_string else CASSANDRA_VERSION
119138

120139
default_dse_version = _get_dse_version_from_cass(CASSANDRA_VERSION.base_version)
121140

@@ -128,7 +147,8 @@ def _get_dse_version_from_cass(cass_version):
128147

129148
else:
130149
log.info('Using Cassandra version: %s', CASSANDRA_VERSION)
131-
CCM_KWARGS['version'] = CASSANDRA_VERSION
150+
log.info('Using CCM version: %s', CCM_VERSION)
151+
CCM_KWARGS['version'] = CCM_VERSION
132152

133153
#This changes the default contact_point parameter in Cluster
134154
def set_default_cass_ip():
@@ -339,7 +359,7 @@ def use_cluster(cluster_name, nodes, ipformat=None, start=True, workloads=[], se
339359
elif ccm_options is None:
340360
ccm_options = CCM_KWARGS.copy()
341361

342-
cassandra_version = ccm_options.get('version', CASSANDRA_VERSION)
362+
cassandra_version = ccm_options.get('version', CCM_VERSION)
343363
dse_version = ccm_options.get('version', DSE_VERSION)
344364

345365
if 'version' in ccm_options:
@@ -373,6 +393,8 @@ def use_cluster(cluster_name, nodes, ipformat=None, start=True, workloads=[], se
373393
log.warning("{0}: {1} Backtrace: {2}".format(ex_type.__name__, ex, traceback.extract_tb(tb)))
374394
del tb
375395

396+
ccm_options.update(cmd_line_args_to_dict('CCM_ARGS'))
397+
376398
log.debug("Creating new CCM cluster, {0}, with args {1}".format(cluster_name, ccm_options))
377399

378400
if dse_cluster:
@@ -391,7 +413,6 @@ def use_cluster(cluster_name, nodes, ipformat=None, start=True, workloads=[], se
391413

392414
CCM_CLUSTER.set_dse_configuration_options(dse_options)
393415
else:
394-
log.debug("Creating new CCM cluster, {0}, with args {1}".format(cluster_name, ccm_options))
395416
CCM_CLUSTER = CCMCluster(path, cluster_name, **ccm_options)
396417
CCM_CLUSTER.set_configuration_options({'start_native_transport': True})
397418
if cassandra_version >= Version('2.2'):

0 commit comments

Comments
 (0)