Implement lab 3 level 4 failover and idempotency

This commit is contained in:
2026-10-29 23:35:04 +03:00
parent 0ab3a341aa
commit a2cb1ad2ae
338 changed files with 37821 additions and 22 deletions
+45 -3
View File
@@ -1,4 +1,4 @@
name: Skeleton contracts
name: Lab3 contracts and application
on: [push, pull_request]
permissions:
contents: read
@@ -12,5 +12,47 @@ jobs:
python-version: '3.12'
- run: python -m pip install -r requirements-dev.txt
- run: make check validate PYTHON=python
# This job validates the skeleton, not a student solution.
# Add build, readiness and make test in a separate application job.
application:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Prepare local test secrets
run: |
cp .env.example .env
mkdir -p secrets
chmod 700 secrets
python3 - <<'PY'
from pathlib import Path
from secrets import token_urlsafe
from urllib.parse import quote
password = token_urlsafe(32)
Path('secrets/postgres_password').write_text(password + '\n')
Path('secrets/database_url').write_text(
f"postgres://messenger:{quote(password, safe='')}@postgres:5432/messenger?sslmode=disable\n"
)
PY
chmod 644 secrets/postgres_password secrets/database_url
- name: Build and start application
run: docker compose --env-file .env up -d --build
- name: Wait for public readiness
run: |
for attempt in $(seq 1 90); do
if curl --fail --silent http://127.0.0.1:8080/health/ready > /dev/null; then
exit 0
fi
sleep 1
done
docker compose --env-file .env ps --all
exit 1
- name: Public smoke
run: make test BASE_URL=http://127.0.0.1:8080
- name: Clean up test volumes
if: always()
run: |
if [ -f .env ]; then
docker compose --env-file .env down -v
fi