135 lines
2.3 KiB
Markdown
135 lines
2.3 KiB
Markdown
|
|
# Staging Environment
|
||
|
|
|
||
|
|
> Produktionslik staging-miljö för testning
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Snabbstart
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# 1. Starta staging
|
||
|
|
docker-compose -f docker-compose.staging.yml up -d
|
||
|
|
|
||
|
|
# 2. Kör tester
|
||
|
|
./scripts/test_staging.sh
|
||
|
|
|
||
|
|
# 3. Verifiera
|
||
|
|
./scripts/verify_staging.sh
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Konfiguration
|
||
|
|
|
||
|
|
### docker-compose.staging.yml
|
||
|
|
|
||
|
|
```yaml
|
||
|
|
version: '3.8'
|
||
|
|
|
||
|
|
services:
|
||
|
|
postgres:
|
||
|
|
image: postgis/postgis:15-3.3
|
||
|
|
environment:
|
||
|
|
POSTGRES_DB: iom_staging
|
||
|
|
POSTGRES_USER: iom
|
||
|
|
POSTGRES_PASSWORD: staging_s…
|
||
|
|
ports:
|
||
|
|
- "5433:5432"
|
||
|
|
|
||
|
|
redis:
|
||
|
|
image: redis:7-alpine
|
||
|
|
ports:
|
||
|
|
- "6380:6379"
|
||
|
|
|
||
|
|
api:
|
||
|
|
build: .
|
||
|
|
environment:
|
||
|
|
DATABASE_URL: postgresql://iom:staging_s…@postgres:5432/iom_staging
|
||
|
|
REDIS_URL: redis://redis:6379/0
|
||
|
|
ENVIRONMENT: staging
|
||
|
|
ports:
|
||
|
|
- "8001:8000"
|
||
|
|
depends_on:
|
||
|
|
- postgres
|
||
|
|
- redis
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Testscenario
|
||
|
|
|
||
|
|
### 1. Health Check
|
||
|
|
```bash
|
||
|
|
curl http://localhost:8001/health
|
||
|
|
```
|
||
|
|
|
||
|
|
### 2. Auth Flow
|
||
|
|
```bash
|
||
|
|
# Registrera
|
||
|
|
curl -X POST http://localhost:8001/auth/register \
|
||
|
|
-d '{"username": "test", "password": "test", "role": "admin"}'
|
||
|
|
|
||
|
|
# Login
|
||
|
|
curl -X POST http://localhost:8001/auth/login \
|
||
|
|
-d '{"username": "test", "password": "test"}'
|
||
|
|
|
||
|
|
# Använd token
|
||
|
|
curl -H "Authorization: Bearer <token>" http://localhost:8001/taxonomy/domains
|
||
|
|
```
|
||
|
|
|
||
|
|
### 3. CRUD Flow
|
||
|
|
```bash
|
||
|
|
# Skapa observation
|
||
|
|
curl -X POST http://localhost:8001/observations \
|
||
|
|
-H "Authorization: Bearer <token>" \
|
||
|
|
-d '{"goid": "BYG-FAC-WIN-GLA-0001", "condition": 3}'
|
||
|
|
|
||
|
|
# Hämta
|
||
|
|
curl http://localhost:8001/observations/OBS-001 \
|
||
|
|
-H "Authorization: Bearer <token>"
|
||
|
|
```
|
||
|
|
|
||
|
|
### 4. AI Pipeline
|
||
|
|
```bash
|
||
|
|
# Analysera bild
|
||
|
|
curl -X POST http://localhost:8001/ai/analyze-image \
|
||
|
|
-H "Authorization: Bearer <token>" \
|
||
|
|
-F "image=@test.jpg"
|
||
|
|
```
|
||
|
|
|
||
|
|
### 5. Decision Intelligence
|
||
|
|
```bash
|
||
|
|
# Impact score
|
||
|
|
curl -X POST http://localhost:8001/decisions/impact \
|
||
|
|
-H "Authorization: Bearer <token>" \
|
||
|
|
-d '{"defect_code": "6200", "condition": 4}'
|
||
|
|
```
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Verifiering
|
||
|
|
|
||
|
|
### Automatiska tester
|
||
|
|
```bash
|
||
|
|
./scripts/test_staging.sh
|
||
|
|
```
|
||
|
|
|
||
|
|
### Manuell checklista
|
||
|
|
- [ ] API svarar
|
||
|
|
- [ ] Auth fungerar
|
||
|
|
- [ ] Database persistent
|
||
|
|
- [ ] AI pipeline körs
|
||
|
|
- [ ] Decision engine svarar
|
||
|
|
- [ ] Sync fungerar
|
||
|
|
- [ ] Monitoring visar data
|
||
|
|
- [ ] Loggar skrivs
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## Nästa steg
|
||
|
|
|
||
|
|
Efter staging-verifiering:
|
||
|
|
1. Produktionsdeployment
|
||
|
|
2. Monitoring
|
||
|
|
3. Backup-verifiering
|