tests: drop unnecessary time.sleep#774
Conversation
|
CI speed measurement for this change set (focused on Integration tests):
Compared runs
Results
Head-to-head against the most recent baseline run (26m55s):
Additional signal from matrix jobs:
So this PR appears to reduce integration CI time by roughly 17–18% while keeping checks green. |
| ) | ||
| time.sleep(5) | ||
| time.sleep(2) # allow iptables rule to take effect | ||
| try: | ||
| self.query_data(self.session, verify_in_tracing=False) |
There was a problem hiding this comment.
Commit: "tests: replace medium-priority time.sleep() calls with polling"
This doesn't introduce polling, just decreases sleep. Why? Are you sure it won't become flaky?
There was a problem hiding this comment.
2 seconds is more than enough for driver to drop all the connections.
But you have a good point, could have poolling here, let me add.
The time.sleep(10) in setup_keyspace() is redundant because callers already ensure the cluster is fully ready before calling it: - use_cluster() calls start_cluster_wait_for_up() which uses wait_for_binary_proto=True + wait_other_notice=True, then wait_for_node_socket() per node - External cluster path (wait=False) had no sleep anyway Remove the wait parameter entirely and its associated sleep, saving 10s per cluster startup.
Replace fixed sleeps with condition-based polling to speed up tests: - simulacron/utils.py: replace 5s sleep with HTTP endpoint polling (max 15s timeout, typically <1s) - test_authentication.py: replace 10s sleep with auth readiness poll that tries connecting with default credentials - upgrade/__init__.py: replace 10s auth sleep with same polling pattern - upgrade/test_upgrade.py: replace 3x 20s sleeps (60s total) with control connection readiness polling Total potential saving: ~95s of unconditional waiting per test run.
Replace fixed sleeps with condition-based polling in four test files: - test_shard_aware.py: replace 25s of sleeps (5+10+5+5) with wait_until_not_raised polling for reconnection after shard connection close and iptables blocking - test_metrics.py: replace 15s of sleeps (5+5+5) with polling for cluster recovery and node-down detection - test_tablets.py: replace 13s of sleeps (3+10) with polling for metadata refresh and decommission completion - simulacron/test_connection.py: replace 20s of sleeps (10+10) with polling for quiescent pool state Total potential saving: ~73s of unconditional waiting.
… for invalidation The tablet tests were intermittently failing because: 1. get_query_trace() used the default 2s max_wait, which is too short under resource pressure (--smp 2). Increased to 10s. 2. test_tablets_invalidation_decommission_non_cc_node used a fixed time.sleep(2) hoping tablet metadata invalidation would complete. Replaced with wait_until polling for the tablet record to be purged (0.5s delay, 20 attempts = 10s budget).
- test_cluster.py: replace sleep(1) x10 iterations with connect(wait_for_all_pools=True) for deterministic pool readiness - test_query.py: replace sleep(5) with wait_until polling for 'Preparing all known prepared statements' log message - test_connection.py: replace sleep(2) with wait_until polling for host_down listener notification
9e56125 to
4b73e63
Compare
|
Updated per request: I squashed the new New commit sequence on this PR branch:
|
Point of this PR
time.sleep()removal/optimization work fromimprove/integration-test-performance-prwithout bringing in unrelated integration-test refactors.From / To
improve/integration-test-performance-prmastercherry-pick-time-sleep-optimizationsExtracted commits
70cc3ffd3- tests: remove redundant 10s sleep from setup_keyspace()0ebdd8dbe- tests: replace high-priority time.sleep() calls with polling8ff92d5b9- tests: replace medium-priority time.sleep() calls with pollingea8ecf800- tests: fix flaky tablet tests by increasing trace timeout and polling for invalidatione8b729f3e- tests: replace fixed time.sleep() calls with polling (~17s saving)