'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.
Should fail with wait_for_complete=True, succeed for False.
@since 3.0.0
@jira_ticket PYTHON-438
@expected_result tracing comes back sans duration
@test_category tracing'

@notwindows
def test_incomplete_query_trace(self):

    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()
    self.assertEqual(len(response_future._query_traces), 1)
    trace = response_future._query_traces[0]
    self.assertTrue(self._wait_for_trace_to_populate(trace.trace_id))
    delete_statement = SimpleStatement('DELETE    duration    FROM    system_traces.sessions    WHERE    session_id    =    {0}'.format(trace.trace_id), consistency_level=ConsistencyLevel.ALL)
    self.session.execute(delete_statement)
    self.assertTrue(self._wait_for_trace_to_delete(trace.trace_id))
    self.assertRaises(TraceUnavailable, trace.populate, max_wait=0.2, wait_for_complete=True)
    self.assertFalse(trace.events)
    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.assertTrue(trace.events)
    self.assertIsNotNone(trace.started_at)
