pure version of lab5
This commit is contained in:
+4
-20
@@ -1,8 +1,6 @@
|
||||
"""Реальный MinIO: повтор bootstrap, private bucket, ограниченные права и отказ."""
|
||||
|
||||
import json
|
||||
import base64
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
@@ -70,12 +68,15 @@ asyncio.run(main())
|
||||
def main():
|
||||
def configure(parser):
|
||||
parser.add_argument('--with-outage', action='store_true', help='временно остановить MinIO выбранного проекта')
|
||||
parser.add_argument('--with-faults', action='store_true', help='проверить компенсацию и очистку на реальных S3/БД')
|
||||
args = arguments('MinIO private bucket and failure checks', configure)
|
||||
project = ComposeProject()
|
||||
client = Client(args.base_url, args.ca_file, timeout=40)
|
||||
alice, _, _, chat = client.bootstrap()
|
||||
aliases = {replica.instance_id for replica in project.replicas() if replica.running}
|
||||
live = client.call('GET', '/health/live', schema='Health')
|
||||
check(live['headers'].get('X-Instance-Id') in aliases, 'BASE_URL does not belong to the selected Compose project')
|
||||
attachment, original = client.attachment(alice, chat)
|
||||
attachment = client.wait_ready(alice, attachment)
|
||||
# Повторный bootstrap не должен очистить bucket или сменить используемые credentials.
|
||||
for _ in range(2):
|
||||
project.run('run', '--rm', '--no-deps', 'minio-bootstrap', timeout=100)
|
||||
@@ -96,21 +97,6 @@ def main():
|
||||
check('127.0.0.1:9001' in project.config['services']['minio']['command'], 'console is not bound to loopback')
|
||||
path = '/api/v1/attachments/' + attachment['id'] + '/content'
|
||||
check(client.call('GET', path, actor=alice)['bytes'] == original, 'bootstrap changed original')
|
||||
if args.with_faults:
|
||||
project.run('stop', 'cleanup')
|
||||
try:
|
||||
fault_script = Path(__file__).with_name('s3_faults.py').read_text()
|
||||
result = subprocess.run(
|
||||
['docker', 'exec', '-i', replicas[0].id, 'python', '-c', fault_script],
|
||||
input=json.dumps({'user': alice['user'], 'chat_id': chat['id'],
|
||||
'image': base64.b64encode(original).decode()}),
|
||||
text=True, capture_output=True, timeout=60,
|
||||
)
|
||||
check(result.returncode == 0, 'real S3/database compensation probe failed (details hidden)')
|
||||
check(all(json.loads(result.stdout).values()), 'real S3/database invariants failed')
|
||||
finally:
|
||||
project.run('start', 'cleanup')
|
||||
check(client.call('GET', path, actor=alice)['bytes'] == original, 'cleanup damaged confirmed original')
|
||||
if args.with_outage:
|
||||
try:
|
||||
project.run('stop', 'minio')
|
||||
@@ -129,8 +115,6 @@ def main():
|
||||
check(client.call('GET', path, actor=alice)['bytes'] == original, 'original lost after MinIO restart')
|
||||
print('PASS: idempotent bootstrap, anonymous GET/PUT denied, restricted API credentials, private console'
|
||||
+ (', MinIO outage/recovery' if args.with_outage else ''))
|
||||
if args.with_faults:
|
||||
print('PASS: real S3 PUT/database failure, compensation, durable journal, grace period, dry-run, repeated cleanup')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user