ЛР 2 — БВТ2301 — Майорова — на 5
Application / application (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-10-23 11:13:22 +03:00
parent 65003b6119
commit 400e62ffdc
36 changed files with 4751 additions and 37 deletions
+78
View File
@@ -0,0 +1,78 @@
Image mtusi-lab2-api Building
#1 [internal] load local bake definitions
#1 reading from stdin 656B done
#1 DONE 0.0s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 739B 0.1s done
#2 DONE 0.1s
#3 [internal] load metadata for docker.io/library/python:3.12.8-slim-bookworm@sha256:2199a62885a12290dc9c5be3ca0681d367576ab7bf037da120e564723292a2f0
#3 DONE 0.1s
#4 [internal] load .dockerignore
#4 transferring context: 132B 0.0s done
#4 DONE 0.1s
#5 [internal] load build context
#5 transferring context: 24.73kB 0.2s done
#5 DONE 0.3s
#6 [1/7] FROM docker.io/library/python:3.12.8-slim-bookworm@sha256:2199a62885a12290dc9c5be3ca0681d367576ab7bf037da120e564723292a2f0
#6 resolve docker.io/library/python:3.12.8-slim-bookworm@sha256:2199a62885a12290dc9c5be3ca0681d367576ab7bf037da120e564723292a2f0
#6 resolve docker.io/library/python:3.12.8-slim-bookworm@sha256:2199a62885a12290dc9c5be3ca0681d367576ab7bf037da120e564723292a2f0 0.4s done
#6 DONE 0.5s
#7 [3/7] RUN groupadd --gid 10001 app && useradd --uid 10001 --gid app --no-create-home app
#7 CACHED
#8 [4/7] COPY requirements.txt ./
#8 CACHED
#9 [2/7] WORKDIR /app
#9 CACHED
#10 [5/7] RUN pip install --no-cache-dir -r requirements.txt
#10 CACHED
#11 [6/7] COPY src/ ./src/
#11 DONE 0.2s
#12 [7/7] COPY migrations/ ./migrations/
#12 DONE 0.3s
#13 exporting to image
#13 exporting layers
#13 exporting layers 1.1s done
#13 exporting manifest sha256:5017231aa6022853d9ca872aa39e5c980e31c40e17c7986757b3afc3651064b5 0.1s done
#13 exporting config sha256:2b594068234b84afae7062ee6b719d9e84a772923d9a4f0d9c2ab431aac7f09c
#13 exporting config sha256:2b594068234b84afae7062ee6b719d9e84a772923d9a4f0d9c2ab431aac7f09c 0.1s done
#13 exporting attestation manifest sha256:3ae47f10c02268299f427294491ad4f25e5485ce4905715abe5868d2d0818ca6
#13 exporting attestation manifest sha256:3ae47f10c02268299f427294491ad4f25e5485ce4905715abe5868d2d0818ca6 0.2s done
#13 exporting manifest list sha256:90f48f95ec551e4de0cb9ca3c8da3fbac9bfa588a52cd6fd9b21a225ac9e48cd
#13 exporting manifest list sha256:90f48f95ec551e4de0cb9ca3c8da3fbac9bfa588a52cd6fd9b21a225ac9e48cd 0.1s done
#13 naming to docker.io/library/mtusi-lab2-api:latest
#13 naming to docker.io/library/mtusi-lab2-api:latest 0.0s done
#13 unpacking to docker.io/library/mtusi-lab2-api:latest
#13 unpacking to docker.io/library/mtusi-lab2-api:latest 0.2s done
#13 DONE 2.1s
#14 resolving provenance for metadata file
#14 DONE 0.1s
Image mtusi-lab2-api Built
Container mtusi-lab2-redis-1 Running
Container mtusi-lab2-postgres-1 Running
Container mtusi-lab2-api-1 Recreate
Container mtusi-lab2-api-1 Recreated
Container mtusi-lab2-postgres-1 Waiting
Container mtusi-lab2-redis-1 Waiting
Container mtusi-lab2-redis-1 Healthy
Container mtusi-lab2-postgres-1 Healthy
Container mtusi-lab2-api-1 Starting
Container mtusi-lab2-api-1 Started
Container mtusi-lab2-redis-1 Waiting
Container mtusi-lab2-api-1 Waiting
Container mtusi-lab2-postgres-1 Waiting
Container mtusi-lab2-postgres-1 Healthy
Container mtusi-lab2-redis-1 Healthy
Container mtusi-lab2-api-1 Healthy
+2
View File
@@ -0,0 +1,2 @@
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
+130
View File
@@ -0,0 +1,130 @@
$ git clone --local /Users/ssmayorova/Documents/ChatGPT/Высоконагруженные приложения/mtusi2026lab2 /Users/ssmayorova/Documents/ChatGPT/Высоконагруженные приложения/clean-clone-o_gf7ofj/mtusi2026lab2
Cloning into '/Users/ssmayorova/Documents/ChatGPT/Высоконагруженные приложения/clean-clone-o_gf7ofj/mtusi2026lab2'...
done.
$ python3 scripts/bootstrap.py
Local configuration ready; secrets were not printed.
$ docker compose up -d --build --wait
Image mtusi-clean-144e2e11-api Building
#1 [internal] load local bake definitions
#1 reading from stdin 718B done
#1 DONE 0.0s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 739B done
#2 DONE 0.0s
#3 [internal] load metadata for docker.io/library/python:3.12.8-slim-bookworm@sha256:2199a62885a12290dc9c5be3ca0681d367576ab7bf037da120e564723292a2f0
#3 DONE 0.0s
#4 [internal] load .dockerignore
#4 transferring context: 132B done
#4 DONE 0.0s
#5 [internal] load build context
#5 transferring context: 24.62kB 0.0s done
#5 DONE 0.0s
#6 [1/7] FROM docker.io/library/python:3.12.8-slim-bookworm@sha256:2199a62885a12290dc9c5be3ca0681d367576ab7bf037da120e564723292a2f0
#6 resolve docker.io/library/python:3.12.8-slim-bookworm@sha256:2199a62885a12290dc9c5be3ca0681d367576ab7bf037da120e564723292a2f0 0.1s done
#6 DONE 0.1s
#7 [4/7] COPY requirements.txt ./
#7 CACHED
#8 [5/7] RUN pip install --no-cache-dir -r requirements.txt
#8 CACHED
#9 [2/7] WORKDIR /app
#9 CACHED
#10 [6/7] COPY src/ ./src/
#10 CACHED
#11 [3/7] RUN groupadd --gid 10001 app && useradd --uid 10001 --gid app --no-create-home app
#11 CACHED
#12 [7/7] COPY migrations/ ./migrations/
#12 CACHED
#13 exporting to image
#13 exporting layers done
#13 exporting manifest sha256:17e1aa1e1ab70d739372aac14340c7082aa2b9d516783f5bb8416e85ac608009 0.0s done
#13 exporting config sha256:08162a60f623a2176f3cf1137372f23710c41dd7f958d7212129d15d5829c02b
#13 exporting config sha256:08162a60f623a2176f3cf1137372f23710c41dd7f958d7212129d15d5829c02b 0.0s done
#13 exporting attestation manifest sha256:ed2d5c62a3502802fd1706fca353486999cc539bd9b0d7f4171309a19a8fabe3 0.0s done
#13 exporting manifest list sha256:f866af8b5e84486fa48b2a6264eb645a81e4e41773a66380f849fb3628f59f49 0.0s done
#13 naming to docker.io/library/mtusi-clean-144e2e11-api:latest done
#13 unpacking to docker.io/library/mtusi-clean-144e2e11-api:latest 0.0s done
#13 DONE 0.2s
#14 resolving provenance for metadata file
#14 DONE 0.0s
Image mtusi-clean-144e2e11-api Built
Network mtusi-clean-144e2e11_default Creating
Network mtusi-clean-144e2e11_default Created
Volume mtusi-clean-144e2e11_postgres_data Creating
Volume mtusi-clean-144e2e11_postgres_data Created
Container mtusi-clean-144e2e11-redis-1 Creating
Container mtusi-clean-144e2e11-postgres-1 Creating
Container mtusi-clean-144e2e11-postgres-1 Created
Container mtusi-clean-144e2e11-redis-1 Created
Container mtusi-clean-144e2e11-api-1 Creating
Container mtusi-clean-144e2e11-api-1 Created
Container mtusi-clean-144e2e11-redis-1 Starting
Container mtusi-clean-144e2e11-postgres-1 Starting
Container mtusi-clean-144e2e11-redis-1 Started
Container mtusi-clean-144e2e11-postgres-1 Started
Container mtusi-clean-144e2e11-postgres-1 Waiting
Container mtusi-clean-144e2e11-redis-1 Waiting
Container mtusi-clean-144e2e11-redis-1 Healthy
Container mtusi-clean-144e2e11-postgres-1 Healthy
Container mtusi-clean-144e2e11-api-1 Starting
Container mtusi-clean-144e2e11-api-1 Started
Container mtusi-clean-144e2e11-redis-1 Waiting
Container mtusi-clean-144e2e11-api-1 Waiting
Container mtusi-clean-144e2e11-postgres-1 Waiting
Container mtusi-clean-144e2e11-redis-1 Healthy
Container mtusi-clean-144e2e11-postgres-1 Healthy
Container mtusi-clean-144e2e11-api-1 Healthy
$ make check test test-student BASE_URL=http://localhost:18086
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
python3 tests/smoke.py --base-url "http://localhost:18086"
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
BASE_URL="http://localhost:18086" python3 -m unittest discover -s student-tests -p test_api.py -v
test_concurrent_messages_and_pagination (test_api.APIContract) ... ok
test_cursor_scope_and_validation (test_api.APIContract) ... ok
test_foreign_chat (test_api.APIContract) ... ok
test_invalid_chat_creation (test_api.APIContract) ... ok
test_malformed_json_and_extra_fields (test_api.APIContract) ... ok
test_registration_race (test_api.APIContract) ... ok
test_unicode_limits (test_api.APIContract) ... ok
test_unicode_password_basic_and_logout (test_api.APIContract) ... ok
----------------------------------------------------------------------
Ran 8 tests in 11.843s
OK
$ make test-persistence ACTION_SCRIPT=scripts/restart.sh BASE_URL=http://localhost:18086
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:18086"
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 exec -T postgres psql -U messenger -d messenger -Atc SELECT count(*) FROM schema_migrations;
1
Container mtusi-clean-144e2e11-api-1 Stopping
Container mtusi-clean-144e2e11-api-1 Stopped
Container mtusi-clean-144e2e11-api-1 Removing
Container mtusi-clean-144e2e11-api-1 Removed
Container mtusi-clean-144e2e11-postgres-1 Stopping
Container mtusi-clean-144e2e11-redis-1 Stopping
Container mtusi-clean-144e2e11-redis-1 Stopped
Container mtusi-clean-144e2e11-redis-1 Removing
Container mtusi-clean-144e2e11-postgres-1 Stopped
Container mtusi-clean-144e2e11-postgres-1 Removing
Container mtusi-clean-144e2e11-redis-1 Removed
Container mtusi-clean-144e2e11-postgres-1 Removed
Volume mtusi-clean-144e2e11_postgres_data Removing
Network mtusi-clean-144e2e11_default Removing
Volume mtusi-clean-144e2e11_postgres_data Removed
Network mtusi-clean-144e2e11_default Removed
PASS: clean local clone, fresh image and all requested acceptance tests.
+9
View File
@@ -0,0 +1,9 @@
{
"composite_operation_rollback": true,
"redis_user_cache_ttl_seconds": 60,
"redis_outage_seconds": 0.2969403329999998,
"redis_recovered_without_relogin": true,
"postgres_outage_response_seconds": 0.006768832999999752,
"postgres_recovered_without_relogin": true,
"short_ttl_expired": true
}
+15
View File
@@ -0,0 +1,15 @@
Container mtusi-lab2-redis-1 Stopping
Container mtusi-lab2-redis-1 Stopped
Container mtusi-lab2-redis-1 Starting
Container mtusi-lab2-redis-1 Started
Container mtusi-lab2-redis-1 Waiting
Container mtusi-lab2-redis-1 Healthy
Container mtusi-lab2-postgres-1 Stopping
Container mtusi-lab2-postgres-1 Stopped
Container mtusi-lab2-postgres-1 Starting
Container mtusi-lab2-postgres-1 Started
Container mtusi-lab2-postgres-1 Waiting
Container mtusi-lab2-postgres-1 Healthy
Container mtusi-lab2-expiry-f1a39764 Creating
Container mtusi-lab2-expiry-f1a39764 Created
PASS: rollback, real Redis TTL/cache, Redis outage, PostgreSQL outage/recovery and session expiry.
+18
View File
@@ -0,0 +1,18 @@
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
python3 tests/smoke.py --base-url "http://localhost:8080"
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
BASE_URL="http://localhost:8080" python3 -m unittest discover -s student-tests -p test_api.py -v
test_concurrent_messages_and_pagination (test_api.APIContract) ... ok
test_cursor_scope_and_validation (test_api.APIContract) ... ok
test_foreign_chat (test_api.APIContract) ... ok
test_invalid_chat_creation (test_api.APIContract) ... ok
test_malformed_json_and_extra_fields (test_api.APIContract) ... ok
test_registration_race (test_api.APIContract) ... ok
test_unicode_limits (test_api.APIContract) ... ok
test_unicode_password_basic_and_logout (test_api.APIContract) ... ok
----------------------------------------------------------------------
Ran 8 tests in 13.427s
OK
File diff suppressed because it is too large Load Diff
+8
View File
@@ -0,0 +1,8 @@
{
"scenario": "Initial own test: 10 concurrent registrations, before bounding KDF concurrency",
"container_memory_mib": 256,
"observed_exit_code": 137,
"observed_oom_killed": true,
"fix": "Limit simultaneous scrypt computations to 2 and set MALLOC_ARENA_MAX=2; rerun the same registration race under unchanged memory limit",
"final_result_source": "student-tests.txt"
}
+3
View File
@@ -0,0 +1,3 @@
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:8080"
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
+6
View File
@@ -0,0 +1,6 @@
Container mtusi-lab2-api-run-3b62fd7eb732 Creating
Container mtusi-lab2-api-run-3b62fd7eb732 Created
Container mtusi-lab2-api-run-0145f8a8aff1 Creating
Container mtusi-lab2-api-run-0145f8a8aff1 Created
PASS: 100000 messages; two indexes; write costs; backup/restore counts, samples and full checksum match.
Backup seconds: 1.102 Restore seconds: 1.742
+27
View File
@@ -0,0 +1,27 @@
[
{
"service": "api",
"container_id": "03414eeb9af4",
"started_at": "2026-10-23T06:53:58.384822282Z",
"status": "running",
"volumes": []
},
{
"service": "postgres",
"container_id": "f8be6202d5e4",
"started_at": "2026-10-23T06:53:51.683479639Z",
"status": "running",
"volumes": [
"mtusi-lab2_postgres_data"
]
},
{
"service": "redis",
"container_id": "5fecf0c5edd1",
"started_at": "2026-10-23T06:53:51.383818051Z",
"status": "running",
"volumes": [
"b72dab0a9ef82932abd5655e09a614b5c99b3a7cef959426f05ad0a2ed7dbc79"
]
}
]
+27
View File
@@ -0,0 +1,27 @@
[
{
"service": "api",
"container_id": "03414eeb9af4",
"started_at": "2026-10-23T06:53:29.066897456Z",
"status": "running",
"volumes": []
},
{
"service": "postgres",
"container_id": "f8be6202d5e4",
"started_at": "2026-10-23T06:53:24.074466953Z",
"status": "running",
"volumes": [
"mtusi-lab2_postgres_data"
]
},
{
"service": "redis",
"container_id": "5fecf0c5edd1",
"started_at": "2026-10-23T06:53:23.920707731Z",
"status": "running",
"volumes": [
"b72dab0a9ef82932abd5655e09a614b5c99b3a7cef959426f05ad0a2ed7dbc79"
]
}
]
+91
View File
@@ -0,0 +1,91 @@
{
"docker": {
"Platform": {
"Name": "Docker Engine - Community"
},
"Version": "29.5.2",
"ApiVersion": "1.54",
"MinAPIVersion": "1.40",
"Os": "linux",
"Arch": "arm64",
"Components": [
{
"Name": "Engine",
"Version": "29.5.2",
"Details": {
"ApiVersion": "1.54",
"Arch": "arm64",
"BuildTime": "Wed May 20 14:39:25 2026",
"Experimental": "false",
"GitCommit": "568f755",
"GoVersion": "go1.26.3",
"KernelVersion": "6.8.0-117-generic",
"MinAPIVersion": "1.40",
"Module": "github.com/moby/moby/v2",
"ModuleVersion": "v2.0.0+unknown",
"Os": "linux"
}
},
{
"Name": "containerd",
"Version": "v2.2.4",
"Details": {
"GitCommit": "193637f7ee8ae5f5aa5248f49e7baa3e6164966e"
}
},
{
"Name": "runc",
"Version": "1.3.5",
"Details": {
"GitCommit": "v1.3.5-0-g488fc13e"
}
},
{
"Name": "docker-init",
"Version": "0.19.0",
"Details": {
"GitCommit": "de40ad0"
}
}
],
"GitCommit": "568f755",
"GoVersion": "go1.26.3",
"KernelVersion": "6.8.0-117-generic",
"BuildTime": "2026-05-20T14:39:25.000000000+00:00"
},
"postgres_settings": {
"fsync": "on",
"synchronous_commit": "on",
"full_page_writes": "on",
"migration_versions": [
"001_initial.sql"
]
},
"api_python": "Python 3.12.8",
"containers": [
{
"service": "api",
"user": "10001:10001",
"memory_bytes": 268435456,
"nano_cpus": 1000000000,
"oom_killed": false,
"health": "healthy"
},
{
"service": "postgres",
"user": "",
"memory_bytes": 536870912,
"nano_cpus": 1000000000,
"oom_killed": false,
"health": "healthy"
},
{
"service": "redis",
"user": "",
"memory_bytes": 67108864,
"nano_cpus": 500000000,
"oom_killed": false,
"health": "healthy"
}
]
}
+2
View File
@@ -0,0 +1,2 @@
python3 tests/smoke.py --base-url "http://localhost:8080"
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
+13
View File
@@ -0,0 +1,13 @@
test_concurrent_messages_and_pagination (test_api.APIContract) ... ok
test_cursor_scope_and_validation (test_api.APIContract) ... ok
test_foreign_chat (test_api.APIContract) ... ok
test_invalid_chat_creation (test_api.APIContract) ... ok
test_malformed_json_and_extra_fields (test_api.APIContract) ... ok
test_registration_race (test_api.APIContract) ... ok
test_unicode_limits (test_api.APIContract) ... ok
test_unicode_password_basic_and_logout (test_api.APIContract) ... ok
----------------------------------------------------------------------
Ran 8 tests in 11.051s
OK
+2
View File
@@ -0,0 +1,2 @@
../.venv/bin/python scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.