Files
mtusi2026lab3/evidence/stand/bootstrap.txt
T

72 lines
3.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Что доказывает: исправленный .env.example позволяет создать окружение
# из чистой копии и поднять рабочий стенд документированными командами.
# Дата UTC: 2026-10-15 (проверки выполнены в этой сессии).
# Окружение: macOS 26.6.2, Apple M4; Docker 28.0.4;
# Compose 2.34.0-desktop.1; Python хоста 3.13.7.
# Стенд: vladimirceva-lab3, HAProxy 127.0.0.1:8080, две API-реплики.
# Код: src_sha256 0349e9a2701784673391c0ba4bc2eedba7013098d6ff7f871261aab36f78354a.
# Исправление и исходники зафиксированы локальным коммитом 84dd7fe.
# Пароли и токен не печатались. Как повторить: make env; make up;
# make test; make instances. Проверка чистого шаблона ниже выполнялась
# во временном каталоге: копия .env.example и make -f <репозиторий>/Makefile env;
# затем config --quiet с получившимся --env-file и compose.yaml проекта.
$ python3 - <<'PY'
from pathlib import Path
import shutil
import subprocess
import tempfile
root=Path.cwd()
with tempfile.TemporaryDirectory(prefix='lab3-bootstrap-fixed-') as temp:
folder=Path(temp)
shutil.copyfile(root/'.env.example',folder/'.env.example')
subprocess.run(['make','-f',str(root/'Makefile'),'env'],cwd=folder,check=True)
env=folder/'.env'
before=env.read_bytes()
subprocess.run(['make','-f',str(root/'Makefile'),'env'],cwd=folder,check=True)
print('Repeated make env preserves existing file:',before==env.read_bytes())
values=dict(line.split('=',1) for line in env.read_text().splitlines() if line and not line.startswith('#') and '=' in line)
print('Both generated passwords have 32 hex characters:',all(len(values[k])==32 and all(c in '0123456789abcdef' for c in values[k]) for k in ['POSTGRES_PASSWORD','VALKEY_PASSWORD']))
subprocess.run(['docker','compose','--env-file',str(env),'-f',str(root/'compose.yaml'),'config','--quiet'],cwd=root,check=True)
print('PASS: clean bootstrap environment and compose configuration')
PY
.env ready
.env ready
Repeated make env preserves existing file: True
Both generated passwords have 32 hex characters: True
PASS: clean bootstrap environment and compose configuration
$ make up
... (сборка, создание и запуск контейнеров опущены)
Container vladimirceva-lab3-postgres-1 Healthy
Container vladimirceva-lab3-valkey-1 Healthy
Container vladimirceva-lab3-migrate-1 Exited
Container vladimirceva-lab3-haproxy-1 Healthy
Container vladimirceva-lab3-api-1 Healthy
Container vladimirceva-lab3-api-2 Healthy
$ make test
python3 tests/smoke.py --base-url "http://localhost:8080"
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
$ make instances
python3 scripts/lab3.py instances --base-url "http://localhost:8080"
one session, 12 x GET /api/v1/users/me via http://localhost:8080
1: 200 X-Instance-Id=bc629f87fa96
2: 200 X-Instance-Id=554216a23f5a
3: 200 X-Instance-Id=bc629f87fa96
4: 200 X-Instance-Id=554216a23f5a
5: 200 X-Instance-Id=bc629f87fa96
6: 200 X-Instance-Id=554216a23f5a
7: 200 X-Instance-Id=bc629f87fa96
8: 200 X-Instance-Id=554216a23f5a
9: 200 X-Instance-Id=bc629f87fa96
10: 200 X-Instance-Id=554216a23f5a
11: 200 X-Instance-Id=bc629f87fa96
12: 200 X-Instance-Id=554216a23f5a
replicas seen: 2 {'bc629f87fa96': 6, '554216a23f5a': 6}
# Итог: make env создаёт оба пароля и сохраняет существующий файл;
# compose принимает окружение; миграции завершились, обе API-реплики и
# LB готовы, smoke прошёл, один токен обслуживают обе реплики.