/** * Connection Pooling Integration Tests * Tests connection pooling behavior and configuration */ import { describe, it, expect } from "vitest"; import { EmbexClient } from "../../index"; import { randomUUID } from "crypto"; describe("Connection Pooling", () => { it("should create client successfully", async () => { const client = new EmbexClient("qdrant", "http://localhost:6334", null); expect(client).toBeDefined(); const collection = client.collection("pool_test"); expect(collection).toBeDefined(); }); it("should reuse connections for multiple operations", async () => { const client = new EmbexClient("qdrant", "http://localhost:6334"); const collection = client.collection("pool_reuse_test"); try { await collection.deleteCollection(); } catch (e) {} await collection.create(128, "cosine"); const operations = Array.from({ length: 10 }, async () => { const vector = Array.from({ length: 128 }, () => Math.random()); try { await collection.query(vector, { limit: 1 }); } catch (e) {} }); await Promise.all(operations); }); it("should handle concurrent requests efficiently", async () => { const client = new EmbexClient("qdrant", "http://localhost:6334", null); const collection = client.collection("pool_concurrent_test"); try { await collection.deleteCollection(); } catch (e) {} await collection.create(128, "cosine"); const points = Array.from({ length: 5 }, () => ({ id: randomUUID(), vector: Array.from({ length: 128 }, () => Math.random()), })); await collection.insert(points); const queries = Array.from({ length: 20 }, async () => { const vector = Array.from({ length: 128 }, () => Math.random()); try { await collection.query(vector, { limit: 5 }); } catch (e) {} }); await Promise.all(queries); }); });