MCPcopy Create free account
hub / github.com/apache/cassandra-python-driver / assert_quiescent_pool_state

Function assert_quiescent_pool_state

tests/integration/util.py:23–59  ·  view source on GitHub ↗

Checking the quiescent pool state checks that none of the requests ids have been lost. However, the callback corresponding to a request_id is called before the request_id is returned back to the pool, therefore session.execute("SELECT * from system.local") assert_quiescent_pool

(test_case, cluster, wait=None)

Source from the content-addressed store, hash-verified

21
22
23def assert_quiescent_pool_state(test_case, cluster, wait=None):
24 """
25 Checking the quiescent pool state checks that none of the requests ids have
26 been lost. However, the callback corresponding to a request_id is called
27 before the request_id is returned back to the pool, therefore
28
29 session.execute("SELECT * from system.local")
30 assert_quiescent_pool_state(self, session.cluster)
31
32 (with no wait) might fail because when execute comes back the request_id
33 hasn't yet been returned to the pool, therefore the wait.
34 """
35 if wait is not None:
36 time.sleep(wait)
37
38 for session in cluster.sessions:
39 pool_states = session.get_pool_state().values()
40 test_case.assertTrue(pool_states)
41
42 for state in pool_states:
43 test_case.assertFalse(state['shutdown'])
44 test_case.assertGreater(state['open_count'], 0)
45 no_in_flight = all((i == 0 for i in state['in_flights']))
46 orphans_and_inflights = zip(state['orphan_requests'], state['in_flights'])
47 all_orphaned = all((len(orphans) == inflight for (orphans, inflight) in orphans_and_inflights))
48 test_case.assertTrue(no_in_flight or all_orphaned)
49
50 for holder in cluster.get_connection_holders():
51 for connection in holder.get_connections():
52 # all ids are unique
53 req_ids = connection.request_ids
54 orphan_ids = connection.orphaned_request_ids
55 test_case.assertEqual(len(req_ids), len(set(req_ids)))
56 test_case.assertEqual(connection.highest_request_id, len(req_ids) + len(orphan_ids) - 1)
57 test_case.assertEqual(connection.highest_request_id, max(chain(req_ids, orphan_ids)))
58 if PROTOCOL_VERSION < 3:
59 test_case.assertEqual(connection.highest_request_id, connection.max_request_id)

Calls 6

setFunction · 0.85
sleepMethod · 0.80
get_pool_stateMethod · 0.80
valuesMethod · 0.45
get_connectionsMethod · 0.45