Skip to content

Commit 850f218

Browse files
authored
Merge pull request datastax#966 from datastax/python-fix-keyspace-test-hang
Python fix keyspace test hang
2 parents 43e85ac + 17c55e6 commit 850f218

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Bug Fixes
44
---------
55
* Tokenmap.get_replicas returns the wrong value if token coincides with the end of the range (PYTHON-978)
66
* Python Driver fails with "more than 255 arguments" python exception when > 255 columns specified in query response (PYTHON-893)
7+
* Hang in integration.standard.test_cluster.ClusterTests.test_set_keyspace_twice (PYTHON-998)
78

89
Other
910
-----

tests/integration/standard/test_cluster.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@
2727
from packaging.version import Version
2828

2929
import cassandra
30-
from cassandra.cluster import Cluster, Session, NoHostAvailable, ExecutionProfile, EXEC_PROFILE_DEFAULT
30+
from cassandra.cluster import Cluster, NoHostAvailable, ExecutionProfile, EXEC_PROFILE_DEFAULT
3131
from cassandra.concurrent import execute_concurrent
3232
from cassandra.policies import (RoundRobinPolicy, ExponentialReconnectionPolicy,
3333
RetryPolicy, SimpleConvictionPolicy, HostDistance,
3434
AddressTranslator, TokenAwarePolicy, HostFilterPolicy)
3535
from cassandra import ConsistencyLevel
3636

37-
from cassandra.pool import Host
3837
from cassandra.query import SimpleStatement, TraceUnavailable, tuple_factory
3938
from cassandra.auth import PlainTextAuthProvider, SaslAuthProvider
4039
from cassandra import connection
@@ -200,23 +199,31 @@ def test_session_host_parameter(self):
200199
201200
@test_category connection
202201
"""
202+
def cleanup():
203+
"""
204+
When this test fails, the inline .shutdown() calls don't get
205+
called, so we register this as a cleanup.
206+
"""
207+
self.cluster_to_shutdown.shutdown()
208+
self.addCleanup(cleanup)
209+
203210
# Test with empty list
204-
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
211+
self.cluster_to_shutdown = Cluster([], protocol_version=PROTOCOL_VERSION)
205212
with self.assertRaises(NoHostAvailable):
206-
Session(cluster, [])
207-
cluster.shutdown()
213+
self.cluster_to_shutdown.connect()
214+
self.cluster_to_shutdown.shutdown()
208215

209216
# Test with only invalid
210-
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
217+
self.cluster_to_shutdown = Cluster(('1.2.3.4',), protocol_version=PROTOCOL_VERSION)
211218
with self.assertRaises(NoHostAvailable):
212-
Session(cluster, [Host("1.2.3.4", SimpleConvictionPolicy)])
213-
cluster.shutdown()
219+
self.cluster_to_shutdown.connect()
220+
self.cluster_to_shutdown.shutdown()
214221

215222
# Test with valid and invalid hosts
216-
cluster = Cluster(protocol_version=PROTOCOL_VERSION)
217-
Session(cluster, [Host(x, SimpleConvictionPolicy) for x in
218-
("127.0.0.1", "127.0.0.2", "1.2.3.4")])
219-
cluster.shutdown()
223+
self.cluster_to_shutdown = Cluster(("127.0.0.1", "127.0.0.2", "1.2.3.4"),
224+
protocol_version=PROTOCOL_VERSION)
225+
self.cluster_to_shutdown.connect()
226+
self.cluster_to_shutdown.shutdown()
220227

221228
def test_protocol_negotiation(self):
222229
"""

0 commit comments

Comments
 (0)