forked from mtusi2026/mtusi2026lab2
lab2
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Sanity checks for track 2 evidence artifacts."""
|
||||
import json
|
||||
import os
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
EVIDENCE = ROOT / 'evidence' / 'track2'
|
||||
|
||||
|
||||
@unittest.skipUnless(
|
||||
os.environ.get('RUN_TRACK2_VERIFY') == '1',
|
||||
'Set RUN_TRACK2_VERIFY=1 after running track2 scripts',
|
||||
)
|
||||
class Track2EvidenceTests(unittest.TestCase):
|
||||
def test_benchmark_artifact(self):
|
||||
path = EVIDENCE / 'benchmark.json'
|
||||
self.assertTrue(path.is_file(), 'missing benchmark.json — run scripts/track2_benchmark.py')
|
||||
data = json.loads(path.read_text(encoding='utf-8'))
|
||||
keyset = data['read_plans']['keyset_limit_50']['execution_ms']
|
||||
offset = data['read_plans']['offset_50000_limit_50']['execution_ms']
|
||||
self.assertLess(keyset, offset, 'keyset should be faster than large OFFSET on hot chat')
|
||||
self.assertIsNotNone(data['read_plans']['keyset_limit_50'].get('index_name'))
|
||||
|
||||
def test_restore_artifact(self):
|
||||
path = EVIDENCE / 'restore_report.json'
|
||||
self.assertTrue(path.is_file(), 'missing restore_report.json')
|
||||
data = json.loads(path.read_text(encoding='utf-8'))
|
||||
self.assertTrue(data['counts_match'])
|
||||
self.assertTrue(data['sample_match'])
|
||||
self.assertGreaterEqual(data['source']['messages'], 100_000)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user