Files
qrtx 5c8bcf0f80 test: cover persistence failover and graceful draining
Add API integration checks, migration compatibility, rolling restart scenarios and a report verification collector.
2026-10-29 11:47:46 +03:00

30 lines
1.2 KiB
Python

import importlib.util
from pathlib import Path
import unittest
spec = importlib.util.spec_from_file_location('saturation', Path(__file__).resolve().parents[1]/'scripts/run-saturation.py')
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
class ClassificationTest(unittest.TestCase):
def classify(self, attempted=1000, dropped=0, errors=0, p95=500):
return module.classify({'measurement': {'scheduled_slots': 1000,
'client_dropped_slots': dropped, 'all': {'attempted': attempted, 'errors': errors}},
'all_latency_ms': {'p95': p95}})['classification']
def test_delivered_healthy_workload_passes(self):
self.assertEqual(self.classify(), 'pass')
def test_latency_or_errors_break_service_criterion(self):
self.assertEqual(self.classify(p95=1500), 'slo_fail')
self.assertEqual(self.classify(errors=20), 'slo_fail')
def test_underfed_workload_is_not_a_server_capacity_measurement(self):
self.assertEqual(self.classify(attempted=800, dropped=200), 'generator_limited')
self.assertEqual(self.classify(attempted=800, dropped=200, p95=3000), 'generator_limited')
if __name__ == '__main__':
unittest.main()