test_performance.py
python
sha256:2313b6a6353294a0ca08ff579624198da250b99163a86215aed31a905912e360
Land Scooling Lab T0/T2 training contract and seven-tier tests
Human
minor
⚠ breaking
42 days ago
| 1 | """Performance tier tests for Scooling Lab bounded local operations.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import time |
| 6 | import unittest |
| 7 | |
| 8 | from scooling_lab_helpers import PROJECT_ROOT, valid_payload |
| 9 | |
| 10 | from scooling_lab.bom import main as bom_main |
| 11 | from scooling_lab.service import TrainingApiService |
| 12 | from scooling_lab.store import TrainingJobStore |
| 13 | |
| 14 | |
| 15 | class ScoolingLabPerformanceTests(unittest.TestCase): |
| 16 | """Performance tests for status/list endpoints and BOM scan budget.""" |
| 17 | |
| 18 | def test_performance_status_and_list_artifacts_are_bounded(self) -> None: |
| 19 | """Repeated status and artifact reads remain inside a local budget.""" |
| 20 | |
| 21 | service = TrainingApiService(TrainingJobStore()) |
| 22 | created = service.create_training_job(valid_payload("performance")) |
| 23 | job_id = str(created["id"]) |
| 24 | |
| 25 | start = time.perf_counter() |
| 26 | for _ in range(200): |
| 27 | self.assertEqual(service.get_training_job(job_id)["status"], "succeeded") |
| 28 | self.assertEqual(len(service.list_artifacts(job_id)["artifacts"]), 1) |
| 29 | elapsed = time.perf_counter() - start |
| 30 | |
| 31 | self.assertLess(elapsed, 1.0) |
| 32 | |
| 33 | def test_performance_bom_scan_runs_inside_ci_budget(self) -> None: |
| 34 | """The real BOM check completes within the configured CI budget.""" |
| 35 | |
| 36 | start = time.perf_counter() |
| 37 | exit_code = bom_main( |
| 38 | [ |
| 39 | "--root", |
| 40 | str(PROJECT_ROOT), |
| 41 | "--output", |
| 42 | "DEPENDENCIES.md", |
| 43 | "--check", |
| 44 | "--budget-seconds", |
| 45 | "30", |
| 46 | ] |
| 47 | ) |
| 48 | elapsed = time.perf_counter() - start |
| 49 | |
| 50 | self.assertEqual(exit_code, 0) |
| 51 | self.assertLess(elapsed, 30) |
| 52 | |
| 53 | |
| 54 | if __name__ == "__main__": |
| 55 | unittest.main() |
File History
1 commit
sha256:2313b6a6353294a0ca08ff579624198da250b99163a86215aed31a905912e360
Land Scooling Lab T0/T2 training contract and seven-tier tests
Human
minor
⚠
42 days ago