ЛР 3: HAProxy + 2 реплики, общая идемпотентность, rolling update

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LOSYASH
2026-10-22 18:21:19 +03:00
co-authored by Claude Opus 5.5
parent 0ab3a341aa
commit a71c582195
54 changed files with 3192 additions and 40 deletions
+13
View File
@@ -0,0 +1,13 @@
Container mtusi-lab3-postgres-1 Running
Container mtusi-lab3-postgres-1 Waiting
Container mtusi-lab3-postgres-1 Healthy
Container mtusi-lab3-api-ttl-1 Starting
Container mtusi-lab3-api-ttl-1 Started
ok - login -> 201
ok - expires_at is about 2s ahead (got 1.99s)
ok - token works before expiry
ok - expired token -> 401 (cache does not extend the session)
4 passed, 0 failed
Container mtusi-lab3-api-ttl-1 Stopping
Container mtusi-lab3-api-ttl-1 Stopped
+59
View File
@@ -0,0 +1,59 @@
{
"workload": "4 closed-loop writers, retry same key on failure, 4s before + 12s after stop",
"replicas": [
{
"stopped_instance": "b5c5b15326cd",
"stop_command_seconds": 1.99,
"before": {
"successful": 502,
"errors": 0,
"successful_rps": 125.4
},
"first_10s_after_stop": {
"successful": 990,
"errors": 1,
"successful_rps": 99.0
},
"first_success_after_stop_s": 0.001,
"max_gap_without_success_after_stop_s": 0.175,
"stopped_instance_served_after_3s": 0,
"instances_after_stop": [
"c2fc366c1f6b"
],
"history_messages": 2035,
"confirmed": 2035,
"lost_or_changed": 0,
"duplicate_texts": 0,
"retries_with_same_key": 1,
"rejoin_seconds": 3.7,
"rejoin_including_start_s": 4.03
},
{
"stopped_instance": "c2fc366c1f6b",
"stop_command_seconds": 0.99,
"before": {
"successful": 621,
"errors": 0,
"successful_rps": 155.2
},
"first_10s_after_stop": {
"successful": 915,
"errors": 1,
"successful_rps": 91.5
},
"first_success_after_stop_s": 0.002,
"max_gap_without_success_after_stop_s": 0.475,
"stopped_instance_served_after_3s": 0,
"instances_after_stop": [
"b5c5b15326cd"
],
"history_messages": 1698,
"confirmed": 1698,
"lost_or_changed": 0,
"duplicate_texts": 0,
"retries_with_same_key": 1,
"rejoin_seconds": 3.83,
"rejoin_including_start_s": 4.18
}
]
}
+71
View File
@@ -0,0 +1,71 @@
ok - at least 2 API replicas running (2)
== Ёхяышър b5c5b15326cd ==
ok - LB serves b5c5b15326cd before the test
{
"stopped_instance": "b5c5b15326cd",
"stop_command_seconds": 1.99,
"before": {
"successful": 502,
"errors": 0,
"successful_rps": 125.4
},
"first_10s_after_stop": {
"successful": 990,
"errors": 1,
"successful_rps": 99.0
},
"first_success_after_stop_s": 0.001,
"max_gap_without_success_after_stop_s": 0.175,
"stopped_instance_served_after_3s": 0,
"instances_after_stop": [
"c2fc366c1f6b"
],
"history_messages": 2035,
"confirmed": 2035,
"lost_or_changed": 0,
"duplicate_texts": 0,
"retries_with_same_key": 1,
"rejoin_seconds": 3.7,
"rejoin_including_start_s": 4.03
}
ok - writes resumed within 10 s after stopping b5c5b15326cd
ok - stopped b5c5b15326cd not served after detection
ok - confirmed messages preserved
ok - no duplicates despite retries with the same key
ok - b5c5b15326cd rejoined the LB after restart
== Ёхяышър c2fc366c1f6b ==
ok - LB serves c2fc366c1f6b before the test
{
"stopped_instance": "c2fc366c1f6b",
"stop_command_seconds": 0.99,
"before": {
"successful": 621,
"errors": 0,
"successful_rps": 155.2
},
"first_10s_after_stop": {
"successful": 915,
"errors": 1,
"successful_rps": 91.5
},
"first_success_after_stop_s": 0.002,
"max_gap_without_success_after_stop_s": 0.475,
"stopped_instance_served_after_3s": 0,
"instances_after_stop": [
"b5c5b15326cd"
],
"history_messages": 1698,
"confirmed": 1698,
"lost_or_changed": 0,
"duplicate_texts": 0,
"retries_with_same_key": 1,
"rejoin_seconds": 3.83,
"rejoin_including_start_s": 4.18
}
ok - writes resumed within 10 s after stopping c2fc366c1f6b
ok - stopped c2fc366c1f6b not served after detection
ok - confirmed messages preserved
ok - no duplicates despite retries with the same key
ok - c2fc366c1f6b rejoined the LB after restart
13 passed, 0 failed
+59
View File
@@ -0,0 +1,59 @@
{
"workload": "4 closed-loop writers, retry same key on failure, 4s before + 12s after stop",
"replicas": [
{
"stopped_instance": "api-a",
"stop_command_seconds": 0.05,
"before": {
"successful": 1539,
"errors": 0,
"successful_rps": 384.4
},
"first_10s_after_stop": {
"successful": 3427,
"errors": 3,
"successful_rps": 342.7
},
"first_success_after_stop_s": 0.001,
"max_gap_without_success_after_stop_s": 0.068,
"stopped_instance_served_after_3s": 0,
"instances_after_stop": [
"api-b"
],
"history_messages": 5659,
"confirmed": 5659,
"lost_or_changed": 0,
"duplicate_texts": 0,
"retries_with_same_key": 3,
"rejoin_seconds": 2.59,
"rejoin_including_start_s": 2.6
},
{
"stopped_instance": "api-b",
"stop_command_seconds": 0.05,
"before": {
"successful": 1518,
"errors": 0,
"successful_rps": 379.2
},
"first_10s_after_stop": {
"successful": 3256,
"errors": 3,
"successful_rps": 325.6
},
"first_success_after_stop_s": 0.001,
"max_gap_without_success_after_stop_s": 0.052,
"stopped_instance_served_after_3s": 0,
"instances_after_stop": [
"api-a"
],
"history_messages": 5534,
"confirmed": 5534,
"lost_or_changed": 0,
"duplicate_texts": 0,
"retries_with_same_key": 3,
"rejoin_seconds": 2.09,
"rejoin_including_start_s": 2.09
}
]
}
+71
View File
@@ -0,0 +1,71 @@
ok - at least 2 API replicas running (2)
== реплика api-a ==
ok - LB serves api-a before the test
{
"stopped_instance": "api-a",
"stop_command_seconds": 0.05,
"before": {
"successful": 1539,
"errors": 0,
"successful_rps": 384.4
},
"first_10s_after_stop": {
"successful": 3427,
"errors": 3,
"successful_rps": 342.7
},
"first_success_after_stop_s": 0.001,
"max_gap_without_success_after_stop_s": 0.068,
"stopped_instance_served_after_3s": 0,
"instances_after_stop": [
"api-b"
],
"history_messages": 5659,
"confirmed": 5659,
"lost_or_changed": 0,
"duplicate_texts": 0,
"retries_with_same_key": 3,
"rejoin_seconds": 2.59,
"rejoin_including_start_s": 2.6
}
ok - writes resumed within 10 s after stopping api-a
ok - stopped api-a not served after detection
ok - confirmed messages preserved
ok - no duplicates despite retries with the same key
ok - api-a rejoined the LB after restart
== реплика api-b ==
ok - LB serves api-b before the test
{
"stopped_instance": "api-b",
"stop_command_seconds": 0.05,
"before": {
"successful": 1518,
"errors": 0,
"successful_rps": 379.2
},
"first_10s_after_stop": {
"successful": 3256,
"errors": 3,
"successful_rps": 325.6
},
"first_success_after_stop_s": 0.001,
"max_gap_without_success_after_stop_s": 0.052,
"stopped_instance_served_after_3s": 0,
"instances_after_stop": [
"api-a"
],
"history_messages": 5534,
"confirmed": 5534,
"lost_or_changed": 0,
"duplicate_texts": 0,
"retries_with_same_key": 3,
"rejoin_seconds": 2.09,
"rejoin_including_start_s": 2.09
}
ok - writes resumed within 10 s after stopping api-b
ok - stopped api-b not served after detection
ok - confirmed messages preserved
ok - no duplicates despite retries with the same key
ok - api-b rejoined the LB after restart
13 passed, 0 failed
+32
View File
@@ -0,0 +1,32 @@
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 108, "failed_attempts": 0, "first_recovery_seconds": 1.751}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab3-api-5 mtusi-messenger:lab3 "python -m app" api 8 minutes ago Up 8 minutes (healthy) 8080/tcp
mtusi-lab3-api-6 mtusi-messenger:lab3 "python -m app" api 8 minutes ago Exited (0) 14 seconds ago
Container mtusi-lab3-postgres-1 Waiting
Container mtusi-lab3-postgres-1 Healthy
Container mtusi-lab3-migrate-1 Starting
Container mtusi-lab3-migrate-1 Started
Container mtusi-lab3-migrate-1 Waiting
Container mtusi-lab3-postgres-1 Waiting
Container mtusi-lab3-postgres-1 Healthy
Container mtusi-lab3-migrate-1 Exited
Container mtusi-lab3-api-6 Starting
Container mtusi-lab3-api-6 Started
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 106, "failed_attempts": 0, "first_recovery_seconds": 1.862}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab3-api-5 mtusi-messenger:lab3 "python -m app" api 9 minutes ago Up 9 minutes (healthy) 8080/tcp
mtusi-lab3-api-6 mtusi-messenger:lab3 "python -m app" api 9 minutes ago Exited (0) 14 seconds ago
Container mtusi-lab3-postgres-1 Waiting
Container mtusi-lab3-postgres-1 Healthy
Container mtusi-lab3-migrate-1 Starting
Container mtusi-lab3-migrate-1 Started
Container mtusi-lab3-migrate-1 Waiting
Container mtusi-lab3-postgres-1 Waiting
Container mtusi-lab3-postgres-1 Healthy
Container mtusi-lab3-migrate-1 Exited
Container mtusi-lab3-api-6 Starting
Container mtusi-lab3-api-6 Started
+21
View File
@@ -0,0 +1,21 @@
== 20 ярЁрыыхы№э√ї чряЁюёют ё юфэшь ъы■ўюь ==
ok - all parallel repeats -> 201 (got [201])
ok - all responses carry the same message id (1 distinct)
ok - requests were served by >=2 replicas (2)
ok - exactly one message in history
ok - every replay returns the identical Message
== ёхьрэЄшър ъы■ўр ==
ok - same key, different body -> 409 (got 409)
ok - other JSON formatting = same request (got 201)
ok - same key in another chat is independent
ok - same key from another user is independent
ok - missing Idempotency-Key -> 400 (got 400)
ok - invalid key 'has space'... -> 400 (got 400)
ok - invalid key 'xxxxxxxxxxxx'... -> 400 (got 400)
ok - invalid key 'slash/key'... -> 400 (got 400)
ok - replay without session -> 401, access re-checked (got 401)
== эхюяЁхфхы╕ээ√щ Ёхчєы№ЄрЄ: ъышхэЄ яютЄюЁ хЄ ё Єхь цх ъы■ўюь ==
ok - retry after uncertain result -> 201
ok - still exactly one message
16 passed, 0 failed
+17
View File
@@ -0,0 +1,17 @@
{
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 15.0,
"elapsed_seconds": 24.987,
"concurrency": 4,
"successful_requests": 2511,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 100.493,
"successful_latency_ms": {
"p50": 14.321,
"p95": 83.278,
"p99": 169.497
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+17
View File
@@ -0,0 +1,17 @@
{
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 15.0,
"elapsed_seconds": 24.987,
"concurrency": 4,
"successful_requests": 2511,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 100.493,
"successful_latency_ms": {
"p50": 14.321,
"p95": 83.278,
"p99": 169.497
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+20
View File
@@ -0,0 +1,20 @@
python : Container mtusi-lab3-redis-1 Paused
строка:1 знак:23
+ ... cache.txt { python student-tests\logout_cache.py --base-url http://lo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: ( Container mtusi-lab3-redis-1 Paused :String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Container mtusi-lab3-redis-1 Unpaused
ok - session is warmed up in cache
== Redis яЁшюёЄрэютыхэ ==
$ docker compose --env-file .env pause redis
ok - logout is NOT confirmed while cache cannot be invalidated (got 503, expected 503)
$ docker compose --env-file .env unpause redis
== Redis тюёёЄрэютыхэ ==
ok - unconfirmed logout left the session consistent and valid (got 200)
ok - retry logout after Redis recovery -> 204 (got 204)
ok - old token after confirmed logout -> 401, no stale cache copy (got 401)
ok - old token still rejected on repeat (got 401)
6 passed, 0 failed
+9
View File
@@ -0,0 +1,9 @@
migrate-1 | applied: nothing (up to date)
migrate-1 | applied: nothing (up to date)
migrate-1 | applied: nothing (up to date)
version | applied_at
------------------+-------------------------------
0001_init | 2026-10-22 14:56:14.127864+00
0002_idempotency | 2026-10-22 14:56:14.257126+00
(2 rows)
+28
View File
@@ -0,0 +1,28 @@
Container mtusi-lab3-redis-1 Stopping
Container mtusi-lab3-redis-1 Stopped
Container mtusi-lab3-redis-1 Starting
Container mtusi-lab3-redis-1 Started
Container mtusi-lab3-postgres-1 Stopping
Container mtusi-lab3-postgres-1 Stopped
Container mtusi-lab3-postgres-1 Starting
Container mtusi-lab3-postgres-1 Started
== 1. Redis недоступен ==
$ docker compose --env-file .env stop redis
ok - valid token still works without Redis (cache bypassed)
ok - writes still work without Redis
ok - login works without Redis
ok - forged token still rejected without Redis
$ docker compose --env-file .env start redis
== 2. PostgreSQL недоступен ==
$ docker compose --env-file .env stop postgres
ok - history without DB -> 503, not a hang (got 503)
ok - unknown token is never trusted without DB (got 503)
ok - anonymous request -> 401
ok - /health/ready -> 503
ok - /health/live -> 200 (process is alive)
$ docker compose --env-file .env start postgres
== 3. восстановление ==
ok - /health/ready back to 200
ok - same token reads the same history after DB is back
11 passed, 0 failed
+14
View File
@@ -0,0 +1,14 @@
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab3-api-5 mtusi-messenger:lab3 "python -m app" api 9 minutes ago Up 9 minutes (healthy) 8080/tcp
mtusi-lab3-api-6 mtusi-messenger:lab3 "python -m app" api 9 minutes ago Up 15 seconds (healthy) 8080/tcp
mtusi-lab3-lb-1 haproxy:3.0.5-alpine "docker-entrypoint.s…" lb 12 minutes ago Up 2 minutes (healthy) 127.0.0.1:8080-8081->8080-8081/tcp
mtusi-lab3-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 20 minutes ago Up About a minute (healthy) 5432/tcp
mtusi-lab3-redis-1 redis:7.4.1-alpine "docker-entrypoint.s…" redis 20 minutes ago Up About a minute (healthy) 6379/tcp
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi-lab3-api-5 mtusi-messenger:lab3 "python -m app" api 9 minutes ago Up 3 seconds (health: starting) 8080/tcp
mtusi-lab3-api-6 mtusi-messenger:lab3 "python -m app" api 9 minutes ago Up 4 seconds (health: starting) 8080/tcp
mtusi-lab3-lb-1 haproxy:3.0.5-alpine "docker-entrypoint.s…" lb 12 minutes ago Up 2 seconds (health: starting) 127.0.0.1:8080-8081->8080-8081/tcp
mtusi-lab3-postgres-1 postgres:16.4-alpine "docker-entrypoint.s…" postgres 20 minutes ago Up 4 seconds (health: starting) 5432/tcp
mtusi-lab3-redis-1 redis:7.4.1-alpine "docker-entrypoint.s…" redis 20 minutes ago Up 5 seconds (health: starting) 6379/tcp
+3
View File
@@ -0,0 +1,3 @@
ok - insert of unknown member failed on foreign key
ok - after rollback: chats=0, members=0 (expected 0, 0)
PASS
+53
View File
@@ -0,0 +1,53 @@
{
"replicas_before": [
"b5c5b15326cd",
"c2fc366c1f6b"
],
"replicas_after": [
"751a5997c6bc",
"dc76a00e8ff8"
],
"all_on_new_image": true,
"steps": [
{
"old": "b5c5b15326cd",
"new": "dc76a00e8ff8",
"new_healthy": true,
"new_served_by_lb": true,
"old_stop_seconds": 1.29
},
{
"old": "c2fc366c1f6b",
"new": "751a5997c6bc",
"new_healthy": true,
"new_served_by_lb": true,
"old_stop_seconds": 1.36
}
],
"update_duration_s": 18.6,
"before_update": {
"successful": 475,
"errors": 0,
"successful_rps": 158.2
},
"during_update": {
"successful": 2634,
"errors": 0,
"successful_rps": 141.5
},
"after_update": {
"successful": 507,
"errors": 0,
"successful_rps": 169.0
},
"max_gap_without_success_s": 0.469,
"instances_serving_at_end": [
"751a5997c6bc",
"dc76a00e8ff8"
],
"history_messages": 3620,
"confirmed": 3620,
"lost_or_changed": 0,
"duplicate_texts": 0,
"retries_with_same_key": 0
}
+97
View File
@@ -0,0 +1,97 @@
$ docker compose --env-file .env build api
$ docker compose --env-file .env run --rm migrate
$ docker image inspect -f {{.Id}} mtusi-messenger:lab3
$ docker compose --env-file .env ps -q api
ok - 2 replicas before update
$ docker inspect -f {{.Image}} b5c5b15326cda7faec130cd40e44c64bc75fab16d4822d19c77e293d61e90556
$ docker inspect -f {{.Image}} c2fc366c1f6bd4375d56f4cacc53ccc56acf6bc744c8450718cf448035bdb435
$ docker compose --env-file .env ps -q api
$ docker compose --env-file .env up -d --no-deps --no-recreate --scale api=3 api
$ docker compose --env-file .env ps -q api
ok - one new replica started for b5c5b15326cd
$ docker inspect -f {{.State.Health.Status}} dc76a00e8ff80eeb393286be367dc2e42aa1f2c55314739b12c77902a52a08a7
$ docker inspect -f {{.State.Health.Status}} dc76a00e8ff80eeb393286be367dc2e42aa1f2c55314739b12c77902a52a08a7
$ docker inspect -f {{.State.Health.Status}} dc76a00e8ff80eeb393286be367dc2e42aa1f2c55314739b12c77902a52a08a7
$ docker inspect -f {{.State.Health.Status}} dc76a00e8ff80eeb393286be367dc2e42aa1f2c55314739b12c77902a52a08a7
$ docker inspect -f {{.State.Health.Status}} dc76a00e8ff80eeb393286be367dc2e42aa1f2c55314739b12c77902a52a08a7
$ docker inspect -f {{.State.Health.Status}} dc76a00e8ff80eeb393286be367dc2e42aa1f2c55314739b12c77902a52a08a7
$ docker inspect -f {{.State.Health.Status}} dc76a00e8ff80eeb393286be367dc2e42aa1f2c55314739b12c77902a52a08a7
$ docker stop -t 15 b5c5b15326cda7faec130cd40e44c64bc75fab16d4822d19c77e293d61e90556
$ docker rm b5c5b15326cda7faec130cd40e44c64bc75fab16d4822d19c77e293d61e90556
ok - new replica dc76a00e8ff8 healthy and in LB before old b5c5b15326cd stops
$ docker compose --env-file .env ps -q api
$ docker compose --env-file .env up -d --no-deps --no-recreate --scale api=3 api
$ docker compose --env-file .env ps -q api
ok - one new replica started for c2fc366c1f6b
$ docker inspect -f {{.State.Health.Status}} 751a5997c6bc08109eb9a7b18c734172b958053acb542f3df1bec0674c4ad534
$ docker inspect -f {{.State.Health.Status}} 751a5997c6bc08109eb9a7b18c734172b958053acb542f3df1bec0674c4ad534
$ docker inspect -f {{.State.Health.Status}} 751a5997c6bc08109eb9a7b18c734172b958053acb542f3df1bec0674c4ad534
$ docker inspect -f {{.State.Health.Status}} 751a5997c6bc08109eb9a7b18c734172b958053acb542f3df1bec0674c4ad534
$ docker inspect -f {{.State.Health.Status}} 751a5997c6bc08109eb9a7b18c734172b958053acb542f3df1bec0674c4ad534
$ docker inspect -f {{.State.Health.Status}} 751a5997c6bc08109eb9a7b18c734172b958053acb542f3df1bec0674c4ad534
$ docker inspect -f {{.State.Health.Status}} 751a5997c6bc08109eb9a7b18c734172b958053acb542f3df1bec0674c4ad534
$ docker stop -t 15 c2fc366c1f6bd4375d56f4cacc53ccc56acf6bc744c8450718cf448035bdb435
$ docker rm c2fc366c1f6bd4375d56f4cacc53ccc56acf6bc744c8450718cf448035bdb435
ok - new replica 751a5997c6bc healthy and in LB before old c2fc366c1f6b stops
$ docker compose --env-file .env ps -q api
$ docker inspect -f {{.Image}} dc76a00e8ff80eeb393286be367dc2e42aa1f2c55314739b12c77902a52a08a7
$ docker inspect -f {{.Image}} 751a5997c6bc08109eb9a7b18c734172b958053acb542f3df1bec0674c4ad534
{
"replicas_before": [
"b5c5b15326cd",
"c2fc366c1f6b"
],
"replicas_after": [
"751a5997c6bc",
"dc76a00e8ff8"
],
"all_on_new_image": true,
"steps": [
{
"old": "b5c5b15326cd",
"new": "dc76a00e8ff8",
"new_healthy": true,
"new_served_by_lb": true,
"old_stop_seconds": 1.29
},
{
"old": "c2fc366c1f6b",
"new": "751a5997c6bc",
"new_healthy": true,
"new_served_by_lb": true,
"old_stop_seconds": 1.36
}
],
"update_duration_s": 18.6,
"before_update": {
"successful": 475,
"errors": 0,
"successful_rps": 158.2
},
"during_update": {
"successful": 2634,
"errors": 0,
"successful_rps": 141.5
},
"after_update": {
"successful": 507,
"errors": 0,
"successful_rps": 169.0
},
"max_gap_without_success_s": 0.469,
"instances_serving_at_end": [
"751a5997c6bc",
"dc76a00e8ff8"
],
"history_messages": 3620,
"confirmed": 3620,
"lost_or_changed": 0,
"duplicate_texts": 0,
"retries_with_same_key": 0
}
ok - replica count restored to 2
ok - all replicas run the new image
ok - old replicas no longer serve traffic
ok - no lost or duplicated writes
9 passed, 0 failed
+2
View File
@@ -0,0 +1,2 @@
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
+83
View File
@@ -0,0 +1,83 @@
== рєЄхэЄшЇшърЎш  ==
ok - wrong password -> 401 + Basic challenge
ok - unknown user -> 401 (same as wrong password)
ok - no token -> 401 + Bearer challenge
ok - X-User-Id alone gives no access
ok - unknown/forged token -> 401
ok - Basic on business endpoint -> 401
ok - X-User-Id cannot override bearer identity
ok - password shorter than 12 -> 400
== logout ==
ok - logout -> 204
ok - token after logout -> 401
ok - second logout -> 401
== уюэър ЁхушёЄЁрЎшш юфэюую username ==
python : Traceback (most recent call last):
строка:1 знак:24
+ ... tests.txt { python student-tests\run.py --base-url http://localhost:8 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
File "C:\Users\79152\Desktop\mtusi2026lab3\student-tests\run.py", line 122, in <module>
main()
~~~~^^
File "C:\Users\79152\Desktop\mtusi2026lab3\student-tests\run.py", line 67, in main
codes = list(pool.map(reg, range(20)))
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\concurrent\futures\_base.py", line 639, in
result_iterator
yield _result_or_cancel(fs.pop())
~~~~~~~~~~~~~~~~~^^^^^^^^^^
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\concurrent\futures\_base.py", line 311, in
_result_or_cancel
return fut.result(timeout)
~~~~~~~~~~^^^^^^^^^
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\concurrent\futures\_base.py", line 450, in result
return self.__get_result()
~~~~~~~~~~~~~~~~~^^
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\concurrent\futures\_base.py", line 395, in
__get_result
raise self._exception
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\concurrent\futures\thread.py", line 86, in run
result = ctx.run(self.task)
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\concurrent\futures\thread.py", line 73, in run
return fn(*args, **kwargs)
File "C:\Users\79152\Desktop\mtusi2026lab3\student-tests\run.py", line 63, in reg
st, _, _ = api.call("POST", "/api/v1/users", {"username": name, "display_name": "r", "password": PASSWORD})
~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\79152\Desktop\mtusi2026lab3\student-tests\common.py", line 34, in call
st, raw, rh = self.raw(method, path, data, h, timeout=timeout)
~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\79152\Desktop\mtusi2026lab3\student-tests\common.py", line 18, in raw
with urllib.request.urlopen(req, timeout=timeout) as r:
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\urllib\request.py", line 187, in urlopen
return opener.open(url, data, timeout)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\urllib\request.py", line 487, in open
response = self._open(req, data)
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\urllib\request.py", line 504, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
'_open', req)
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\urllib\request.py", line 464, in _call_chain
result = func(*args)
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\urllib\request.py", line 1350, in http_open
return self.do_open(http.client.HTTPConnection, req)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\urllib\request.py", line 1325, in do_open
r = h.getresponse()
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\http\client.py", line 1450, in getresponse
response.begin()
~~~~~~~~~~~~~~^^
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\http\client.py", line 336, in begin
version, status, reason = self._read_status()
~~~~~~~~~~~~~~~~~^^
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\http\client.py", line 297, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "C:\Users\79152\AppData\Local\Python\pythoncore-3.14-64\Lib\socket.py", line 725, in readinto
return self._sock.recv_into(b)
~~~~~~~~~~~~~~~~~~~~^^^
TimeoutError: timed out
sent=100 accepted=100 received=100 unique_ids=100 all_texts_present=True
PASS