Подтвердить трек 2 реальными сбоями, нагрузкой и отчётом
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"""Публичная нагрузка сообщений с отдельными cgroup CPU/memory snapshots."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
command = [sys.executable, '-X', 'utf8', 'tests/load.py', '--base-url', 'http://127.0.0.1:8085',
|
||||
'--duration', '30', '--concurrency', '4', '--output', 'evidence/load-messages.json']
|
||||
with (ROOT / 'evidence/load-messages-run.txt').open('w', encoding='utf-8') as output:
|
||||
process = subprocess.Popen(command, cwd=ROOT, stdout=output, stderr=subprocess.STDOUT)
|
||||
samples = []
|
||||
start = time.monotonic()
|
||||
while process.poll() is None:
|
||||
ids = subprocess.check_output(['docker', 'compose', '-p', 'lyakhonov-lab5', 'ps', '-q'], cwd=ROOT, text=True).split()
|
||||
stats = subprocess.check_output(['docker', 'stats', '--no-stream', '--format', '{{json .}}', *ids], text=True)
|
||||
samples.append(dict(at_seconds=round(time.monotonic()-start, 3), containers=[json.loads(x) for x in stats.splitlines()]))
|
||||
time.sleep(2)
|
||||
code = process.wait()
|
||||
(ROOT / 'evidence/load-messages-resources.json').write_text(json.dumps(dict(command=command, exit_code=code, samples=samples), indent=2), encoding='utf-8')
|
||||
raise SystemExit(code)
|
||||
@@ -51,7 +51,7 @@ def main(args):
|
||||
c = Client(args.base_url)
|
||||
begin = time.monotonic()
|
||||
att = c.call('POST', '/api/v1/chats/' + chat['id'] + '/attachments?filename=load.png', 202,
|
||||
raw=raw, actor=alice, headers={'Content-Type': 'image/png'})['json']
|
||||
raw=raw, actor=alice, headers={'Content-Type': 'image/png'}, schema='Attachment')['json']
|
||||
accepted = time.monotonic()
|
||||
ready = c.wait_ready(alice, att)
|
||||
check(len(ready['variants']) == 3 and ready['sha256'] == hashlib.sha256(raw).hexdigest(), 'bad load result')
|
||||
|
||||
@@ -212,6 +212,7 @@ class Experiment:
|
||||
upload(huge, 413)
|
||||
att = self.upload()
|
||||
self.invariant(att)
|
||||
check(self.probe('anonymous', id=att['id']) == 403, 'bucket allows anonymous reads')
|
||||
self.c.call('GET', '/api/v1/attachments/' + att['id'], 404, actor=self.eve)
|
||||
self.c.call('GET', '/api/v1/attachments/' + att['id'] + '/content', 404, actor=self.eve)
|
||||
key = os.urandom(16).hex()
|
||||
|
||||
@@ -10,6 +10,17 @@ from src.storage import storage
|
||||
|
||||
def run(args):
|
||||
action = args['action']
|
||||
if action == 'anonymous':
|
||||
import boto3
|
||||
from botocore import UNSIGNED
|
||||
from botocore.config import Config
|
||||
from botocore.exceptions import ClientError
|
||||
s3 = boto3.client('s3', endpoint_url='http://s3:9000', config=Config(signature_version=UNSIGNED))
|
||||
try:
|
||||
s3.get_object(Bucket=BUCKET, Key=f"originals/{args['id']}")
|
||||
except ClientError as exc:
|
||||
return exc.response['ResponseMetadata']['HTTPStatusCode']
|
||||
return 200
|
||||
if action == 'sql':
|
||||
with storage.pool.connection() as conn:
|
||||
cursor = conn.execute(args['query'], args.get('params', []))
|
||||
|
||||
@@ -58,11 +58,11 @@ def targeted():
|
||||
errors.append(str(exc))
|
||||
time.sleep(.05)
|
||||
check(first is not None and first <= 10, 'slow API failover')
|
||||
page = c.call('GET', '/api/v1/chats/' + chat['id'] + '/messages?limit=100', actor=alice)['json']
|
||||
page = c.call('GET', '/api/v1/chats/' + chat['id'] + '/messages?limit=100', actor=alice, schema='MessagePage')['json']
|
||||
messages = list(page['items'])
|
||||
while page['next_cursor']:
|
||||
from urllib.parse import quote
|
||||
page = c.call('GET', '/api/v1/chats/' + chat['id'] + '/messages?limit=100&cursor=' + quote(page['next_cursor'], safe=''), actor=alice)['json']
|
||||
page = c.call('GET', '/api/v1/chats/' + chat['id'] + '/messages?limit=100&cursor=' + quote(page['next_cursor'], safe=''), actor=alice, schema='MessagePage')['json']
|
||||
messages.extend(page['items'])
|
||||
found = {m['id'] for m in messages}
|
||||
check(all(m['id'] in found for m in responses), 'acknowledged message lost')
|
||||
|
||||
Reference in New Issue
Block a user