ЛР3 на 3

Co-authored-by: Югай Артур Рустамович <f1ekserr@yandex.ru>
This commit is contained in:
2026-11-16 22:23:04 +03:00
co-authored by Югай Артур Рустамович
parent 0ab3a341aa
commit 09aece58fe
37 changed files with 2651 additions and 35 deletions
+7
View File
@@ -0,0 +1,7 @@
{
"ttl_seconds": 2,
"expiry_unchanged_on_restart": true,
"before_restart": 200,
"after_expiry_and_restart": 401,
"new_login": 201
}
+117
View File
@@ -0,0 +1,117 @@
{
"public": {
"service": "api2",
"target_instance": "610aec79ba3b43ae8f846930b60d9293",
"before": {
"api1": {
"instance_id": "5047bb490b0a4fc5b07d22d0768a0e99",
"container_id": "507f14400f4fd4591391920e26ffb793859af0c423a7d9e858f1bf66a8b7b2f1"
},
"api2": {
"instance_id": "610aec79ba3b43ae8f846930b60d9293",
"container_id": "661c0fb5e5d3ba0553bdc4af3aa653877e7f9d002acba05cb1d758cf27b2cef7"
}
},
"after": {
"api1": {
"id": "507f14400f4fd4591391920e26ffb793859af0c423a7d9e858f1bf66a8b7b2f1",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:18:58.414235595Z",
"running": true,
"user": "messenger",
"volumes": []
},
"api2": {
"id": "661c0fb5e5d3ba0553bdc4af3aa653877e7f9d002acba05cb1d758cf27b2cef7",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:18:58.362001356Z",
"running": false,
"user": "messenger",
"volumes": []
},
"db": {
"id": "27554c7dfdfe16221938def671c50cb7fe3a2950bf6d2786829564728097a2b4",
"image": "sha256:665dc7b37ac52a17e298511414c21d23ffa4e6a6ef6225b3e5d59c7afb35e994",
"started_at": "2026-11-16T19:18:58.195689773Z",
"running": true,
"user": "",
"volumes": [
"kuznetsov-lab3_pgdata"
]
},
"lb": {
"id": "68b269bee797b8fb4b855a25969793a9d1160f7959fefcc8982abbe0e642d9ef",
"image": "sha256:1242e4006ac3f1ed15871efadca3d8d089e76f720017a1c51747133ee40cc953",
"started_at": "2026-11-16T19:18:58.120987029Z",
"running": true,
"user": "haproxy",
"volumes": []
}
},
"stop_seconds": 2.111,
"metrics": {
"observed_instances_before": 2,
"successful_writes": 115,
"failed_attempts": 3,
"first_recovery_seconds": 4.508
}
},
"second_replica": {
"service": "api1",
"target_instance": "5047bb490b0a4fc5b07d22d0768a0e99",
"before": {
"api1": {
"instance_id": "5047bb490b0a4fc5b07d22d0768a0e99",
"container_id": "507f14400f4fd4591391920e26ffb793859af0c423a7d9e858f1bf66a8b7b2f1"
},
"api2": {
"instance_id": "4f0e086687c94a0a80d9111a9c83f04e",
"container_id": "661c0fb5e5d3ba0553bdc4af3aa653877e7f9d002acba05cb1d758cf27b2cef7"
}
},
"after": {
"api1": {
"id": "507f14400f4fd4591391920e26ffb793859af0c423a7d9e858f1bf66a8b7b2f1",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:18:58.414235595Z",
"running": false,
"user": "messenger",
"volumes": []
},
"api2": {
"id": "661c0fb5e5d3ba0553bdc4af3aa653877e7f9d002acba05cb1d758cf27b2cef7",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:19:22.964997834Z",
"running": true,
"user": "messenger",
"volumes": []
},
"db": {
"id": "27554c7dfdfe16221938def671c50cb7fe3a2950bf6d2786829564728097a2b4",
"image": "sha256:665dc7b37ac52a17e298511414c21d23ffa4e6a6ef6225b3e5d59c7afb35e994",
"started_at": "2026-11-16T19:18:58.195689773Z",
"running": true,
"user": "",
"volumes": [
"kuznetsov-lab3_pgdata"
]
},
"lb": {
"id": "68b269bee797b8fb4b855a25969793a9d1160f7959fefcc8982abbe0e642d9ef",
"image": "sha256:1242e4006ac3f1ed15871efadca3d8d089e76f720017a1c51747133ee40cc953",
"started_at": "2026-11-16T19:18:58.120987029Z",
"running": true,
"user": "haproxy",
"volumes": []
}
},
"stop_seconds": 2.198,
"metrics": {
"successful_writes": 105,
"failed_attempts": 4,
"first_recovery_seconds": 4.903,
"replay_on_survivor": "PASS"
}
},
"status": "PASS"
}
+19
View File
@@ -0,0 +1,19 @@
{
"idempotency_after_restart": "PASS",
"public_persistence": "PASS",
"cursor_after_restart": "PASS",
"logout_after_restart": "PASS",
"migration_replay": "PASS",
"database": {
"users": 85,
"chats": 30,
"members": 59,
"messages": 132,
"sessions": 81,
"migrations": 2,
"idempotency_keys": 131,
"expiry_fingerprint": "cbe12ea82e21ad631a3fc1fc9eda03cf",
"passwords_are_argon2id": true,
"session_hashes_only": true
}
}
+75
View File
@@ -0,0 +1,75 @@
{
"project": "kuznetsov-lab3",
"before": {
"api1": {
"id": "507f14400f4fd4591391920e26ffb793859af0c423a7d9e858f1bf66a8b7b2f1",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:18:40.942462168Z",
"running": true,
"user": "messenger",
"volumes": []
},
"api2": {
"id": "661c0fb5e5d3ba0553bdc4af3aa653877e7f9d002acba05cb1d758cf27b2cef7",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:18:40.77808525Z",
"running": true,
"user": "messenger",
"volumes": []
},
"db": {
"id": "27554c7dfdfe16221938def671c50cb7fe3a2950bf6d2786829564728097a2b4",
"image": "sha256:665dc7b37ac52a17e298511414c21d23ffa4e6a6ef6225b3e5d59c7afb35e994",
"started_at": "2026-11-16T19:18:37.397863614Z",
"running": true,
"user": "",
"volumes": [
"kuznetsov-lab3_pgdata"
]
},
"lb": {
"id": "68b269bee797b8fb4b855a25969793a9d1160f7959fefcc8982abbe0e642d9ef",
"image": "sha256:1242e4006ac3f1ed15871efadca3d8d089e76f720017a1c51747133ee40cc953",
"started_at": "2026-11-16T19:18:41.110660867Z",
"running": true,
"user": "haproxy",
"volumes": []
}
},
"after": {
"api1": {
"id": "507f14400f4fd4591391920e26ffb793859af0c423a7d9e858f1bf66a8b7b2f1",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:18:58.414235595Z",
"running": true,
"user": "messenger",
"volumes": []
},
"api2": {
"id": "661c0fb5e5d3ba0553bdc4af3aa653877e7f9d002acba05cb1d758cf27b2cef7",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:18:58.362001356Z",
"running": true,
"user": "messenger",
"volumes": []
},
"db": {
"id": "27554c7dfdfe16221938def671c50cb7fe3a2950bf6d2786829564728097a2b4",
"image": "sha256:665dc7b37ac52a17e298511414c21d23ffa4e6a6ef6225b3e5d59c7afb35e994",
"started_at": "2026-11-16T19:18:58.195689773Z",
"running": true,
"user": "",
"volumes": [
"kuznetsov-lab3_pgdata"
]
},
"lb": {
"id": "68b269bee797b8fb4b855a25969793a9d1160f7959fefcc8982abbe0e642d9ef",
"image": "sha256:1242e4006ac3f1ed15871efadca3d8d089e76f720017a1c51747133ee40cc953",
"started_at": "2026-11-16T19:18:58.120987029Z",
"running": true,
"user": "haproxy",
"volumes": []
}
}
}
+51
View File
@@ -0,0 +1,51 @@
{
"service": "api1",
"target_instance": "5047bb490b0a4fc5b07d22d0768a0e99",
"before": {
"api1": {
"instance_id": "5047bb490b0a4fc5b07d22d0768a0e99",
"container_id": "507f14400f4fd4591391920e26ffb793859af0c423a7d9e858f1bf66a8b7b2f1"
},
"api2": {
"instance_id": "4f0e086687c94a0a80d9111a9c83f04e",
"container_id": "661c0fb5e5d3ba0553bdc4af3aa653877e7f9d002acba05cb1d758cf27b2cef7"
}
},
"after": {
"api1": {
"id": "507f14400f4fd4591391920e26ffb793859af0c423a7d9e858f1bf66a8b7b2f1",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:18:58.414235595Z",
"running": false,
"user": "messenger",
"volumes": []
},
"api2": {
"id": "661c0fb5e5d3ba0553bdc4af3aa653877e7f9d002acba05cb1d758cf27b2cef7",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:19:22.964997834Z",
"running": true,
"user": "messenger",
"volumes": []
},
"db": {
"id": "27554c7dfdfe16221938def671c50cb7fe3a2950bf6d2786829564728097a2b4",
"image": "sha256:665dc7b37ac52a17e298511414c21d23ffa4e6a6ef6225b3e5d59c7afb35e994",
"started_at": "2026-11-16T19:18:58.195689773Z",
"running": true,
"user": "",
"volumes": [
"kuznetsov-lab3_pgdata"
]
},
"lb": {
"id": "68b269bee797b8fb4b855a25969793a9d1160f7959fefcc8982abbe0e642d9ef",
"image": "sha256:1242e4006ac3f1ed15871efadca3d8d089e76f720017a1c51747133ee40cc953",
"started_at": "2026-11-16T19:18:58.120987029Z",
"running": true,
"user": "haproxy",
"volumes": []
}
},
"stop_seconds": 2.198
}
+198
View File
@@ -0,0 +1,198 @@
{
"date_utc": "2026-11-16T19:18:01.388967+00:00",
"platform": "Windows-11-10.0.26200-SP0",
"source_commit": "0ab3a341aa7ba32363ce43061d4ff02b1f2964af",
"worktree_dirty_at_start": true,
"project": "kuznetsov-lab3",
"status": "PASS",
"persistence": {
"idempotency_after_restart": "PASS",
"public_persistence": "PASS",
"cursor_after_restart": "PASS",
"logout_after_restart": "PASS",
"migration_replay": "PASS",
"database": {
"users": 85,
"chats": 30,
"members": 59,
"messages": 132,
"sessions": 81,
"migrations": 2,
"idempotency_keys": 131,
"expiry_fingerprint": "cbe12ea82e21ad631a3fc1fc9eda03cf",
"passwords_are_argon2id": true,
"session_hashes_only": true
}
},
"failover": {
"public": {
"service": "api2",
"target_instance": "610aec79ba3b43ae8f846930b60d9293",
"before": {
"api1": {
"instance_id": "5047bb490b0a4fc5b07d22d0768a0e99",
"container_id": "507f14400f4fd4591391920e26ffb793859af0c423a7d9e858f1bf66a8b7b2f1"
},
"api2": {
"instance_id": "610aec79ba3b43ae8f846930b60d9293",
"container_id": "661c0fb5e5d3ba0553bdc4af3aa653877e7f9d002acba05cb1d758cf27b2cef7"
}
},
"after": {
"api1": {
"id": "507f14400f4fd4591391920e26ffb793859af0c423a7d9e858f1bf66a8b7b2f1",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:18:58.414235595Z",
"running": true,
"user": "messenger",
"volumes": []
},
"api2": {
"id": "661c0fb5e5d3ba0553bdc4af3aa653877e7f9d002acba05cb1d758cf27b2cef7",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:18:58.362001356Z",
"running": false,
"user": "messenger",
"volumes": []
},
"db": {
"id": "27554c7dfdfe16221938def671c50cb7fe3a2950bf6d2786829564728097a2b4",
"image": "sha256:665dc7b37ac52a17e298511414c21d23ffa4e6a6ef6225b3e5d59c7afb35e994",
"started_at": "2026-11-16T19:18:58.195689773Z",
"running": true,
"user": "",
"volumes": [
"kuznetsov-lab3_pgdata"
]
},
"lb": {
"id": "68b269bee797b8fb4b855a25969793a9d1160f7959fefcc8982abbe0e642d9ef",
"image": "sha256:1242e4006ac3f1ed15871efadca3d8d089e76f720017a1c51747133ee40cc953",
"started_at": "2026-11-16T19:18:58.120987029Z",
"running": true,
"user": "haproxy",
"volumes": []
}
},
"stop_seconds": 2.111,
"metrics": {
"observed_instances_before": 2,
"successful_writes": 115,
"failed_attempts": 3,
"first_recovery_seconds": 4.508
}
},
"second_replica": {
"service": "api1",
"target_instance": "5047bb490b0a4fc5b07d22d0768a0e99",
"before": {
"api1": {
"instance_id": "5047bb490b0a4fc5b07d22d0768a0e99",
"container_id": "507f14400f4fd4591391920e26ffb793859af0c423a7d9e858f1bf66a8b7b2f1"
},
"api2": {
"instance_id": "4f0e086687c94a0a80d9111a9c83f04e",
"container_id": "661c0fb5e5d3ba0553bdc4af3aa653877e7f9d002acba05cb1d758cf27b2cef7"
}
},
"after": {
"api1": {
"id": "507f14400f4fd4591391920e26ffb793859af0c423a7d9e858f1bf66a8b7b2f1",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:18:58.414235595Z",
"running": false,
"user": "messenger",
"volumes": []
},
"api2": {
"id": "661c0fb5e5d3ba0553bdc4af3aa653877e7f9d002acba05cb1d758cf27b2cef7",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:19:22.964997834Z",
"running": true,
"user": "messenger",
"volumes": []
},
"db": {
"id": "27554c7dfdfe16221938def671c50cb7fe3a2950bf6d2786829564728097a2b4",
"image": "sha256:665dc7b37ac52a17e298511414c21d23ffa4e6a6ef6225b3e5d59c7afb35e994",
"started_at": "2026-11-16T19:18:58.195689773Z",
"running": true,
"user": "",
"volumes": [
"kuznetsov-lab3_pgdata"
]
},
"lb": {
"id": "68b269bee797b8fb4b855a25969793a9d1160f7959fefcc8982abbe0e642d9ef",
"image": "sha256:1242e4006ac3f1ed15871efadca3d8d089e76f720017a1c51747133ee40cc953",
"started_at": "2026-11-16T19:18:58.120987029Z",
"running": true,
"user": "haproxy",
"volumes": []
}
},
"stop_seconds": 2.198,
"metrics": {
"successful_writes": 105,
"failed_attempts": 4,
"first_recovery_seconds": 4.903,
"replay_on_survivor": "PASS"
}
},
"status": "PASS"
},
"expiry": {
"ttl_seconds": 2,
"expiry_unchanged_on_restart": true,
"before_restart": 200,
"after_expiry_and_restart": 401,
"new_login": 201
},
"dependency": {
"live_without_db": 200,
"ready_without_db": 503,
"business_without_db": 503,
"recovered": 200
},
"containers": {
"api1": {
"id": "507f14400f4fd4591391920e26ffb793859af0c423a7d9e858f1bf66a8b7b2f1",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:19:43.768338589Z",
"running": true,
"user": "messenger",
"volumes": []
},
"api2": {
"id": "661c0fb5e5d3ba0553bdc4af3aa653877e7f9d002acba05cb1d758cf27b2cef7",
"image": "sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e",
"started_at": "2026-11-16T19:19:22.964997834Z",
"running": true,
"user": "messenger",
"volumes": []
},
"db": {
"id": "27554c7dfdfe16221938def671c50cb7fe3a2950bf6d2786829564728097a2b4",
"image": "sha256:665dc7b37ac52a17e298511414c21d23ffa4e6a6ef6225b3e5d59c7afb35e994",
"started_at": "2026-11-16T19:20:08.884908456Z",
"running": true,
"user": "",
"volumes": [
"kuznetsov-lab3_pgdata"
]
},
"lb": {
"id": "68b269bee797b8fb4b855a25969793a9d1160f7959fefcc8982abbe0e642d9ef",
"image": "sha256:1242e4006ac3f1ed15871efadca3d8d089e76f720017a1c51747133ee40cc953",
"started_at": "2026-11-16T19:18:58.120987029Z",
"running": true,
"user": "haproxy",
"volumes": []
}
},
"docker": "29.9.3",
"resources": {
"cpus": 12,
"memory_bytes": 16591364096
}
}
+246
View File
@@ -0,0 +1,246 @@
Environment ready; existing settings and secrets preserved
$ ".\.venv\Scripts\python.exe" -X utf8 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
$ ".\.venv\Scripts\python.exe" -X utf8 scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
$ docker compose --project-name kuznetsov-lab3 --env-file .env config --quiet
$ docker compose --project-name kuznetsov-lab3 --env-file .env config --quiet
$ docker compose --project-name kuznetsov-lab3 --env-file .env build api1
Image mtusi-messenger:kuznetsov-lab3 Building
#1 [internal] load local bake definitions
#1 reading from stdin 1.18kB 0.0s done
#1 DONE 0.0s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 728B done
#2 DONE 0.0s
#3 [internal] load metadata for docker.io/library/python:3.13.14-slim-bookworm@sha256:67a1e1f215ccda113cfc024e8639049257e88f273898f595b61476d128d387e8
#3 DONE 0.0s
#4 [internal] load .dockerignore
#4 transferring context: 246B done
#4 DONE 0.0s
#5 [internal] load build context
#5 transferring context: 29.41kB done
#5 DONE 0.0s
#6 [1/6] FROM docker.io/library/python:3.13.14-slim-bookworm@sha256:67a1e1f215ccda113cfc024e8639049257e88f273898f595b61476d128d387e8
#6 resolve docker.io/library/python:3.13.14-slim-bookworm@sha256:67a1e1f215ccda113cfc024e8639049257e88f273898f595b61476d128d387e8 0.0s done
#6 DONE 0.0s
#7 [2/6] WORKDIR /app
#7 CACHED
#8 [3/6] COPY requirements.lock .
#8 CACHED
#9 [5/6] COPY src ./src
#9 CACHED
#10 [4/6] RUN python -m pip install --no-cache-dir -r requirements.lock && useradd --uid 10001 --create-home messenger
#10 CACHED
#11 [6/6] COPY migrations ./migrations
#11 CACHED
#12 exporting to image
#12 exporting layers done
#12 exporting manifest sha256:a3d0f132fa9296c0d0ae311c2ddddf30fcd6bcecdd528a7a6b83610bc6f78d55 0.0s done
#12 exporting config sha256:8f192856e8c06f99020d20dd6a79da3ead41d9d106f36957f2c3703ee60521ca 0.0s done
#12 exporting attestation manifest sha256:5ed3f3eb5c6be0a6fdc47cd44dcc7ec5d6e44244975bac604f6856e39c6570e8 0.0s done
#12 exporting manifest list sha256:c81e768c9996b7b4938b93c9a39dea208053025b1d8fb429dea6d534aab1c69e 0.0s done
#12 naming to docker.io/library/mtusi-messenger:kuznetsov-lab3 done
#12 unpacking to docker.io/library/mtusi-messenger:kuznetsov-lab3 done
#12 DONE 0.1s
#13 resolving provenance for metadata file
#13 DONE 0.0s
Image mtusi-messenger:kuznetsov-lab3 Built
$ docker compose --project-name kuznetsov-lab3 --env-file .env run --rm --no-deps lb haproxy -c -f /usr/local/etc/haproxy/haproxy.cfg
Volume kuznetsov-lab3_pgdata Creating
Volume kuznetsov-lab3_pgdata Creating
Network kuznetsov-lab3_default Creating
Network kuznetsov-lab3_default Creating
Volume kuznetsov-lab3_pgdata Created
Volume kuznetsov-lab3_pgdata Created
Network kuznetsov-lab3_default Created
Network kuznetsov-lab3_default Created
Container kuznetsov-lab3-lb-run-193abe66af6f Creating
Container kuznetsov-lab3-lb-run-193abe66af6f Created
[NOTICE] (1) : [/usr/local/etc/haproxy/haproxy.cfg:35] : 'server api_ready/first' : could not resolve address 'api1', disabling server.
[NOTICE] (1) : [/usr/local/etc/haproxy/haproxy.cfg:36] : 'server api_ready/second' : could not resolve address 'api2', disabling server.
[NOTICE] (1) : [/usr/local/etc/haproxy/haproxy.cfg:43] : 'server api_live/first' : could not resolve address 'api1', disabling server.
[NOTICE] (1) : [/usr/local/etc/haproxy/haproxy.cfg:44] : 'server api_live/second' : could not resolve address 'api2', disabling server.
$ docker compose --project-name kuznetsov-lab3 --env-file .env up -d --no-build db migrate api1 api2 lb
Container kuznetsov-lab3-db-1 Creating
Container kuznetsov-lab3-db-1 Created
Container kuznetsov-lab3-migrate-1 Creating
Container kuznetsov-lab3-migrate-1 Created
Container kuznetsov-lab3-api1-1 Creating
Container kuznetsov-lab3-api2-1 Creating
Container kuznetsov-lab3-api2-1 Created
Container kuznetsov-lab3-api1-1 Created
Container kuznetsov-lab3-lb-1 Creating
Container kuznetsov-lab3-lb-1 Created
Container kuznetsov-lab3-db-1 Starting
Container kuznetsov-lab3-db-1 Started
Container kuznetsov-lab3-db-1 Waiting
Container kuznetsov-lab3-db-1 Healthy
Container kuznetsov-lab3-migrate-1 Starting
Container kuznetsov-lab3-migrate-1 Started
Container kuznetsov-lab3-migrate-1 Waiting
Container kuznetsov-lab3-migrate-1 Exited
Container kuznetsov-lab3-api2-1 Starting
Container kuznetsov-lab3-api1-1 Starting
Container kuznetsov-lab3-api2-1 Started
Container kuznetsov-lab3-api1-1 Started
Container kuznetsov-lab3-lb-1 Starting
Container kuznetsov-lab3-lb-1 Started
Two API replicas ready through LB: http://127.0.0.1:18103
$ ".\.venv\Scripts\python.exe" -X utf8 tests/smoke.py --base-url http://127.0.0.1:18103
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
$ ".\.venv\Scripts\python.exe" -X utf8 -m unittest discover -s student-tests -v
test_auth_and_access (test_api.ApiTests.test_auth_and_access) ... ok
test_bad_cursors_and_limits (test_api.ApiTests.test_bad_cursors_and_limits) ... ok
test_chat_pagination (test_api.ApiTests.test_chat_pagination) ... ok
test_chat_validation_is_atomic (test_api.ApiTests.test_chat_validation_is_atomic) ... ok
test_invalid_json_and_content_type (test_api.ApiTests.test_invalid_json_and_content_type) ... ok
test_message_fields_and_unicode (test_api.ApiTests.test_message_fields_and_unicode) ... ok
test_message_pagination (test_api.ApiTests.test_message_pagination) ... ok
test_parallel_messages (test_api.ApiTests.test_parallel_messages) ... ok
test_parallel_username (test_api.ApiTests.test_parallel_username) ... ok
test_read_after_write (test_api.ApiTests.test_read_after_write) ... ok
test_user_fields (test_api.ApiTests.test_user_fields) ... ok
test_different_body_conflicts (test_idempotency.IdempotencyTests.test_different_body_conflicts) ... ok
test_failure_rolls_back_message_and_key (test_idempotency.IdempotencyTests.test_failure_rolls_back_message_and_key) ... ok
test_invalid_body_does_not_reserve_key (test_idempotency.IdempotencyTests.test_invalid_body_does_not_reserve_key) ... ok
test_key_required_and_format (test_idempotency.IdempotencyTests.test_key_required_and_format) ... ok
test_replay_normalizes_json (test_idempotency.IdempotencyTests.test_replay_normalizes_json) ... ok
test_replay_still_checks_access_and_session (test_idempotency.IdempotencyTests.test_replay_still_checks_access_and_session) ... ok
test_retention_and_expired_key_reuse (test_idempotency.IdempotencyTests.test_retention_and_expired_key_reuse) ... ok
test_same_session_on_both_instances (test_idempotency.IdempotencyTests.test_same_session_on_both_instances) ... ok
test_scope_is_user_and_chat_not_session (test_idempotency.IdempotencyTests.test_scope_is_user_and_chat_not_session) ... ok
test_twenty_concurrent_requests_use_both_replicas (test_idempotency.IdempotencyTests.test_twenty_concurrent_requests_use_both_replicas) ... ok
test_logout_only_revokes_current_session (test_sessions.SessionTests.test_logout_only_revokes_current_session) ... ok
test_malformed_basic_and_body (test_sessions.SessionTests.test_malformed_basic_and_body) ... ok
test_only_bearer_identifies_user (test_sessions.SessionTests.test_only_bearer_identifies_user) ... ok
test_password_boundaries_unicode_colon_spaces (test_sessions.SessionTests.test_password_boundaries_unicode_colon_spaces) ... ok
test_password_required_and_limits (test_sessions.SessionTests.test_password_required_and_limits) ... ok
test_wrong_and_unknown_credentials (test_sessions.SessionTests.test_wrong_and_unknown_credentials) ... ok
----------------------------------------------------------------------
Ran 27 tests in 9.649s
OK
$ ".\.venv\Scripts\python.exe" -X utf8 tests/resilience.py --mode persistence --action-script ".\scripts\restart.cmd" --base-url http://127.0.0.1:18103
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
$ docker compose --project-name kuznetsov-lab3 --env-file .env run --rm --no-deps migrate
Container kuznetsov-lab3-migrate-run-081dd93a6626 Creating
Container kuznetsov-lab3-migrate-run-081dd93a6626 Created
Already applied: 001_initial.sql
Already applied: 002_idempotency.sql
$ docker compose --project-name kuznetsov-lab3 --env-file .env run --rm --no-deps migrate
Container kuznetsov-lab3-migrate-run-2367ac7a347b Creating
Container kuznetsov-lab3-migrate-run-2367ac7a347b Created
Already applied: 001_initial.sql
Already applied: 002_idempotency.sql
PASS: old session/cursor, durable logout and repeatable migrations
$ ".\.venv\Scripts\python.exe" -X utf8 tests/resilience.py --mode failover --action-script ".\scripts\stop-one.cmd" --base-url http://127.0.0.1:18103
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 115, "failed_attempts": 3, "first_recovery_seconds": 4.508}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
$ docker compose --project-name kuznetsov-lab3 --env-file .env start api1 api2
Container kuznetsov-lab3-db-1 Waiting
Container kuznetsov-lab3-db-1 Healthy
Container kuznetsov-lab3-migrate-1 Starting
Container kuznetsov-lab3-migrate-1 Started
Container kuznetsov-lab3-migrate-1 Waiting
Container kuznetsov-lab3-migrate-1 Exited
Container kuznetsov-lab3-api2-1 Starting
Container kuznetsov-lab3-api2-1 Started
PASS: both physical API replicas stopped separately; no lost messages or duplicates
$ docker compose --project-name kuznetsov-lab3 --env-file .env start api1 api2
Container kuznetsov-lab3-db-1 Waiting
Container kuznetsov-lab3-db-1 Healthy
Container kuznetsov-lab3-migrate-1 Starting
Container kuznetsov-lab3-migrate-1 Started
Container kuznetsov-lab3-migrate-1 Waiting
Container kuznetsov-lab3-migrate-1 Exited
Container kuznetsov-lab3-api1-1 Starting
Container kuznetsov-lab3-api1-1 Started
$ docker compose --project-name kuznetsov-lab3-ttl --env-file .env up -d --no-build db migrate api1 api2 lb
Volume kuznetsov-lab3-ttl_pgdata Creating
Volume kuznetsov-lab3-ttl_pgdata Creating
Network kuznetsov-lab3-ttl_default Creating
Network kuznetsov-lab3-ttl_default Creating
Volume kuznetsov-lab3-ttl_pgdata Created
Volume kuznetsov-lab3-ttl_pgdata Created
Network kuznetsov-lab3-ttl_default Created
Network kuznetsov-lab3-ttl_default Created
Container kuznetsov-lab3-ttl-db-1 Creating
Container kuznetsov-lab3-ttl-db-1 Created
Container kuznetsov-lab3-ttl-migrate-1 Creating
Container kuznetsov-lab3-ttl-migrate-1 Created
Container kuznetsov-lab3-ttl-api2-1 Creating
Container kuznetsov-lab3-ttl-api1-1 Creating
Container kuznetsov-lab3-ttl-api1-1 Created
Container kuznetsov-lab3-ttl-api2-1 Created
Container kuznetsov-lab3-ttl-lb-1 Creating
Container kuznetsov-lab3-ttl-lb-1 Created
Container kuznetsov-lab3-ttl-db-1 Starting
Container kuznetsov-lab3-ttl-db-1 Started
Container kuznetsov-lab3-ttl-db-1 Waiting
Container kuznetsov-lab3-ttl-db-1 Healthy
Container kuznetsov-lab3-ttl-migrate-1 Starting
Container kuznetsov-lab3-ttl-migrate-1 Started
Container kuznetsov-lab3-ttl-migrate-1 Waiting
Container kuznetsov-lab3-ttl-migrate-1 Exited
Container kuznetsov-lab3-ttl-api2-1 Starting
Container kuznetsov-lab3-ttl-api1-1 Starting
Container kuznetsov-lab3-ttl-api2-1 Started
Container kuznetsov-lab3-ttl-api1-1 Started
Container kuznetsov-lab3-ttl-lb-1 Starting
Container kuznetsov-lab3-ttl-lb-1 Started
Two API replicas ready through LB: http://127.0.0.1:18113
$ docker compose --project-name kuznetsov-lab3-ttl --env-file .env restart --timeout 3 api1 api2
Container kuznetsov-lab3-ttl-api1-1 Restarting
Container kuznetsov-lab3-ttl-api2-1 Restarting
Container kuznetsov-lab3-ttl-api1-1 Started
Container kuznetsov-lab3-ttl-api2-1 Started
PASS: TTL=2, expired token rejected after API restart; fresh login works
$ docker compose --project-name kuznetsov-lab3-ttl --env-file .env down --timeout 10
Container kuznetsov-lab3-ttl-lb-1 Stopping
Container kuznetsov-lab3-ttl-lb-1 Stopped
Container kuznetsov-lab3-ttl-lb-1 Removing
Container kuznetsov-lab3-ttl-lb-1 Removed
Container kuznetsov-lab3-ttl-api2-1 Stopping
Container kuznetsov-lab3-ttl-api1-1 Stopping
Container kuznetsov-lab3-ttl-api2-1 Stopped
Container kuznetsov-lab3-ttl-api2-1 Removing
Container kuznetsov-lab3-ttl-api2-1 Removed
Container kuznetsov-lab3-ttl-api1-1 Stopped
Container kuznetsov-lab3-ttl-api1-1 Removing
Container kuznetsov-lab3-ttl-api1-1 Removed
Container kuznetsov-lab3-ttl-migrate-1 Stopping
Container kuznetsov-lab3-ttl-migrate-1 Stopped
Container kuznetsov-lab3-ttl-migrate-1 Removing
Container kuznetsov-lab3-ttl-migrate-1 Removed
Container kuznetsov-lab3-ttl-db-1 Stopping
Container kuznetsov-lab3-ttl-db-1 Stopped
Container kuznetsov-lab3-ttl-db-1 Removing
Container kuznetsov-lab3-ttl-db-1 Removed
Network kuznetsov-lab3-ttl_default Removing
Network kuznetsov-lab3-ttl_default Removed
$ docker compose --project-name kuznetsov-lab3 --env-file .env stop --timeout 10 db
Container kuznetsov-lab3-db-1 Stopping
Container kuznetsov-lab3-db-1 Stopped
$ docker compose --project-name kuznetsov-lab3 --env-file .env start db
Container kuznetsov-lab3-db-1 Starting
Container kuznetsov-lab3-db-1 Started
PASS: DB outage -> live=200, ready/business=503; session works after recovery
$ ".\.venv\Scripts\python.exe" -X utf8 tests/smoke.py --base-url http://127.0.0.1:18103
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
PASS: full lab3 verification