This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
|
||||
spec = importlib.util.spec_from_file_location("capacity_probe", Path(__file__).resolve().parents[1] / "deploy" / "capacity_probe.py")
|
||||
probe = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(probe)
|
||||
|
||||
|
||||
class CapacityProbeTests(unittest.TestCase):
|
||||
def test_summary_reports_failures_and_nearest_rank_latency(self):
|
||||
report = probe.summarize([(True, 10), (True, 20), (False, 30), (True, 40), (True, 100)], 2)
|
||||
self.assertEqual(report["requests"], 5)
|
||||
self.assertEqual(report["successes"], 4)
|
||||
self.assertEqual(report["failures"], 1)
|
||||
self.assertEqual(report["errorRate"], 0.2)
|
||||
self.assertEqual(report["latencyMs"], {"median": 30, "p95": 100, "maximum": 100})
|
||||
|
||||
def test_summary_rejects_empty_results(self):
|
||||
with self.assertRaisesRegex(ValueError, "At least one"):
|
||||
probe.summarize([], 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user