Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c4aac4719 |
+28
-14
@@ -327,23 +327,22 @@ for (const { history, latencies, statistics } of [
|
||||
}
|
||||
|
||||
// An app state in which, of the WAN targets, the first timedOut timed out,
|
||||
// the next answered answered after latency ms, and the rest have not been
|
||||
// checked yet.
|
||||
function stateAfter({ timedOut, answered, latency }) {
|
||||
// the next unreachable were found unreachable, the next answered answered
|
||||
// after latency ms, and the rest have not been checked yet.
|
||||
function stateAfter({ timedOut, unreachable, answered, latency }) {
|
||||
const state = new AppState([]);
|
||||
for (const host of state.wan.slice(0, timedOut)) {
|
||||
host.pushSample(Date.now(), { latency: null, error: "timeout" });
|
||||
}
|
||||
for (const host of state.wan.slice(timedOut, timedOut + answered)) {
|
||||
host.pushSample(Date.now(), { latency, error: null });
|
||||
}
|
||||
const results = [
|
||||
...Array(timedOut).fill({ latency: null, error: "timeout" }),
|
||||
...Array(unreachable).fill({ latency: null, error: "unreachable" }),
|
||||
...Array(answered).fill({ latency, error: null }),
|
||||
];
|
||||
results.forEach((result, i) => state.wan[i].pushSample(Date.now(), result));
|
||||
return state;
|
||||
}
|
||||
|
||||
// For each number the health is decided by, the rows put it one under, at
|
||||
// and one over its threshold. A target found unreachable counts as one
|
||||
// that timed out.
|
||||
for (const { timedOut, answered, latency, health } of [
|
||||
// and one over its threshold.
|
||||
for (const { timedOut, unreachable = 0, answered, latency, health } of [
|
||||
// Offline: more than 10 timed out and at most 4 answered.
|
||||
{ timedOut: 9, answered: 4, latency: 30, health: "degraded" },
|
||||
{ timedOut: 10, answered: 4, latency: 30, health: "degraded" },
|
||||
@@ -360,9 +359,24 @@ for (const { timedOut, answered, latency, health } of [
|
||||
{ timedOut: 0, answered: 4, latency: 1001, health: "slow" },
|
||||
{ timedOut: 0, answered: 2, latency: 1001, health: "healthy" },
|
||||
{ timedOut: 0, answered: 3, latency: 1001, health: "healthy" },
|
||||
// A target found unreachable counts as one that timed out.
|
||||
{
|
||||
timedOut: 5,
|
||||
unreachable: 6,
|
||||
answered: 4,
|
||||
latency: 30,
|
||||
health: "offline",
|
||||
},
|
||||
{
|
||||
timedOut: 0,
|
||||
unreachable: 5,
|
||||
answered: 10,
|
||||
latency: 30,
|
||||
health: "degraded",
|
||||
},
|
||||
]) {
|
||||
test(`with ${timedOut} WAN targets timed out and ${answered} answering after ${latency}ms, the health is ${health}`, () => {
|
||||
const state = stateAfter({ timedOut, answered, latency });
|
||||
test(`with ${timedOut} WAN targets timed out, ${unreachable} found unreachable and ${answered} answering after ${latency}ms, the health is ${health}`, () => {
|
||||
const state = stateAfter({ timedOut, unreachable, answered, latency });
|
||||
assert.equal(state.healthStatus(), health);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user