ЛР 7 — БВТ2303 — Брезгунова — на 5
Skeleton contracts / contracts (pull_request) Blocked by required conditions
Lab7 solution / integration (pull_request) Blocked by required conditions

This commit is contained in:
2026-12-04 17:07:57 +03:00
parent 20afc2c790
commit ee9d70af85
129 changed files with 81564 additions and 90 deletions
+27
View File
@@ -0,0 +1,27 @@
"""Public load workload plus actual process/cgroup snapshots on the same stand."""
import json
import sys
import time
from verify import ROOT,BASE,CA,command,compose,save
def stats(role):
tag='src.app:app' if role.startswith('api') else 'src.worker'
code="import psutil,json; p=next(p for p in psutil.process_iter() if p.name().startswith('python') and "+repr(tag)+" in p.cmdline()); procs=[p]+p.children(recursive=True); print(json.dumps({'cpu_seconds':sum(sum(x.cpu_times()[:2]) for x in procs),'rss_bytes':sum(x.memory_info().rss for x in procs)}))"
return json.loads(compose('exec','-T',role,'python','-c',code))
if __name__=='__main__':
before={r:stats(r) for r in ('api1','api2','worker')}
started=time.monotonic()
command([sys.executable,'-X','utf8','tests/load.py','--base-url',BASE,'--ca-file',CA,'--duration','30','--concurrency','4','--output','evidence/load.json'],'load.txt')
elapsed=time.monotonic()-started
after={r:stats(r) for r in before}
ids=compose('ps','-q').split()
containers=command(['docker','stats','--no-stream','--format','{{json .}}',*ids])
save('load-resources.json',{'before':before,'after':after,'wall_seconds':elapsed,
'CPU_cores':{r:(after[r]['cpu_seconds']-before[r]['cpu_seconds'])/elapsed for r in before},
'cgroup_snapshots':[json.loads(line) for line in containers.splitlines()],
'clock_resolution_seconds':time.get_clock_info('monotonic').resolution,
'limitation':'Process snapshots include child workers, exclude client, DB, TLS sidecars and Collector from API CPU; container snapshots cover those separately. RSS is end snapshot, not worst-case peak.'})
print('PASS: public HTTPS load and process/container resource snapshots')