feat: xhttp xmux
This commit is contained in:
16 files changed
+231
-18
No files matched your search
@@ -2394,15 +2394,21 @@ class GroupWatch:
|
||||
return status == 200 and isinstance(body, dict) and "delay" in body
|
||||
|
||||
def record(self, tag, ok, hinted=False):
|
||||
# Logged: each miss of a member still up, and its going down and up. A hiccup that heals
|
||||
# before the member goes down leaves those misses, and nothing else, behind.
|
||||
h = self.health.setdefault(tag, {"up": True, "misses": 0, "passes": 0, "since": self.wall()})
|
||||
if ok:
|
||||
h["misses"], h["passes"] = 0, h["passes"] + 1
|
||||
if not h["up"] and h["passes"] >= GROUP_PASSES_UP:
|
||||
h["up"], h["since"] = True, self.wall()
|
||||
print(f"{tag}: up again", file=sys.stderr)
|
||||
else:
|
||||
h["passes"], h["misses"] = 0, h["misses"] + 1
|
||||
if h["up"]:
|
||||
print(f"{tag}: test failed ({h['misses']}/{1 if hinted else GROUP_MISSES_DOWN}{', after a hint' if hinted else ''})", file=sys.stderr)
|
||||
if h["up"] and (hinted or h["misses"] >= GROUP_MISSES_DOWN):
|
||||
h["up"], h["since"] = False, self.wall()
|
||||
print(f"{tag}: down", file=sys.stderr)
|
||||
|
||||
def up(self, tag):
|
||||
return self.health.get(tag, {}).get("up", True)
|
||||
|
||||
@@ -419,6 +419,25 @@ class GroupWatchTest(EnvTest):
|
||||
self.assertEqual(self.step(), [])
|
||||
self.assertEqual(self.step(), [("warp", "warp-1")])
|
||||
|
||||
def test_logs_misses_and_outages(self):
|
||||
def lines(fn, *args):
|
||||
return run(fn, *args)[2].splitlines()
|
||||
|
||||
self.step(0)
|
||||
self.working["warp-1"] = False
|
||||
# A hiccup that heals before the member goes down still leaves its miss behind.
|
||||
self.assertEqual(lines(self.step), ["warp-1: test failed (1/2)"])
|
||||
self.working["warp-1"] = True
|
||||
self.assertEqual(lines(self.step), [])
|
||||
self.working["warp-1"] = False
|
||||
self.assertEqual(lines(self.step), ["warp-1: test failed (1/2)"])
|
||||
self.assertEqual(lines(self.step), ["warp-1: test failed (2/2)", "warp-1: down", "warp: warp-1 -> warp-2"])
|
||||
# Down, its misses are not repeated every test.
|
||||
self.assertEqual(lines(self.step), [])
|
||||
self.working["warp-1"] = True
|
||||
self.step(), self.step()
|
||||
self.assertEqual(lines(self.step), ["warp-1: up again", "warp: warp-2 -> warp-1"])
|
||||
|
||||
def test_a_hint_moves_at_once(self):
|
||||
self.step(0)
|
||||
self.working["warp-1"] = False
|
||||
|
||||
Reference in new issue
Block a user