chore(ux): измерить матрицу WAN и расчёт назначения проб

This commit is contained in:
Denozordec committed 2026-10-04 21:52:05 +07:00
1 parent 28e2d38ee6
commit b3da4216e6
6 files changed
+65 -2

No files matched your search

@@ -0,0 +1,30 @@
import { test, expect } from "@playwright/test"
import { writeFileSync } from "node:fs"
import { optimizerServersSchema } from "../../lib/route-optimizer-response"
for (const [wanCount,jhCount] of [[1000,1],[10,100]]) {
test(`Матрица WAN${wanCount} × JH${jhCount} без Exit`, async ({page},info) => {
test.setTimeout(90000)
const common = { host: "192.0.2.1", enabled: true, status: "online", latency: 10, country: "RU", site: "TEST", model: "CHR" }
const servers = optimizerServersSchema.parse([
{ ...common, id: 1, name: "Домашний роутер", type: "home-router", wanUplinks: Array.from({ length: wanCount }, (_, i) => ({ id: `wan${i+1}`, name: `WAN${i+1}`, isp: "ISP", iface: `ether${i+1}`, ip: `198.51.100.${i+1}`, maxDl: 100, maxUl: 100 })) },
...Array.from({ length: jhCount }, (_, i) => ({ ...common, id: i+2, name: `Jump ${i+1}`, type: "jump-host" })),
])
const writes: string[] = []
await page.route("**/health", r => r.fulfill({ json: { ok: true } }))
await page.route("**/api/**", r => {
const path = new URL(r.request().url()).pathname
if (r.request().method() !== "GET" && !path.endsWith("/preview")) writes.push(path)
return r.fulfill({ json: path === "/api/auth/config" ? { required: false } : path === "/api/servers" ? servers : path === "/api/filters/rules" ? { rulesets: [] } : path === "/api/uptime/speed-probes" ? { probes: [] } : path === "/api/ospf/catalog" ? { interfaces: [], instances: [], neighbors: [], bfdSessions: [], routes: [], failures: [] } : path.endsWith("/ospf/optimize/preview") ? { serverId: 1, serverName: "Домашний роутер", pingWeight: 60, interfacesTotal: 0, changedCount: 0, unchangedCount: 0, interfaces: [], changes: [] } : {} })
})
const started=Date.now(); await page.goto("/route-optimizer?server=1&keep=1")
const table=page.getByRole("table").filter({hasText:"WAN-аплинк"})
await expect(table.locator("tr[data-row-id]")).toHaveCount(wanCount)
const profile={wanCount,jhCount,bytes:Buffer.byteLength(JSON.stringify(servers)),rows:await table.locator("tr[data-row-id]").count(),columns:await table.getByRole("columnheader").count(),tableNodes:await table.locator("*").count(),pageNodes:await page.locator("*").count(),readyMs:Date.now()-started}
console.log("WAN matrix",JSON.stringify(profile)); writeFileSync(info.outputPath("matrix-profile.json"),JSON.stringify(profile,null,2))
expect(writes).toEqual([])
})
}