готово

This commit is contained in:
2026-11-12 19:38:03 +03:00
parent ec540a1a72
commit f3ba37f736
142 changed files with 10257 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
"""Исходный persistence-сценарий плюс доказательство рестарта API и всех хранилищ."""
import argparse
import json
from pathlib import Path
import subprocess
import sys
ROOT = Path(__file__).resolve().parents[1]
def states():
result = {}
for service in ('api', 'postgres', 'redis', 'minio', 'reconciler', 'lb'):
ids = subprocess.check_output(['docker', 'compose', 'ps', '-q', service], cwd=ROOT, text=True).split()
if not ids:
raise RuntimeError('Не запущен сервис ' + service)
result[service] = {}
for container in ids:
state = json.loads(subprocess.check_output(['docker', 'inspect', '--format', '{{json .State}}', container], cwd=ROOT, text=True))
result[service][container] = {'StartedAt': state['StartedAt'], 'Pid': state['Pid']}
return result
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--base-url', default='http://localhost:8080')
parser.add_argument('--action-script', required=True)
parser.add_argument('--ca-file')
args = parser.parse_args()
before = states()
print('ДО: ' + json.dumps(before), flush=True)
command = [sys.executable, str(ROOT / 'tests/resilience.py'), '--mode', 'persistence',
'--action-script', args.action_script, '--base-url', args.base_url]
if args.ca_file:
command += ['--ca-file', args.ca_file]
subprocess.run(command, cwd=ROOT, check=True)
after = states()
print('ПОСЛЕ: ' + json.dumps(after), flush=True)
for service in before:
if before[service] == after[service]:
raise AssertionError('Сервис не перезапущен: ' + service)
print('PASS: StartedAt изменился у API, PostgreSQL, Redis, MinIO, reconciler и LB; прежний токен и данные сохранены')
if __name__ == '__main__':
main()