Skip to content

Commit baf085d

Browse files
committed
use optional kwarg, not a separate function
1 parent 58abbbf commit baf085d

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

tests/integration/standard/test_authentication.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from tests.integration import use_singledc, get_cluster, remove_cluster, PROTOCOL_VERSION, CASSANDRA_IP, \
2222
set_default_cass_ip
23-
from tests.integration.util import assert_quiescent_pool_state, assert_quiescent_pool_state_with_wait
23+
from tests.integration.util import assert_quiescent_pool_state
2424

2525
try:
2626
import unittest2 as unittest
@@ -93,7 +93,7 @@ def test_auth_connect(self):
9393
session = cluster.connect()
9494
try:
9595
self.assertTrue(session.execute('SELECT release_version FROM system.local'))
96-
assert_quiescent_pool_state_with_wait(self, cluster, wait=1)
96+
assert_quiescent_pool_state(self, cluster, wait=1)
9797
for pool in session.get_pools():
9898
connection, _ = pool.borrow_connection(timeout=0)
9999
self.assertEqual(connection.authenticator.server_authenticator_class, 'org.apache.cassandra.auth.PasswordAuthenticator')
@@ -102,7 +102,7 @@ def test_auth_connect(self):
102102
cluster.shutdown()
103103
finally:
104104
root_session.execute('DROP USER %s', user)
105-
assert_quiescent_pool_state_with_wait(self, root_session.cluster, wait=1)
105+
assert_quiescent_pool_state(self, root_session.cluster, wait=1)
106106
root_session.cluster.shutdown()
107107

108108
def test_connect_wrong_pwd(self):

tests/integration/util.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,20 @@
1616
import time
1717

1818

19-
def assert_quiescent_pool_state_with_wait(test_case, cluster, wait):
19+
def assert_quiescent_pool_state(test_case, cluster, wait=None):
2020
"""
21-
This function is useful for waiting before checking the pool state.
22-
assert_quiescent_pool_state checks that none of the requests ids have got lost.
23-
However the callback corresponding to a request_id is called before the request_id
24-
is returned back to the pool, therfore
21+
Checking the quiescent pool state checks that none of the requests ids have
22+
been lost. However, the callback corresponding to a request_id is called
23+
before the request_id is returned back to the pool, therefore
2524
2625
session.execute("SELECT * from system.local")
2726
assert_quiescent_pool_state(self, session.cluster)
2827
29-
might fail because when execute comes back the request_id hasn't yet been
30-
returned to the pool, therefore the wait.
28+
(with no wait) might fail because when execute comes back the request_id
29+
hasn't yet been returned to the pool, therefore the wait.
3130
"""
32-
time.sleep(wait)
33-
assert_quiescent_pool_state(test_case, cluster)
34-
35-
36-
def assert_quiescent_pool_state(test_case, cluster):
31+
if wait is not None:
32+
time.sleep(wait)
3733

3834
for session in cluster.sessions:
3935
pool_states = session.get_pool_state().values()

0 commit comments

Comments
 (0)