fix(test): отдавать /interface с интерфейсом шаблона в сценарии passive OSPF
Устаревшая фикстура, не дефект продукта. Сценарий mixed passive добавляет непассивный шаблон OSPF на fixture-loop без Full-соседа, а мок RouterOS в этой точке отдаёт пустой /interface. resolveOspfInterfaceSelectors закрыто отказывает (STATE_CONFLICT), если имя интерфейса шаблона нельзя подтвердить ни соседом, ни инвентарём, — это корректная защита. На реальном маршрутизаторе интерфейс шаблона есть в /interface, поэтому для этого цикла мок отдаёт инвентарь с fixture-gre и fixture-loop. Ожидание теста (шаблон без Full не блокирует и не входит в план) не менялось. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
73af143a53
commit
84e34da4f9
1 file changed
+6
@@ -61,6 +61,8 @@ let ospfFixtures = false
|
||||
let ospfAnalysisFixtures = false, ospfAnalysisDispatches = 0, ospfAnalysisNativeRequests = 0
|
||||
let ospfAfterCostPatch: (() => void) | undefined
|
||||
let ospfAnalysisExtraNeighbors: Record<string, string>[] = []
|
||||
// Native /interface inventory for templates whose interface has no Full neighbor.
|
||||
let ospfAnalysisInterfaces: Record<string, string>[] | 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" }]
|
||||
|
||||
Reference in new issue
Block a user