Adding test for python-438
This commit is contained in:
@@ -392,6 +392,10 @@ class BasicKeyspaceUnitTestCase(unittest.TestCase):
|
|||||||
def function_table_name(self):
|
def function_table_name(self):
|
||||||
return self._testMethodName.lower()
|
return self._testMethodName.lower()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def keyspace_table_name(self):
|
||||||
|
return "{0}.{1}".format(self.keyspace_name, self._testMethodName.lower())
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def drop_keyspace(cls):
|
def drop_keyspace(cls):
|
||||||
execute_with_long_wait_retry(cls.session, "DROP KEYSPACE {0}".format(cls.ks_name))
|
execute_with_long_wait_retry(cls.session, "DROP KEYSPACE {0}".format(cls.ks_name))
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ except ImportError:
|
|||||||
|
|
||||||
from cassandra import ConsistencyLevel
|
from cassandra import ConsistencyLevel
|
||||||
from cassandra.query import (PreparedStatement, BoundStatement, SimpleStatement,
|
from cassandra.query import (PreparedStatement, BoundStatement, SimpleStatement,
|
||||||
BatchStatement, BatchType, dict_factory)
|
BatchStatement, BatchType, dict_factory, TraceUnavailable)
|
||||||
from cassandra.cluster import Cluster
|
from cassandra.cluster import Cluster
|
||||||
from cassandra.policies import HostDistance
|
from cassandra.policies import HostDistance
|
||||||
|
|
||||||
@@ -138,6 +138,40 @@ class QueryTests(BasicSharedKeyspaceUnitTestCase):
|
|||||||
self.assertIsNotNone(client_ip, "Client IP was not set in trace with C* >= 2.2")
|
self.assertIsNotNone(client_ip, "Client IP was not set in trace with C* >= 2.2")
|
||||||
self.assertTrue(pat.match(client_ip), "Client IP from trace did not match the expected value")
|
self.assertTrue(pat.match(client_ip), "Client IP from trace did not match the expected value")
|
||||||
|
|
||||||
|
def test_incomplete_query_trace(self):
|
||||||
|
"""
|
||||||
|
Tests to ensure that partial tracing works.
|
||||||
|
|
||||||
|
Creates a table and runs an insert. Then attempt a query with tracing enabled. After the query is run we delete the
|
||||||
|
duration information associated with the trace, and attempt to populate the tracing information. We should receive tracing
|
||||||
|
information without any trace enabled.
|
||||||
|
|
||||||
|
@since 3.0.0
|
||||||
|
@jira_ticket PYTHON-438
|
||||||
|
@expected_result tracing comes back sans duration
|
||||||
|
|
||||||
|
@test_category tracing
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Create table and run insert, then select
|
||||||
|
self.session.execute("CREATE TABLE {0} (k INT, i INT, PRIMARY KEY(k, i))".format(self.keyspace_table_name))
|
||||||
|
self.session.execute("INSERT INTO {0} (k, i) VALUES (0, 1)".format(self.keyspace_table_name))
|
||||||
|
response_future = self.session.execute_async("SELECT i FROM {0} WHERE k=0".format(self.keyspace_table_name), trace=True)
|
||||||
|
response_future.result()
|
||||||
|
|
||||||
|
# Delete trace duration from latest select session.
|
||||||
|
DELETE_TRACES = "DELETE duration FROM system_traces.sessions WHERE session_id = {0}"
|
||||||
|
|
||||||
|
for trace in response_future._query_traces:
|
||||||
|
self.session.execute(DELETE_TRACES.format(trace.trace_id))
|
||||||
|
self.assertRaises(TraceUnavailable,trace.populate(wait_for_complete=False))
|
||||||
|
self.assertIsNone(trace.duration)
|
||||||
|
self.assertIsNotNone(trace.trace_id)
|
||||||
|
self.assertIsNotNone(trace.request_type)
|
||||||
|
self.assertIsNotNone(trace.parameters)
|
||||||
|
self.assertIsNotNone(trace.events)
|
||||||
|
self.assertIsNotNone(trace.started_at)
|
||||||
|
|
||||||
def test_column_names(self):
|
def test_column_names(self):
|
||||||
"""
|
"""
|
||||||
Test to validate the columns are present on the result set.
|
Test to validate the columns are present on the result set.
|
||||||
@@ -295,7 +329,6 @@ class BatchStatementTests(BasicSharedKeyspaceUnitTestCase):
|
|||||||
self.cluster.set_core_connections_per_host(HostDistance.LOCAL, 1)
|
self.cluster.set_core_connections_per_host(HostDistance.LOCAL, 1)
|
||||||
self.session = self.cluster.connect()
|
self.session = self.cluster.connect()
|
||||||
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.cluster.shutdown()
|
self.cluster.shutdown()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user