Skip to content

Commit d59af15

Browse files
committed
Changes from test failures.
Move session id creation before insights reporter starts. When the insights reporter retrieves the startup data, it captures the session id. Since this runs in a separate thread, the session id is usually created by the time this capture actually runs. But it's a race, and sessionId can occassionally be captured as None. Fix tests/integration/cqlengine/model/test_model.py:TestDeprecationWarning.test_deprecation_warnings: Asyncio throws warnings on python 2.7+ that aren't relevant to the test, so ignore them.
1 parent c5a374f commit d59af15

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

cassandra/cluster.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2538,6 +2538,8 @@ def __init__(self, cluster, hosts, keyspace=None):
25382538
msg += " using keyspace '%s'" % self.keyspace
25392539
raise NoHostAvailable(msg, [h.address for h in hosts])
25402540

2541+
self.session_id = uuid.uuid4()
2542+
25412543
cc_host = self.cluster.get_control_connection_host()
25422544
valid_insights_version = (cc_host and version_supports_insights(cc_host.dse_version))
25432545
if self.cluster.monitor_reporting_enabled and valid_insights_version:
@@ -2551,7 +2553,6 @@ def __init__(self, cluster, hosts, keyspace=None):
25512553
'not supported by server version {v} on '
25522554
'ControlConnection host {c}'.format(v=cc_host.release_version, c=cc_host))
25532555

2554-
self.session_id = uuid.uuid4()
25552556
log.debug('Started Session with client_id {} and session_id {}'.format(self.cluster.client_id,
25562557
self.session_id))
25572558

tests/integration/cqlengine/model/test_model.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,13 @@ class SensitiveModel(Model):
259259
rows[-1]
260260
rows[-1:]
261261

262-
self.assertEqual(len(w), 4)
263-
self.assertIn("__table_name_case_sensitive__ will be removed in 4.0.", str(w[0].message))
264-
self.assertIn("__table_name_case_sensitive__ will be removed in 4.0.", str(w[1].message))
262+
# Asyncio complains loudly about old syntax on python 3.7+, so get rid of all of those
263+
relevant_warnings = [warn for warn in w if "with (yield from lock)" not in str(warn.message)]
264+
265+
self.assertEqual(len(relevant_warnings), 4)
266+
self.assertIn("__table_name_case_sensitive__ will be removed in 4.0.", str(relevant_warnings[0].message))
267+
self.assertIn("__table_name_case_sensitive__ will be removed in 4.0.", str(relevant_warnings[1].message))
265268
self.assertIn("ModelQuerySet indexing with negative indices support will be removed in 4.0.",
266-
str(w[2].message))
269+
str(relevant_warnings[2].message))
267270
self.assertIn("ModelQuerySet slicing with negative indices support will be removed in 4.0.",
268-
str(w[3].message))
271+
str(relevant_warnings[3].message))

0 commit comments

Comments
 (0)