Latency statistics written once, thresholds read from CONFIG (closes #102)
check / check (push) Successful in 3m30s
check / check (push) Successful in 3m30s
A target's min, max, median and average latency now come from one list of its answers, through latencyStats(), which the summary's figures use too, so the median is written once. latencyHex() and latencyClass() read one table of color limits in CONFIG. The health thresholds, the debug log's length, the gateway check's timeout, the recovery probe's number of hosts and interval, how often the rows are sorted and the delay before the first sparkline resize are CONFIG entries, read where the numbers were. HostState's minLatency(), maxLatency(), averageLatency() and medianLatency() are gone; the statistics test reads historyStats(). Nothing the page does or shows changes. A unit test now covers the summary's figures. Model: opus-5-5
This commit is contained in:
+26
-10
@@ -347,19 +347,35 @@ for (const { history, latencies, statistics } of [
|
||||
},
|
||||
]) {
|
||||
test(`a target's min, max, average and median latency over ${history}`, () => {
|
||||
const host = hostAfter(latencies);
|
||||
assert.deepEqual(
|
||||
{
|
||||
min: host.minLatency(),
|
||||
max: host.maxLatency(),
|
||||
average: host.averageLatency(),
|
||||
median: host.medianLatency(),
|
||||
},
|
||||
statistics,
|
||||
);
|
||||
const { min, max, avg, med } = hostAfter(latencies).historyStats();
|
||||
assert.deepEqual({ min, max, average: avg, median: med }, statistics);
|
||||
});
|
||||
}
|
||||
|
||||
// The summary's figures come from each WAN target's last check, by the same
|
||||
// rules as a target's own: here four answered, one was found unreachable
|
||||
// and the rest have not been checked yet. The median, 22.5, and the
|
||||
// average, 21.25, are rounded.
|
||||
test("the summary's min, max, median and average latency over the WAN targets' last checks", () => {
|
||||
const state = new AppState([]);
|
||||
[30, 10, null, 25, 20].forEach((latency, i) =>
|
||||
state.wan[i].pushSample(
|
||||
Date.now(),
|
||||
latency === null
|
||||
? { latency: null, error: "unreachable" }
|
||||
: { latency, error: null },
|
||||
),
|
||||
);
|
||||
assert.deepEqual(state.wanStats(), {
|
||||
reachable: 4,
|
||||
total: state.wan.length,
|
||||
min: 10,
|
||||
max: 30,
|
||||
med: 23,
|
||||
avg: 21,
|
||||
});
|
||||
});
|
||||
|
||||
// An app state in which, of the WAN targets, the first timedOut timed out,
|
||||
// the next unreachable were found unreachable, the next answered answered
|
||||
// after latency ms, and the rest have not been checked yet.
|
||||
|
||||
Reference in New Issue
Block a user