tests: полный вывод сценариев, ключи mc ls, разбивка времени reconciler
This commit is contained in:
@@ -144,9 +144,14 @@ def scenario_db_gap(c):
|
||||
check(objs == '0', 'compensation must delete the object, objects=' + objs)
|
||||
# Reconciler (короткий grace для теста) убирает брошенное намерение.
|
||||
psql("UPDATE attachments SET updated_at = now() - interval '30 minutes' WHERE chat_id = '%s'" % chat['id'])
|
||||
out = compose('run', '--rm', '--no-deps', '-T', '--entrypoint', '/app/reconcile', 'reconciler',
|
||||
'--apply', '--grace', '10m').stdout.strip().splitlines()[-1]
|
||||
rep = json.loads(out)
|
||||
for _ in range(10):
|
||||
r = compose('run', '--rm', '--no-deps', '-T', '--entrypoint', '/app/reconcile', 'reconciler',
|
||||
'--apply', '--grace', '10m', check=False)
|
||||
if r.returncode != 3: # 3 — advisory lock у фонового reconciler
|
||||
break
|
||||
time.sleep(2)
|
||||
check(r.returncode in (0, 4), 'reconcile failed: ' + r.stderr[-300:])
|
||||
rep = json.loads(r.stdout.strip().splitlines()[-1])
|
||||
after = psql("SELECT count(*) FROM attachments WHERE chat_id = '%s'" % chat['id'])
|
||||
check(after == '0', 'reconciler did not remove stale intent')
|
||||
return {'client_status': st, 'seconds': round(time.time() - t0, 1), 'after_gap': {'rows': rows.split()[-1], 'objects': int(objs)},
|
||||
@@ -172,7 +177,7 @@ def scenario_security(c):
|
||||
check(own == 'ok', 'api key cannot read own bucket')
|
||||
check(mb.returncode != 0, 'api key must not create buckets')
|
||||
check(admin.returncode != 0, 'api key must not use admin API')
|
||||
check(buckets.returncode != 0 or BUCKET not in buckets.stdout or 'evil' not in buckets.stdout, 'unexpected bucket listing')
|
||||
check(buckets.returncode != 0 or 'evil' not in buckets.stdout, 'api key sees a bucket it created?!')
|
||||
# Bootstrap идемпотентен: повторный запуск успешен, объект на месте.
|
||||
before = mc('mc ls --recursive s3/%s | wc -l' % BUCKET).stdout.strip()
|
||||
r1 = compose('run', '--rm', 's3-init')
|
||||
@@ -183,7 +188,8 @@ def scenario_security(c):
|
||||
check('0.0.0.0' not in ports and '127.0.0.1' not in ports, 's3 port is published: ' + ports)
|
||||
return {'anonymous_get': '403', 'anonymous_list': '403', 'api_key_own_bucket': 'allowed',
|
||||
'api_key_make_bucket': 'denied', 'api_key_admin': 'denied',
|
||||
'api_key_list_all_buckets': 'denied' if buckets.returncode != 0 else 'allowed',
|
||||
'api_key_visible_buckets': sorted(l.split()[-1].rstrip('/') for l in buckets.stdout.splitlines() if l.strip())
|
||||
if buckets.returncode == 0 else 'denied',
|
||||
'bootstrap_runs': [r1.returncode, r2.returncode], 'objects_before_after': [int(before), int(after)],
|
||||
's3_published_ports': ports or 'none'}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user