Docker images / prepare-release (push) Successful in 10s
Docker images / backend-test (push) Successful in 2m19s
Docker images / frontend-image (push) Successful in 4m47s
Docker images / updater-image (push) Successful in 48s
Docker images / backend-image (push) Successful in 2m53s
Docker images / notify-webhook (push) Skipped
Docker images / publish-release (push) Successful in 13s
Куб IPFIX час+день с AND-слайсами и экраном отчётности /statistics, живой /traffic не меняем. Co-authored-by: Cursor <[email protected]>
72 lines
1.5 KiB
TypeScript
72 lines
1.5 KiB
TypeScript
import assert from "node:assert/strict"
|
|
import {
|
|
bumpFlowFact,
|
|
collectCappedFacts,
|
|
FACT_ASN_TOP,
|
|
FACT_TUPLE_CAP,
|
|
resetFactsForTests,
|
|
} from "./traffic-flow-facts.js"
|
|
|
|
resetFactsForTests()
|
|
bumpFlowFact({
|
|
serverId: 1,
|
|
bucketAt: "2026-09-10T10:00:00.000Z",
|
|
iface: "ether1",
|
|
country: "US",
|
|
service: "https",
|
|
asn: 15169,
|
|
bytes: 100,
|
|
packets: 2,
|
|
})
|
|
bumpFlowFact({
|
|
serverId: 1,
|
|
bucketAt: "2026-09-10T10:00:00.000Z",
|
|
iface: "ether1",
|
|
country: "us",
|
|
service: "https",
|
|
asn: 15169,
|
|
bytes: 50,
|
|
packets: 1,
|
|
})
|
|
const merged = collectCappedFacts()
|
|
assert.equal(merged.length, 1)
|
|
assert.equal(merged[0]?.bytes, 150)
|
|
assert.equal(merged[0]?.country, "US")
|
|
assert.equal(merged[0]?.asn, 15169)
|
|
|
|
resetFactsForTests()
|
|
for (let i = 1; i <= FACT_ASN_TOP + 20; i++) {
|
|
bumpFlowFact({
|
|
serverId: 2,
|
|
bucketAt: "2026-09-10T11:00:00.000Z",
|
|
iface: "ether1",
|
|
country: "DE",
|
|
service: "https",
|
|
asn: i,
|
|
bytes: FACT_ASN_TOP + 21 - i,
|
|
packets: 1,
|
|
})
|
|
}
|
|
const cappedAsn = collectCappedFacts()
|
|
const asns = new Set(cappedAsn.map((r) => r.asn))
|
|
assert.ok(asns.has(0))
|
|
assert.ok(asns.size <= FACT_ASN_TOP + 1)
|
|
|
|
resetFactsForTests()
|
|
for (let i = 0; i < FACT_TUPLE_CAP + 30; i++) {
|
|
bumpFlowFact({
|
|
serverId: 3,
|
|
bucketAt: "2026-09-10T12:00:00.000Z",
|
|
iface: `ether${i % 3}`,
|
|
country: "NL",
|
|
service: `svc-${i}`,
|
|
asn: 1,
|
|
bytes: 10,
|
|
packets: 1,
|
|
})
|
|
}
|
|
const cappedTuples = collectCappedFacts()
|
|
assert.ok(cappedTuples.length <= FACT_TUPLE_CAP + 3)
|
|
|
|
console.log("traffic-flow-facts.test.ts: ok")
|