fix(map): показывать скорость сервисов по короткому окну IPFIX
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 3s
Docker images / frontend-image (push) Successful in 2m14s
Docker images / updater-image (push) Successful in 39s
Docker images / netflow-agent-image (push) Successful in 31s
Docker images / backend-image (push) Successful in 15s
Docker images / publish-release (push) Successful in 11s
Docker images / notify-webhook (push) Successful in 2s
Docker images / prepare-release (push) Successful in 11s
Docker images / backend-test (push) Successful in 3s
Docker images / frontend-image (push) Successful in 2m14s
Docker images / updater-image (push) Successful in 39s
Docker images / netflow-agent-image (push) Successful in 31s
Docker images / backend-image (push) Successful in 15s
Docker images / publish-release (push) Successful in 11s
Docker images / notify-webhook (push) Successful in 2s
This commit is contained in:
1 parent
ed7b1e0350
commit
c44bcd8f59
14 files changed
+261
-120
No files matched your search
@@ -22,7 +22,7 @@ test("live GRE does not hash metrics and probe values retain zero and fractions"
|
||||
})
|
||||
|
||||
test("a filtered topology does not inherit a service's full-network traffic composition", () => {
|
||||
const service = {id: "svc:dns", label: "DNS", category: "DNS", bytes: 100, bps: 10, share: 1,
|
||||
const service = {id: "svc:dns", label: "DNS", category: "DNS", bytes: 100, bps: 10, share: 0.4,
|
||||
trafficTypes: [{transport: "UDP", application: "DNS", bytes: 100}], lastBucketAt: "2026-11-26T18:30:00.000Z"}
|
||||
const edges = ["1", "2"].map(fromId => ({fromId, toId: service.id, bytes: 50, bps: 5, bpsFwd: 5, bpsRev: 0}))
|
||||
const partial = scopeMapDestinations([service], edges, [], id => id === "1").services[0]
|
||||
@@ -31,4 +31,6 @@ test("a filtered topology does not inherit a service's full-network traffic comp
|
||||
assert.equal(partial?.lastBucketAt, undefined)
|
||||
assert.deepEqual(complete?.trafficTypes, service.trafficTypes)
|
||||
assert.equal(complete?.lastBucketAt, service.lastBucketAt)
|
||||
assert.equal(complete.share, 0.4)
|
||||
assert.equal(partial.share, 1)
|
||||
})
|
||||
@@ -31,7 +31,7 @@ test("network map refuses partial GRE and foreign failure/probe contexts",()=>{
|
||||
assert.throws(()=>validateNetworkMapSnapshot([server],{tunnels:[]},{probes:[probe]}),/неизвестному/)
|
||||
})
|
||||
|
||||
import {networkMapFlowSchema,validateNetworkMapDns} from "./network-map-response"
|
||||
import {networkMapFlowSchema,recentMapFlowSchema,validateNetworkMapDns} from "./network-map-response"
|
||||
test("map Flow envelope retains zeros and refuses missing metadata and contradictory totals",()=>{
|
||||
const empty={"hops":[],"live":false,"rangeMinutes":5,"windowSec":300,"totalBytes":0,"namedBytes":0,"unclassifiedBytes":0,"asnLoaded":false,"countryLoaded":false,"services":[],"serviceEdges":[],"servicePaths":[],"countries":[],"countryEdges":[],"countryPaths":[],"countryServiceGroups":[],"mapServiceMinSharePct":5,"dedupApplied":false,"excludeMeshApplied":false,"excludeOverlayApplied":false}
|
||||
assert.equal(networkMapFlowSchema.parse(empty).totalBytes,0)
|
||||
@@ -49,6 +49,11 @@ test("map Flow envelope retains zeros and refuses missing metadata and contradic
|
||||
assert.throws(()=>networkMapFlowSchema.parse(recent))
|
||||
assert.throws(()=>networkMapFlowSchema.parse({...recent,windowSec:120}))
|
||||
assert.throws(()=>networkMapFlowSchema.parse({...recent,includesCurrentMinute:undefined}))
|
||||
assert.equal(recentMapFlowSchema.parse(recent).windowSec,90.125)
|
||||
for (const windowSec of [60,119.999]) assert.equal(recentMapFlowSchema.parse({...recent,windowSec}).windowSec,windowSec)
|
||||
for (const invalid of [empty,{...recent,windowSec:59},{...recent,windowSec:120},{...recent,includesCurrentMinute:undefined},{...recent,sourceWindow:shorter.sourceWindow}]) {
|
||||
assert.throws(()=>recentMapFlowSchema.parse(invalid))
|
||||
}
|
||||
})
|
||||
test("map DNS matches exactly requested names and accepts explicit unresolved null",()=>{
|
||||
assert.deepEqual(validateNetworkMapDns({results:{"router.example":null}},["router.example"]),{"router.example":null})
|
||||
|
||||
@@ -27,11 +27,17 @@ export function validateNetworkMapSnapshot(servers:unknown,gre:unknown,probes:un
|
||||
|
||||
import {flowMapHopsDtoSchema} from "@mmapp/contracts/traffic-flow"
|
||||
import {isIpv4String} from "./gre-endpoint-resolve"
|
||||
export const networkMapFlowSchema = flowMapHopsDtoSchema.required().partial({ sourceWindow: true, interfaceTraffic: true, includesCurrentMinute: true, nodeUsers: true }).refine(data =>
|
||||
const mapFlowResponse = flowMapHopsDtoSchema.required().partial({ sourceWindow: true, interfaceTraffic: true, includesCurrentMinute: true, nodeUsers: true }).refine(data =>
|
||||
data.namedBytes <= data.totalBytes && data.unclassifiedBytes <= data.totalBytes
|
||||
)
|
||||
export const networkMapFlowSchema = mapFlowResponse.refine(data =>
|
||||
!data.includesCurrentMinute && data.windowSec === data.rangeMinutes * 60 && (data.sourceWindow
|
||||
? data.sourceWindow.requestedMinutes === 5 && data.sourceWindow.effectiveMinutes === data.rangeMinutes
|
||||
: data.rangeMinutes === 5) &&
|
||||
data.namedBytes <= data.totalBytes && data.unclassifiedBytes <= data.totalBytes
|
||||
: data.rangeMinutes === 5)
|
||||
)
|
||||
export const recentMapFlowSchema = mapFlowResponse.refine(data =>
|
||||
data.includesCurrentMinute === true && data.rangeMinutes === 1 && data.windowSec >= 60 && data.windowSec < 120 &&
|
||||
(!data.sourceWindow || data.sourceWindow.requestedMinutes === 1 && data.sourceWindow.effectiveMinutes === 1)
|
||||
)
|
||||
export function validateNetworkMapDns(raw:unknown,hosts:string[]){
|
||||
const data=z.object({results:z.record(z.string(),z.string().refine(isIpv4String).nullable())}).parse(raw)
|
||||
|
||||
@@ -53,12 +53,15 @@ export function scopeMapDestinations(
|
||||
bytes += unassigned
|
||||
totals.set(service.id, total)
|
||||
}
|
||||
const shareOfVisible = Boolean(userId) || services.some(service => (totals.get(service.id)?.bytes ?? 0) !== service.bytes)
|
||||
return {
|
||||
shareOfVisible,
|
||||
services: services.flatMap(service => {
|
||||
const total = totals.get(service.id)
|
||||
if (!total) return []
|
||||
const { trafficTypes, serviceEvidence, lastBucketAt, ...destination } = service
|
||||
return [{ ...destination, ...total, share: bytes ? total.bytes / bytes : 0,
|
||||
const visibleShare = bytes ? total.bytes / bytes : 0
|
||||
return [{ ...destination, ...total, share: shareOfVisible ? visibleShare : service.share,
|
||||
...(total.bytes === service.bytes ? { trafficTypes, serviceEvidence, lastBucketAt } : {}) }]
|
||||
}).sort((a, b) => b.bytes - a.bytes || a.label.localeCompare(b.label)),
|
||||
edges: visibleEdges,
|
||||
|
||||
Reference in new issue
Block a user