chore(test): вынести 14 самодостаточных приёмок из основного набора MCP, объединить шарды

- шард misc: 14 приёмок, которые создают свои серверы и проходят в чистой БД
  (BGP, фильтры, аптайм, путь, артефакты логов, live-трафик, контекст пути,
  management transport, сохранение и CREATE ID); verifyMcpAlertsOutbox зависит от
  состояния основного набора и остался в нём;
- шарды scoped forward+inverse и WireGuard объединены: меньше процессов спорят за CPU;
- acceptance-shard.test.ts при MCP_INTEGRATION_CONTINUE=1 продолжает после отказа
  и перечисляет все упавшие приёмки;
- mcp-host-files: в сообщение отказа добавлен error_code (один нестабильный отказ
  rejected до отправки за 4 прогона, причина не установлена).

Замер: основной набор отдельно 180-277 с (разброс машины до 30%), шарды 93-144 с;
149 строк результатов на месте.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
DenozordecandClaude Opus 5.5 committed 2026-11-19 15:11:47 +07:00
1 parent 171c0e6162
commit 1e96ddac79
5 files changed
+39 -21

No files matched your search

@@ -5,13 +5,13 @@
import { spawn } from 'node:child_process'
import { fileURLToPath } from 'node:url'
// Grouped by measured duration (2026-11-19): each shard ~110-190 s, the primary ~320 s.
// Grouped by measured duration (2026-11-19, after the service speed-ups): each shard ~60-150 s,
// the primary ~220 s. Fewer, fuller shards leave more CPU to the primary.
const shards = {
'scoped-forward': ['acceptScopedRouteCommunitySwitch:forward'],
'scoped-inverse': ['acceptScopedRouteCommunitySwitch:inverse'],
'scoped-forward-inverse': ['acceptScopedRouteCommunitySwitch:forward', 'acceptScopedRouteCommunitySwitch:inverse'],
'scoped-route-ai': ['acceptScopedRouteCommunitySwitch:route-ai'],
'wireguard-create': ['acceptWireguardInterfaceCreation', 'acceptRouteCommunityContextMcp', 'acceptWireguardPeerCreation'],
'wireguard-change': ['acceptWireguardInterfaceUpdate', 'acceptWireguardImport'],
wireguard: ['acceptWireguardInterfaceCreation', 'acceptRouteCommunityContextMcp', 'acceptWireguardPeerCreation', 'acceptWireguardInterfaceUpdate', 'acceptWireguardImport'],
misc: ['verifyMcpBgpExport', 'verifyMcpBgpFilterBinding', 'verifyMcpBgpCommunityPolicy', 'verifyMcpBgpPrefixes', 'verifyMcpFilterWrites', 'verifyMcpUptimeOverview', 'verifyMcpPathCompletion', 'verifyMcpLogArtifacts', 'verifyMcpFlowLive', 'verifyMcpControlPathContext', 'acceptManagementTransport', 'acceptRouteCommunityContextCompatibilityMcp', 'acceptNativeConservation', 'acceptNativeCreateId'],
'overlay-ipsec': ['verifyMcpFlowOverlay', 'acceptWireguardInterfaceDeletion', 'acceptIpsecPeerDeletion', 'acceptIpsecUserDeletion', 'acceptIpsecCertificateDeletion', 'acceptIpsecPeerUpdate'],
}
const harness = fileURLToPath(new URL('./test-mcp-postgres.mjs', import.meta.url))
@@ -13,7 +13,11 @@ try {
await updateMcpSettings({ enabled: true }, actor)
for (const name of names) {
const started = performance.now()
await ACCEPTANCE_SHARDS[name](actor)
try { await ACCEPTANCE_SHARDS[name](actor) } catch (error) {
// MCP_INTEGRATION_CONTINUE=1 lists every failing acceptance in one run, like integration.test.ts.
if (process.env.MCP_INTEGRATION_CONTINUE !== "1") throw error
console.error(`✗ shard ${name}: ${error instanceof Error ? error.stack ?? error.message : String(error)}`); process.exitCode = 1; continue
}
console.log(`✓ shard ${name} ${((performance.now() - started) / 1000).toFixed(1)}s`)
}
} finally {
@@ -19,6 +19,20 @@ export const ACCEPTANCE_SHARDS: Record<string, (actor: AuthUser) => Promise<unkn
acceptIpsecUserDeletion: async actor => (await import("./ipsec-user-delete-acceptance.js")).acceptIpsecUserDeletion(actor),
acceptIpsecCertificateDeletion: async actor => (await import("./ipsec-certificate-delete-acceptance.js")).acceptIpsecCertificateDeletion(actor),
acceptIpsecPeerUpdate: async actor => (await import("./ipsec-peer-update-acceptance.js")).acceptIpsecPeerUpdate(actor),
verifyMcpBgpExport: async actor => (await import("../../test/mcp-bgp-export.js")).verifyMcpBgpExport(actor),
verifyMcpBgpFilterBinding: async actor => (await import("../../test/mcp-bgp-filter-binding.js")).verifyMcpBgpFilterBinding(actor),
verifyMcpBgpCommunityPolicy: async actor => (await import("../../test/mcp-bgp-community-policy.js")).verifyMcpBgpCommunityPolicy(actor),
verifyMcpBgpPrefixes: async actor => (await import("../../test/mcp-bgp-prefixes.js")).verifyMcpBgpPrefixes(actor),
verifyMcpFilterWrites: async actor => (await import("../../test/mcp-filter-write.js")).verifyMcpFilterWrites(actor),
verifyMcpUptimeOverview: async actor => (await import("../../test/mcp-uptime-overview.js")).verifyMcpUptimeOverview(actor),
verifyMcpPathCompletion: async actor => (await import("../../test/mcp-path-completion.js")).verifyMcpPathCompletion(actor),
verifyMcpLogArtifacts: async actor => (await import("../../test/mcp-log-artifacts.js")).verifyMcpLogArtifacts(actor),
verifyMcpFlowLive: async actor => (await import("../../test/mcp-flow-live.js")).verifyMcpFlowLive(actor),
verifyMcpControlPathContext: async actor => (await import("./control-path-context-acceptance.js")).verifyMcpControlPathContext(actor),
acceptManagementTransport: async actor => (await import("./management-transport-acceptance.js")).acceptManagementTransport(actor),
acceptRouteCommunityContextCompatibilityMcp: async actor => (await import("./routing-community-context-compatibility-acceptance.js")).acceptRouteCommunityContextCompatibilityMcp(actor),
acceptNativeConservation: async actor => (await import("./native-conservation-acceptance.js")).acceptNativeConservation(actor),
acceptNativeCreateId: async actor => (await import("./native-create-id-acceptance.js")).acceptNativeCreateId(actor),
}
/** Acceptances the primary run may skip: a listed name, or a name whose every `name:part` is listed.
+14 -14
View File
@@ -1325,20 +1325,20 @@ try {
const beforeTrafficHistoryCalls = catalogCalls
await (await import("../../test/mcp-traffic-history.js")).verifyMcpTrafficHistory(actor)
await (await import("../../test/mcp-user-traffic-history.js")).verifyMcpUserTrafficHistory(actor)
await (await import("../../test/mcp-bgp-export.js")).verifyMcpBgpExport(actor)
await (await import("../../test/mcp-bgp-filter-binding.js")).verifyMcpBgpFilterBinding(actor)
await (await import("../../test/mcp-bgp-community-policy.js")).verifyMcpBgpCommunityPolicy(actor)
await (await import("../../test/mcp-bgp-prefixes.js")).verifyMcpBgpPrefixes(actor)
await shardable("verifyMcpBgpExport")
await shardable("verifyMcpBgpFilterBinding")
await shardable("verifyMcpBgpCommunityPolicy")
await shardable("verifyMcpBgpPrefixes")
await (await import("../../test/mcp-filter-shared.js")).verifySharedFilterWrites()
await (await import("../../test/mcp-filter-write.js")).verifyMcpFilterWrites(actor)
await (await import("../../test/mcp-uptime-overview.js")).verifyMcpUptimeOverview(actor)
await shardable("verifyMcpFilterWrites")
await shardable("verifyMcpUptimeOverview")
await (await import("../../test/mcp-network-hosts.js")).verifyMcpNetworkHosts(actor)
assert.equal(catalogCalls, beforeTrafficHistoryCalls)
await (await import("../../test/mcp-sidebar-counts.js")).verifyMcpSidebarCounts(actor, () => catalogCalls)
countCatalogCalls = false
const { preflightPaths } = await import("./ecmp-preflight.js")
await (await import("../../test/mcp-path-completion.js")).verifyMcpPathCompletion(actor)
await (await import("../../test/mcp-log-artifacts.js")).verifyMcpLogArtifacts(actor)
await shardable("verifyMcpPathCompletion")
await shardable("verifyMcpLogArtifacts")
await (await import("../../test/mcp-alerts-outbox.js")).verifyMcpAlertsOutbox(actor)
preflightFixtures = Object.fromEntries(Object.values(preflightPaths("ipv4")).map(path => ["/rest" + path, []]))
preflightFixtures["/rest/ip/route"] = [1, 2].map(index => ({ ".id": `*p${index}`, "dst-address": "192.0.2.0/24", gateway: `192.0.2.${index}`, "immediate-gw": `192.0.2.${index}%same-gre`, "routing-table": "main", distance: "10", active: "true", disabled: "false" }))
@@ -1737,7 +1737,7 @@ try {
await shardable("acceptWireguardPeerCreation")
await (await import("../../test/mcp-flow-analytics.js")).verifyMcpFlowAnalytics(actor)
await (await import("../../test/mcp-flow-map.js")).verifyMcpFlowMap(actor)
await (await import("../../test/mcp-flow-live.js")).verifyMcpFlowLive(actor)
await shardable("verifyMcpFlowLive")
await shardable("verifyMcpFlowOverlay")
await (await import("../../test/mcp-acme-test.js")).verifyMcpAcmeTest(actor)
await (await import("../../test/mcp-acme-settings.js")).verifyMcpAcmeSettings(actor)
@@ -2985,7 +2985,7 @@ try {
const fixtureSchedulerWasPaused = fixtureScheduler.isSchedulerJobsPaused()
await fixtureScheduler.pauseSchedulerJobsAndWait()
try {
await soft("verifyMcpControlPathContext", async () => (await import("./control-path-context-acceptance.js")).verifyMcpControlPathContext(actor))
await shardable("verifyMcpControlPathContext")
await shardable("acceptScopedRouteCommunitySwitch")
await soft("verifyMcpTerminalDiagnostics", async () => (await import("../../test/mcp-terminal-diagnostics.js")).verifyMcpTerminalDiagnostics(actor, app))
await soft("verifyMcpEventsBatch", async () => (await import("../../test/mcp-events-batch.js")).verifyMcpEventsBatch(actor, app))
@@ -2999,9 +2999,9 @@ try {
await shardable("acceptIpsecUserDeletion")
await shardable("acceptIpsecCertificateDeletion")
await shardable("acceptIpsecPeerUpdate")
await soft("acceptManagementTransport", async () => (await import("./management-transport-acceptance.js")).acceptManagementTransport(actor))
await shardable("acceptManagementTransport")
await soft("verifyMcpFlowPurge", async () => (await import("../../test/mcp-flow-purge.js")).verifyMcpFlowPurge(actor))
await soft("acceptRouteCommunityContextCompatibilityMcp", async () => (await import("./routing-community-context-compatibility-acceptance.js")).acceptRouteCommunityContextCompatibilityMcp(actor))
await shardable("acceptRouteCommunityContextCompatibilityMcp")
} finally { if (!fixtureSchedulerWasPaused) fixtureScheduler.resumeSchedulerJobs() }
const client = new Client({ name: "integration", version: "1.0.0" })
try {
@@ -3886,8 +3886,8 @@ try {
await invalidateMcpAccess()
await assert.rejects(authenticateMcpToken(rotated.token))
console.log("✓ Immediate pause and external-generation invalidation")
await soft("acceptNativeConservation", async () => (await import("./native-conservation-acceptance.js")).acceptNativeConservation(actor))
await soft("acceptNativeCreateId", async () => (await import("./native-create-id-acceptance.js")).acceptNativeCreateId(actor))
await shardable("acceptNativeConservation")
await shardable("acceptNativeCreateId")
} finally {
// Teardown diagnostics: if a step hangs, name it and the live handles instead of waiting silently.
let step = "scheduler"
+1 -1
View File
@@ -26,7 +26,7 @@ export async function verifyMcpHostFiles(actor: AuthUser, app: FastifyInstance)
const prepare=()=>invokeMcpTool(principal,"mm_netflow_host_files_export_plan",{}) as Promise<{planId:string;state:string}>
const wait=async(id:string)=>{
for(let n=0;n<600;n++){
const row=(await pool.query("SELECT state,result FROM mcp_operations WHERE id=$1",[id])).rows[0]
const row=(await pool.query("SELECT state,result,error_code FROM mcp_operations WHERE id=$1",[id])).rows[0]
if(!["pending","running"].includes(row.state))return row
await delay(25)
}