From 896c8ff6b52f3748a1feaad114bb431078164b64 Mon Sep 17 00:00:00 2001 From: BillyOutlast <172061051+BillyOutlast@users.noreply.github.com> Date: Wed, 16 Sep 2026 03:23:11 -0300 Subject: [PATCH] fix(test): stop 2 unit tests from calling a real LAN server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two tests in tests/unit/model-embedding-discovery-and-cache.test.ts made a real HTTP call to the contributor's private Lemonade server (192.168.31.147) with no reachability guard — they failed with a 60s socket timeout on any machine without access to that LAN, including this one. tests/integration/semantic-cache-lemonade.test.ts already gates the same endpoint with an isEndpointReachable() skip; apply the identical pattern here so a unit test never depends on live network access. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --- ...odel-embedding-discovery-and-cache.test.ts | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/unit/model-embedding-discovery-and-cache.test.ts b/tests/unit/model-embedding-discovery-and-cache.test.ts index f2aaed8cc5..68e5fa4e88 100644 --- a/tests/unit/model-embedding-discovery-and-cache.test.ts +++ b/tests/unit/model-embedding-discovery-and-cache.test.ts @@ -12,6 +12,26 @@ import { } from "../../open-sse/services/modelEndpointPolicy.ts"; import { detectTestKind } from "@/lib/api/modelTestRunner"; +// The two "live Lemonade" tests below hit a real embedding server on the +// contributor's private LAN (192.168.31.147) — unreachable from CI or any +// other machine. A unit test must never depend on live network access +// (tests/integration/semantic-cache-lemonade.test.ts already gates the same +// endpoint this way for the integration suite), so both self-skip instead of +// failing when the endpoint isn't reachable. +const LEMONADE_TEST_BASE_URL = "http://192.168.31.147:13305"; + +async function isEndpointReachable(url: string, timeoutMs = 1500): Promise { + try { + const controller = new AbortController(); + const timer = setTimeout(() => controller.abort(), timeoutMs); + const res = await fetch(url, { method: "HEAD", signal: controller.signal }).catch(() => null); + clearTimeout(timer); + return res !== null; + } catch { + return false; + } +} + test("detectModelModality flags Lemonade embeddings model and pulls dimensions and context length", () => { // Lemonade verbatim /v1/models shape for harrier-oss-v1-0.6b const lemonadeRecord = { @@ -119,7 +139,12 @@ test("detectTestKind in modelTestRunner detects embedding test probe for harrier assert.equal(result3.isEmbedding, true); }); -test("test-embedding route validates inputs and generates embeddings via live Lemonade", async () => { +test("test-embedding route validates inputs and generates embeddings via live Lemonade", async (t) => { + const reachable = await isEndpointReachable(LEMONADE_TEST_BASE_URL); + if (!reachable) { + t.skip(`Lemonade server not reachable at ${LEMONADE_TEST_BASE_URL}`); + return; + } const testEmbeddingRoute = await import("../../src/app/api/settings/cache-config/test-embedding/route.ts"); @@ -143,7 +168,12 @@ test("test-embedding route validates inputs and generates embeddings via live Le assert.ok(typeof data.latencyMs === "number" && data.latencyMs > 0); }); -test("test-embedding route automatically resolves connection details from DB when not passed", async () => { +test("test-embedding route automatically resolves connection details from DB when not passed", async (t) => { + const reachable = await isEndpointReachable(LEMONADE_TEST_BASE_URL); + if (!reachable) { + t.skip(`Lemonade server not reachable at ${LEMONADE_TEST_BASE_URL}`); + return; + } const { getDbInstance } = await import("@/lib/db/core"); const testEmbeddingRoute = await import("../../src/app/api/settings/cache-config/test-embedding/route.ts");