# Resilience Test Scenarios

## RS-01: API Startup with Database Ready

**Trigger**: Start API container after PostgreSQL is healthy
**Observable**: API responds to HTTP requests
**Pass criterion**: API returns non-5xx response within 60s of container start

## RS-02: Database Migrations on Fresh Start

**Trigger**: Start API against empty database
**Observable**: All 11 migrations execute successfully
**Pass criterion**: API starts without error; all tables exist; schemaversions table has 11 entries

## RS-03: Region Processing Survives Tile Download Failure

**Trigger**: Submit region request where some tiles may fail (rate limit / timeout)
**Observable**: Region either completes (with partial tiles) or is marked "failed"
**Pass criterion**: Status is either "completed" or "failed" (never stuck in "processing" indefinitely); max processing time < 300s

## RS-04: Queue Capacity Limit

**Trigger**: Submit 1001+ region requests rapidly (exceeds capacity 1000)
**Observable**: Queue rejects overflow requests
**Pass criterion**: First 1000 accepted; subsequent requests return error or are dropped; no crash

## RS-05: Concurrent Download Limit Respected

**Trigger**: Submit large region (many tiles) and observe download concurrency
**Observable**: At most MaxConcurrentDownloads (4) HTTP requests to Google Maps simultaneously
**Pass criterion**: No more than 4 concurrent outbound tile requests at any point (behavioral; requires observation or logging)

## RS-06: Route Processing with All Regions Completing

**Trigger**: Create route with requestMaps=true, wait for completion
**Observable**: Route transitions from processing to ready
**Pass criterion**: mapsReady=true; no regions stuck in "processing"
