@@ -0,0 +1,38 @@
|
||||
"""Small bounded presentation check, not a claim of maximum production capacity."""
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import statistics
|
||||
import sys
|
||||
import time
|
||||
|
||||
assert sys.argv[1] == '--bounded-synthetic-check'
|
||||
s = importlib.util.spec_from_file_location('demo', '/root/check-public-demonstration.py')
|
||||
m = importlib.util.module_from_spec(s); s.loader.exec_module(m)
|
||||
credentials = json.loads(Path('/root/compras-demo-access.json').read_text())
|
||||
paths = {'admin': '/pessoas/relatorios', 'procurement': '/ordens', 'finance': '/relatorios', 'warehouse': '/dashboard'}
|
||||
clients = {key: m.Client(credentials[key], 'https://compras.tempo.co.mz') for key in paths}
|
||||
|
||||
|
||||
def exercise(key):
|
||||
timings = []
|
||||
for _ in range(12):
|
||||
started = time.perf_counter()
|
||||
result = clients[key].request(paths[key])
|
||||
elapsed = time.perf_counter() - started
|
||||
assert result['status'] == 200 and result['page']['props']['auth']['user'] is not None, key
|
||||
timings.append(elapsed)
|
||||
return timings
|
||||
|
||||
|
||||
started = time.perf_counter()
|
||||
with ThreadPoolExecutor(max_workers=4) as pool:
|
||||
timings = [elapsed for group in pool.map(exercise, paths) for elapsed in group]
|
||||
ordered = sorted(timings)
|
||||
proof = {'state': 'passed', 'origin': 'https://compras.tempo.co.mz', 'normal_login_sessions': 4, 'concurrent_sessions': 4,
|
||||
'get_requests': len(timings), 'responses_200': len(timings), 'duration_seconds': round(time.perf_counter()-started, 3),
|
||||
'median_seconds': round(statistics.median(timings), 3), 'p95_seconds': round(ordered[int(len(ordered)*0.95)-1], 3),
|
||||
'maximum_seconds': round(max(timings), 3), 'business_mutations': False, 'maximum_production_capacity_certified': False}
|
||||
Path('/var/www/compras-deploy/demonstration-20261129/bounded-load.json').write_text(json.dumps(proof, indent=2))
|
||||
print(json.dumps(proof, indent=2))
|
||||
Reference in New Issue
Block a user