Skip to content

Commit 125a289

Browse files
committed
Merge branch 'oss-next' of github.com:riptano/python-driver into oss-next
2 parents 04e6b7a + 1395dd1 commit 125a289

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

tests/integration/cqlengine/management/test_management.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,23 @@
1919
import mock
2020
import logging
2121
from packaging.version import Version
22-
2322
from cassandra.cqlengine.connection import get_session, get_cluster
2423
from cassandra.cqlengine import CQLEngineException
2524
from cassandra.cqlengine import management
2625
from cassandra.cqlengine.management import _get_table_metadata, sync_table, drop_table, sync_type
2726
from cassandra.cqlengine.models import Model
2827
from cassandra.cqlengine import columns
2928

30-
from tests.integration import PROTOCOL_VERSION, greaterthancass20, MockLoggingHandler, CASSANDRA_VERSION
29+
from tests.integration import DSE_VERSION, PROTOCOL_VERSION, greaterthancass20, MockLoggingHandler, CASSANDRA_VERSION
3130
from tests.integration.cqlengine.base import BaseCassEngTestCase
3231
from tests.integration.cqlengine.query.test_queryset import TestModel
3332
from cassandra.cqlengine.usertype import UserType
3433
from tests.integration.cqlengine import DEFAULT_KEYSPACE
3534

3635

36+
INCLUDE_REPAIR = not (DSE_VERSION and DSE_VERSION >= Version('6.0.7'))
37+
38+
3739
class KeyspaceManagementTest(BaseCassEngTestCase):
3840
def test_create_drop_succeeeds(self):
3941
cluster = get_cluster()
@@ -207,9 +209,13 @@ class ModelWithTableProperties(Model):
207209

208210
__options__ = {'bloom_filter_fp_chance': '0.76328',
209211
'comment': 'TxfguvBdzwROQALmQBOziRMbkqVGFjqcJfVhwGR',
210-
'gc_grace_seconds': '2063',
211-
'read_repair_chance': '0.17985',
212-
'dclocal_read_repair_chance': '0.50811'}
212+
'gc_grace_seconds': '2063'}
213+
214+
if INCLUDE_REPAIR:
215+
__options__.update(
216+
{'read_repair_chance': '0.17985',
217+
'dclocal_read_repair_chance': '0.50811'}
218+
)
213219

214220
key = columns.UUID(primary_key=True)
215221

@@ -225,13 +231,15 @@ def test_set_table_properties(self):
225231
expected = {'bloom_filter_fp_chance': 0.76328,
226232
'comment': 'TxfguvBdzwROQALmQBOziRMbkqVGFjqcJfVhwGR',
227233
'gc_grace_seconds': 2063,
228-
'read_repair_chance': 0.17985,
229234
# For some reason 'dclocal_read_repair_chance' in CQL is called
230235
# just 'local_read_repair_chance' in the schema table.
231236
# Source: https://issues.apache.org/jira/browse/CASSANDRA-6717
232237
# TODO: due to a bug in the native driver i'm not seeing the local read repair chance show up
233238
# 'local_read_repair_chance': 0.50811,
234239
}
240+
if INCLUDE_REPAIR:
241+
expected.update({'read_repair_chance': 0.17985})
242+
235243
options = management._get_table_metadata(ModelWithTableProperties).options
236244
self.assertEqual(dict([(k, options.get(k)) for k in expected.keys()]),
237245
expected)
@@ -241,8 +249,9 @@ def test_table_property_update(self):
241249
ModelWithTableProperties.__options__['comment'] = 'xirAkRWZVVvsmzRvXamiEcQkshkUIDINVJZgLYSdnGHweiBrAiJdLJkVohdRy'
242250
ModelWithTableProperties.__options__['gc_grace_seconds'] = 96362
243251

244-
ModelWithTableProperties.__options__['read_repair_chance'] = 0.2989
245-
ModelWithTableProperties.__options__['dclocal_read_repair_chance'] = 0.12732
252+
if INCLUDE_REPAIR:
253+
ModelWithTableProperties.__options__['read_repair_chance'] = 0.2989
254+
ModelWithTableProperties.__options__['dclocal_read_repair_chance'] = 0.12732
246255

247256
sync_table(ModelWithTableProperties)
248257

tests/integration/upgrade/test_upgrade.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,17 @@
2626
import unittest # noqa
2727

2828

29+
# Previous Cassandra upgrade
2930
two_to_three_path = upgrade_paths([
3031
UpgradePath("2.2.9-3.11", {"version": "2.2.9"}, {"version": "3.11"}, {}),
3132
])
33+
34+
# Previous DSE upgrade
35+
five_upgrade_path = upgrade_paths([
36+
UpgradePath("5.0.11-5.1.4", {"version": "5.0.11"}, {"version": "5.1.4"}, {}),
37+
])
38+
39+
3240
class UpgradeTests(UpgradeBase):
3341
@two_to_three_path
3442
def test_can_write(self):
@@ -43,16 +51,17 @@ def test_can_write(self):
4351
"""
4452
self.start_upgrade(0)
4553

54+
self.cluster_driver.add_execution_profile("all", ExecutionProfile(consistency_level=ConsistencyLevel.ALL))
55+
self.cluster_driver.add_execution_profile("one", ExecutionProfile(consistency_level=ConsistencyLevel.LOCAL_ONE))
56+
4657
c = count()
4758
while not self.is_upgraded():
48-
self.session.execute("INSERT INTO test3rf.test(k, v) VALUES (%s, 0)", (next(c), ))
59+
self.session.execute("INSERT INTO test3rf.test(k, v) VALUES (%s, 0)", (next(c), ), execution_profile="one")
4960
time.sleep(0.0001)
5061

51-
self.session.default_consistency_level = ConsistencyLevel.ALL
52-
total_number_of_inserted = self.session.execute("SELECT COUNT(*) from test3rf.test")[0][0]
62+
total_number_of_inserted = self.session.execute("SELECT COUNT(*) from test3rf.test", execution_profile="all")[0][0]
5363
self.assertEqual(total_number_of_inserted, next(c))
5464

55-
self.session.default_consistency_level = ConsistencyLevel.LOCAL_ONE
5665
self.assertEqual(self.logger_handler.get_message_count("error", ""), 0)
5766

5867
@two_to_three_path
@@ -101,16 +110,17 @@ def test_can_write(self):
101110
"""
102111
self.start_upgrade(0)
103112

113+
self.cluster_driver.add_execution_profile("all", ExecutionProfile(consistency_level=ConsistencyLevel.ALL))
114+
self.cluster_driver.add_execution_profile("one", ExecutionProfile(consistency_level=ConsistencyLevel.LOCAL_ONE))
115+
104116
c = count()
105117
while not self.is_upgraded():
106-
self.session.execute("INSERT INTO test3rf.test(k, v) VALUES (%s, 0)", (next(c),))
118+
self.session.execute("INSERT INTO test3rf.test(k, v) VALUES (%s, 0)", (next(c),), execution_profile="one")
107119
time.sleep(0.0001)
108120

109-
self.session.default_consistency_level = ConsistencyLevel.ALL
110-
total_number_of_inserted = self.session.execute("SELECT COUNT(*) from test3rf.test")[0][0]
121+
total_number_of_inserted = self.session.execute("SELECT COUNT(*) from test3rf.test", execution_profile="all")[0][0]
111122
self.assertEqual(total_number_of_inserted, next(c))
112123

113-
self.session.default_consistency_level = ConsistencyLevel.LOCAL_ONE
114124
self.assertEqual(self.logger_handler.get_message_count("error", ""), 0)
115125

116126
@two_to_three_path
@@ -261,7 +271,7 @@ def test_can_write_speculative(self):
261271
cluster = Cluster()
262272
self.addCleanup(cluster.shutdown)
263273
cluster.add_execution_profile("spec_ep_rr", spec_ep_rr)
264-
274+
cluster.add_execution_profile("all", ExecutionProfile(consistency_level=ConsistencyLevel.ALL))
265275
session = cluster.connect()
266276

267277
self.start_upgrade(0)
@@ -272,8 +282,7 @@ def test_can_write_speculative(self):
272282
execution_profile='spec_ep_rr')
273283
time.sleep(0.0001)
274284

275-
session.default_consistency_level = ConsistencyLevel.ALL
276-
total_number_of_inserted = session.execute("SELECT COUNT(*) from test3rf.test")[0][0]
285+
total_number_of_inserted = session.execute("SELECT COUNT(*) from test3rf.test", execution_profile="all")[0][0]
277286
self.assertEqual(total_number_of_inserted, next(c))
278287

279288
self.assertEqual(self.logger_handler.get_message_count("error", ""), 0)

0 commit comments

Comments
 (0)