From 84e34da4f91327ce87c13a371d257ab4aabe25de Mon Sep 17 00:00:00 2001 From: Denozordec Date: Sun, 15 Nov 2026 22:19:14 +0700 Subject: [PATCH] =?UTF-8?q?fix(test):=20=D0=BE=D1=82=D0=B4=D0=B0=D0=B2?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20/interface=20=D1=81=20=D0=B8=D0=BD=D1=82?= =?UTF-8?q?=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81=D0=BE=D0=BC=20=D1=88=D0=B0?= =?UTF-8?q?=D0=B1=D0=BB=D0=BE=D0=BD=D0=B0=20=D0=B2=20=D1=81=D1=86=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=D1=80=D0=B8=D0=B8=20passive=20OSPF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Устаревшая фикстура, не дефект продукта. Сценарий mixed passive добавляет непассивный шаблон OSPF на fixture-loop без Full-соседа, а мок RouterOS в этой точке отдаёт пустой /interface. resolveOspfInterfaceSelectors закрыто отказывает (STATE_CONFLICT), если имя интерфейса шаблона нельзя подтвердить ни соседом, ни инвентарём, — это корректная защита. На реальном маршрутизаторе интерфейс шаблона есть в /interface, поэтому для этого цикла мок отдаёт инвентарь с fixture-gre и fixture-loop. Ожидание теста (шаблон без Full не блокирует и не входит в план) не менялось. Co-Authored-By: Claude Opus 5.5 --- backend/src/modules/mcp/integration.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/src/modules/mcp/integration.test.ts b/backend/src/modules/mcp/integration.test.ts index ad40ff8d..c6a152ea 100644 --- a/backend/src/modules/mcp/integration.test.ts +++ b/backend/src/modules/mcp/integration.test.ts @@ -61,6 +61,8 @@ let ospfFixtures = false let ospfAnalysisFixtures = false, ospfAnalysisDispatches = 0, ospfAnalysisNativeRequests = 0 let ospfAfterCostPatch: (() => void) | undefined let ospfAnalysisExtraNeighbors: Record[] = [] +// Native /interface inventory for templates whose interface has no Full neighbor. +let ospfAnalysisInterfaces: Record[] | undefined const ospfAnalysisAddresses = [{ ".id": "*la", interface: "fixture-gre", address: "192.0.2.1/30", disabled: "false", invalid: "false" }] let ospfCostWriteFault = "none" let ospfPassiveWrites = 0, ospfIgnoreUnset = false @@ -557,6 +559,7 @@ const router = createServer((req, res) => { if (interfaceFixtures && req.url === "/rest/interface") { res.setHeader("content-type", "application/json"); res.end(JSON.stringify([{ ".id": "*gre", name: "fixture-gre", type: "gre" }, { ".id": "*fixture", name: "fixture-bridge", type: "bridge" }])); return } + if (ospfAnalysisInterfaces && req.url === "/rest/interface") { res.setHeader("content-type", "application/json"); res.end(JSON.stringify(ospfAnalysisInterfaces)); return } if (interfaceFixtures && req.url?.startsWith("/rest/ip/vrf")) { res.setHeader("content-type", "application/json") if (req.method === "PUT") { @@ -2601,6 +2604,8 @@ try { const dispatchesBeforePassive = ospfAnalysisDispatches fixtureOspf["interface-template"][0].passive = "true" await assert.rejects(invokeMcpTool(graphPrincipal, "mm_ospf_optimizer_plan", { serverId: 1 }), (error: { code?: string }) => error.code === "MEASUREMENT_UNKNOWN", "A passive template cannot become eligible through a stale Full neighbor") + // A real router lists the template's interface in /interface even without a Full neighbor. + ospfAnalysisInterfaces = [{ ".id": "*gre", name: "fixture-gre", type: "gre-tunnel", disabled: "false" }, { ".id": "*loop", name: "fixture-loop", type: "bridge", disabled: "false" }] for (const passive of ["true", "false"]) { fixtureOspf["interface-template"] = [...structuredClone(costBaseline), { ...costBaseline[0], ".id": "*passive", interfaces: "fixture-loop", passive }] const mixedPassive = await invokeMcpTool(graphPrincipal, "mm_ospf_optimizer_plan", { serverId: 1 }) as { planId: string } @@ -2609,6 +2614,7 @@ try { assert.deepEqual(mixedEvidence.before.ranking.map(row => row.interface), [costBaseline[0].interfaces]) assert.deepEqual(mixedEvidence.steps.map(row => row.step.id), [costBaseline[0][".id"]]) } + ospfAnalysisInterfaces = undefined assert.equal(ospfAnalysisDispatches, dispatchesBeforePassive, "Passive or no-Full templates with unknown BFD cannot block or enter the selected GRE plan") fixtureOspf["interface-template"] = [{ ...costBaseline[0], interfaces: "fixture-loop" }] ospfAnalysisExtraNeighbors = [{ ".id": "*loop", instance: "fixture-ospf", interface: "fixture-loop", state: "Full", "router-id": "192.0.2.2", address: "192.0.2.2" }]