fix: account for HTTP/S traffic and separate network curves

This commit is contained in:
2026-11-02 14:13:26 +08:00
parent 5291b2ab72
commit 4c3b7ead4e
10 changed files with 336 additions and 13 deletions
+14
View File
@@ -9,6 +9,9 @@ for (const hours of [1, 6, 24] as MonitoringRange[]) {
assert.equal(snapshot.timestamps[0], end - hours * 3_600_000)
assert.equal(snapshot.timestamps.at(-1), end)
assert.equal(snapshot.panels.length, 6)
assert.equal(snapshot.panels[0]!.series[0]!.id, 'http4')
assert.equal(snapshot.panels[1]!.series[0]!.id, 'http6')
assert.equal(snapshot.panels[0]!.series[0]!.labelKey, 'monitor.series.http')
for (const panel of snapshot.panels) {
for (const series of panel.series) {
assert.equal(series.values.length, snapshot.timestamps.length)
@@ -34,4 +37,15 @@ assert.deepEqual(paths[1]!.plottedValues, [1, 3, null, 4, 5], 'Unknown stacked b
assert.deepEqual(metricPaths([upper], 5, true, coordinate)[0]!.plottedValues, upper.values, 'Hiding a lower series must rebuild the stack')
assert.deepEqual(metricStatistics([null, 0, 4, null]), { mean: 2, latest: null, max: 4 }, 'Missing samples must not become zero or stale latest values')
assert.deepEqual(metricStatistics([null, null]), { mean: 0, latest: null, max: 0 })
for (const family of [4, 6]) {
const panel = createMonitoringSnapshot(end, 24).panels[family === 4 ? 0 : 1]!
panel.series = [series(`http${family}`, [null, null, null, .1, .2]), series(`rsync${family}`, [.2, .3, .4, .5, .6])]
assert.equal(panel.stacked, false, 'Network protocols must use independent rates')
const networkPaths = metricPaths(panel.series, 5, panel.stacked, coordinate)
assert.deepEqual(networkPaths[0]!.plottedValues, [null, null, null, .1, .2], 'HTTP/S coordinates must match its rate, not the combined traffic')
assert.deepEqual(networkPaths[1]!.plottedValues, [.2, .3, .4, .5, .6], 'New HTTP/S collection must not hide existing rsync history')
assert.equal(networkPaths[1]!.line, 'M0,0.2 L1,0.3 L2,0.4 L3,0.5 L4,0.6')
const httpOnly = metricPaths([panel.series[0]!], 5, panel.stacked, coordinate)
assert.deepEqual(httpOnly[0]!.plottedValues, networkPaths[0]!.plottedValues, 'Hiding rsync must not move the HTTP/S curve')
}
console.log('Monitoring check passed: deterministic windows, statistics, missing samples, line/fill gaps, stack limits and disk capacities.')