31 lines
1.6 KiB
Python
Executable File
31 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Source-only hot-cache safety guards; NOT a Rust compile, concurrency test or RPS result."""
|
|
from pathlib import Path
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
read = lambda path: (ROOT / path).read_text()
|
|
hot = read("src/cache/lookup/hot.rs")
|
|
entry = read("src/cache/model/cache.rs")
|
|
model = read("src/cache/model/maintenance.rs")
|
|
inv = read("src/cache/invalidation/invalidate.rs")
|
|
dash = read("src/cache/dashboard.rs")
|
|
assert 'headers: Arc<HeaderMap>' in entry
|
|
assert 'Arc::clone(&entry.headers)' in hot
|
|
assert 'drop(store);' in hot
|
|
assert hot.index('drop(store);\n\n let mut response') < hot.index('headers.as_ref().clone()')
|
|
assert 'store.saved_body_hit(&ticket.scope, &ticket.domain, body_bytes)' in hot
|
|
assert 'store.lru.remove(&old_sequence)' in hot and 'store.lru.insert(sequence, storage_key)' in hot
|
|
assert '.sweep()' not in hot
|
|
assert 'fn sweep(' not in entry
|
|
assert 'fn saved_body_hit(' in entry
|
|
assert 'domains: BTreeMap<String, BTreeMap<String, DomainCounters>>' in entry
|
|
assert 'if self.ban_rule_count.load(Ordering::Acquire) == 0' in inv
|
|
assert 'bans.iter().any(|rule| rule.matches_hot' in inv
|
|
assert 'fn matching_hot_key(' in model and 'entry.vary.is_empty()' in model
|
|
assert 'store.domain_count = 0' in dash
|
|
assert 'c.reasons.get_mut(reason)' in dash
|
|
assert 'include!("tests/hot_hit_034_tests.rs")' in read('src/cache/tests.rs')
|
|
for path in (ROOT / 'src').rglob('*.rs'):
|
|
if '/tests/' not in path.as_posix() and path.name != 'tests.rs':
|
|
assert len(path.read_text().splitlines()) <= 500, path
|
|
print('PASS HOT path static invariants (no Rust compilation or throughput claim)')
|