Functional Weave
Code in Python

monitor.incidents@1.0.0

vectors.json

5,284 bytes · view raw

[
  {"name": "two down checks in a row are one incident ending at the first up check", "args": [[{"at": 0, "status": "up"}, {"at": 60, "status": "down"}, {"at": 120, "status": "down"}, {"at": 180, "status": "up"}, {"at": 240, "status": "up"}], "down", 1, 300], "expect": [{"start": 60, "end": 180, "durationSeconds": 120, "worst": "down", "checks": 2}]},
  {"name": "a run exactly confirmChecks long is an incident", "args": [[{"at": 0, "status": "up"}, {"at": 60, "status": "down"}, {"at": 120, "status": "down"}, {"at": 180, "status": "up"}, {"at": 240, "status": "up"}], "down", 2, 300], "expect": [{"start": 60, "end": 180, "durationSeconds": 120, "worst": "down", "checks": 2}]},
  {"name": "a run shorter than confirmChecks is ignored as a flap", "args": [[{"at": 0, "status": "up"}, {"at": 60, "status": "down"}, {"at": 120, "status": "down"}, {"at": 180, "status": "up"}, {"at": 240, "status": "up"}], "down", 3, 300], "expect": []},
  {"name": "a run still bad at the last check is ongoing, measured to now", "args": [[{"at": 0, "status": "up"}, {"at": 60, "status": "down"}, {"at": 120, "status": "down"}], "down", 1, 200], "expect": [{"start": 60, "end": null, "durationSeconds": 140, "worst": "down", "checks": 2}]},
  {"name": "degraded mode joins degraded and down checks into one incident, worst down", "args": [[{"at": 0, "status": "up"}, {"at": 60, "status": "degraded"}, {"at": 120, "status": "down"}, {"at": 180, "status": "degraded"}, {"at": 240, "status": "up"}], "degraded", 1, 240], "expect": [{"start": 60, "end": 240, "durationSeconds": 180, "worst": "down", "checks": 3}]},
  {"name": "down mode: a degraded check is not bad, so it ends the down incident", "args": [[{"at": 0, "status": "up"}, {"at": 60, "status": "degraded"}, {"at": 120, "status": "down"}, {"at": 180, "status": "degraded"}, {"at": 240, "status": "up"}], "down", 1, 240], "expect": [{"start": 120, "end": 180, "durationSeconds": 60, "worst": "down", "checks": 1}]},
  {"name": "a degraded-only incident has worst degraded", "args": [[{"at": 0, "status": "up"}, {"at": 60, "status": "degraded"}, {"at": 120, "status": "up"}], "degraded", 1, 120], "expect": [{"start": 60, "end": 120, "durationSeconds": 60, "worst": "degraded", "checks": 1}]},
  {"name": "short blips around a real outage are dropped, and an unconfirmed ongoing run too", "args": [[{"at": 0, "status": "up"}, {"at": 60, "status": "down"}, {"at": 120, "status": "up"}, {"at": 180, "status": "down"}, {"at": 240, "status": "down"}, {"at": 300, "status": "down"}, {"at": 360, "status": "up"}, {"at": 420, "status": "down"}], "down", 2, 480], "expect": [{"start": 180, "end": 360, "durationSeconds": 180, "worst": "down", "checks": 3}]},
  {"name": "no checks, no incidents", "args": [[], "down", 1, 1000], "expect": []},
  {"name": "a series that starts bad starts its incident at the first check", "args": [[{"at": 0, "status": "down"}, {"at": 60, "status": "up"}], "down", 1, 60], "expect": [{"start": 0, "end": 60, "durationSeconds": 60, "worst": "down", "checks": 1}]},
  {"name": "all up has no incidents", "args": [[{"at": 0, "status": "up"}, {"at": 60, "status": "up"}, {"at": 120, "status": "up"}], "down", 1, 180], "expect": []},
  {"name": "an ongoing incident with now at its only check lasts 0 seconds", "args": [[{"at": 100, "status": "down"}], "down", 1, 100], "expect": [{"start": 100, "end": null, "durationSeconds": 0, "worst": "down", "checks": 1}]},
  {"name": "two separate incidents come out in time order", "args": [[{"at": 0, "status": "down"}, {"at": 10, "status": "up"}, {"at": 20, "status": "down"}, {"at": 30, "status": "down"}], "down", 1, 45], "expect": [{"start": 0, "end": 10, "durationSeconds": 10, "worst": "down", "checks": 1}, {"start": 20, "end": null, "durationSeconds": 25, "worst": "down", "checks": 2}]},
  {"name": "checks out of time order are an error", "args": [[{"at": 60, "status": "up"}, {"at": 60, "status": "down"}], "down", 1, 100], "expectError": "checks must be in strictly ascending time order"},
  {"name": "an unknown check status is an error", "args": [[{"at": 0, "status": "offline"}], "down", 1, 100], "expectError": "unknown check status: offline"},
  {"name": "up is not an incident status", "args": [[{"at": 0, "status": "up"}, {"at": 60, "status": "down"}, {"at": 120, "status": "down"}, {"at": 180, "status": "up"}, {"at": 240, "status": "up"}], "up", 1, 300], "expectError": "incidentStatus must be down or degraded, received up"},
  {"name": "confirmChecks 0 is an error", "args": [[{"at": 0, "status": "up"}, {"at": 60, "status": "down"}, {"at": 120, "status": "down"}, {"at": 180, "status": "up"}, {"at": 240, "status": "up"}], "down", 0, 300], "expectError": "confirmChecks must be at least 1"},
  {"name": "now before the last check is an error", "args": [[{"at": 0, "status": "up"}, {"at": 60, "status": "down"}, {"at": 120, "status": "down"}, {"at": 180, "status": "up"}, {"at": 240, "status": "up"}], "down", 1, 200], "expectError": "now 200 is before the last check at 240"},
  {"name": "a fractional now is an error", "args": [[{"at": 0, "status": "up"}, {"at": 60, "status": "down"}, {"at": 120, "status": "down"}, {"at": 180, "status": "up"}, {"at": 240, "status": "up"}], "down", 1, 300.5], "expectError": "now must be a whole number of seconds"}
]