mirror of
https://github.com/qdrant/qdrant.git
synced 2026-07-23 11:11:00 -05:00
[ai] test: wait for cluster readiness in flaky e2e test (#9012)
* [ai] test: wait for cluster readiness in flaky e2e test
This commit is contained in:
@@ -38,6 +38,25 @@ class ClientUtils:
|
||||
time.sleep(1)
|
||||
return False
|
||||
|
||||
def wait_for_cluster_ready(self, expected_peers: int, timeout: int = 60) -> bool:
|
||||
"""Wait until consensus has elected a leader, all expected peers are visible, and pending operations have drained."""
|
||||
deadline = time.time() + timeout
|
||||
while time.time() < deadline:
|
||||
try:
|
||||
status = self.client.cluster_status()
|
||||
if (getattr(status, "status", None) == "enabled"
|
||||
and len(status.peers) >= expected_peers
|
||||
and status.raft_info.leader is not None
|
||||
and status.raft_info.pending_operations == 0):
|
||||
print(f"Cluster ready with {len(status.peers)} peers, leader={status.raft_info.leader}")
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
print(f"Waiting for cluster to form ({expected_peers} peers expected)...")
|
||||
time.sleep(0.5)
|
||||
return False
|
||||
|
||||
def wait_for_collection_loaded(self, collection_name: str, timeout: int = 10) -> bool:
|
||||
"""Wait for a specific collection to be loaded."""
|
||||
for _ in range(timeout):
|
||||
|
||||
@@ -11,6 +11,7 @@ class TestSnapshotsInterferenceWithConsensus:
|
||||
"""Test that creating snapshots does not block other operations - https://github.com/qdrant/qdrant/issues/7489."""
|
||||
client = ClientUtils(host=qdrant_compose[0].host, port=qdrant_compose[0].http_port, timeout=10)
|
||||
client.wait_for_server()
|
||||
assert client.wait_for_cluster_ready(expected_peers=3), "Cluster did not become ready within timeout"
|
||||
|
||||
# Create collection and insert points
|
||||
collection_config = {"vectors": {"size": 512, "distance": "Dot"}, "shard_number": 3, "replication_factor": 1, "optimization_config": {"indexing_threshold": 0}}
|
||||
|
||||
Reference in New Issue
Block a user