'Ensure trace can be requested for async and non-async queries'

def test_trace(self):

    cluster = Cluster(protocol_version=PROTOCOL_VERSION)
    session = cluster.connect()
    def check_trace(trace):
        self.assertIsNotNone(trace.request_type)
        self.assertIsNotNone(trace.duration)
        self.assertIsNotNone(trace.started_at)
        self.assertIsNotNone(trace.coordinator)
        self.assertIsNotNone(trace.events)
    result = session.execute('SELECT    *    FROM    system.local', trace=True)
    check_trace(result.get_query_trace())
    query = 'SELECT    *    FROM    system.local'
    statement = SimpleStatement(query)
    result = session.execute(statement, trace=True)
    check_trace(result.get_query_trace())
    query = 'SELECT    *    FROM    system.local'
    statement = SimpleStatement(query)
    result = session.execute(statement)
    self.assertIsNone(result.get_query_trace())
    statement2 = SimpleStatement(query)
    future = session.execute_async(statement2, trace=True)
    future.result()
    check_trace(future.get_query_trace())
    statement2 = SimpleStatement(query)
    future = session.execute_async(statement2)
    future.result()
    self.assertIsNone(future.get_query_trace())
    prepared = session.prepare('SELECT    *    FROM    system.local')
    future = session.execute_async(prepared, parameters=(), trace=True)
    future.result()
    check_trace(future.get_query_trace())
    cluster.shutdown()
