MockServer for intelligent release system testing. This server simulates various abnormal scenarios to test AI-based diagnosis and troubleshooting capabilities.
- CPU Burner: Increases CPU usage to specified percentage
- Memory Leaker: Continuously leaks memory at specified rate
- Network Latency: Adds specified latency to HTTP requests
- Health Check Failure: Controls health check endpoints to return failures
- Goroutine Leak: Creates goroutines that never exit
- Disk IO: Generates high disk IO
- Crash Simulator: Simulates service crash after delay
- Dependency Failure: Simulates dependency service failures
go build -o mockserver cmd/server/main.go./mockserver -f etc/mockserver.yamldocker build -t mockserver:latest .
docker run -p 8888:8888 mockserver:latestStart multiple scenarios at once. When a new composite scenario is triggered, all previous scenarios are automatically stopped.
curl -X POST http://localhost:8888/api/v1/composite/start \
-H "Content-Type: application/json" \
-d '{
"scenarios": [
{
"name": "cpu_burner",
"params": {"target_percent": 80},
"duration": 300
},
{
"name": "memory_leaker",
"params": {"target_mb": 2048, "leak_rate_mb": 50},
"duration": 300
}
]
}'Note: The optional duration parameter (in seconds) enables auto-recovery. When set, the scenario will automatically stop after the specified duration. If multiple scenarios have different durations, they will all stop when the maximum duration is reached.
curl -X POST http://localhost:8888/api/v1/composite/stopcurl http://localhost:8888/api/v1/composite/statuscurl -X POST http://localhost:8888/api/v1/scenarios/cpu_burner/start \
-H "Content-Type: application/json" \
-d '{"target_percent": 80}'With auto-recovery (stops after 5 minutes):
curl -X POST http://localhost:8888/api/v1/scenarios/cpu_burner/start \
-H "Content-Type: application/json" \
-d '{"target_percent": 80, "duration": 300}'curl -X POST http://localhost:8888/api/v1/scenarios/memory_leaker/start \
-H "Content-Type: application/json" \
-d '{"target_mb": 2048, "leak_rate_mb": 50}'curl -X POST http://localhost:8888/api/v1/scenarios/network_latency/start \
-H "Content-Type: application/json" \
-d '{"latency_ms": 500}'# Always fail
curl -X POST http://localhost:8888/api/v1/scenarios/health_check/start \
-H "Content-Type: application/json" \
-d '{"failure_mode": "always", "status_code": 503}'
# Intermittent failure (50% probability)
curl -X POST http://localhost:8888/api/v1/scenarios/health_check/start \
-H "Content-Type: application/json" \
-d '{"failure_mode": "intermittent", "fail_rate": 0.5}'
# Delayed response
curl -X POST http://localhost:8888/api/v1/scenarios/health_check/start \
-H "Content-Type: application/json" \
-d '{"failure_mode": "delayed"}'curl -X POST http://localhost:8888/api/v1/scenarios/goroutine_leak/start \
-H "Content-Type: application/json" \
-d '{"goroutines_per_second": 100}'curl -X POST http://localhost:8888/api/v1/scenarios/disk_io/start \
-H "Content-Type: application/json" \
-d '{"write_rate_mb": 100}'# Crash after 10 seconds
curl -X POST http://localhost:8888/api/v1/scenarios/crash/start \
-H "Content-Type: application/json" \
-d '{"crash_delay": 10}'curl -X POST http://localhost:8888/api/v1/scenarios/dependency/start \
-H "Content-Type: application/json" \
-d '{"failure_type": "timeout"}'curl http://localhost:8888/api/v1/scenarioscurl http://localhost:8888/api/v1/scenarios/cpu_burner/statuscurl -X POST http://localhost:8888/api/v1/scenarios/cpu_burner/stopcurl http://localhost:8888/health
curl http://localhost:8888/readycurl http://localhost:8888/api/v1/mock-servicecurl http://localhost:8888/api/v1/test/sleep10mscurl http://localhost:8888/api/v1/test/sleep30ms┌─────────────────────────────────────────────────────────┐
│ Mock Server │
├─────────────────────────────────────────────────────────┤
│ HTTP API Layer │
│ - Single/Composite scenario control │
│ - Status queries │
├─────────────────────────────────────────────────────────┤
│ Scenario Manager │
│ - Scenario lifecycle management │
│ - Session management (composite scenarios) │
│ - Atomic scenario switching │
├─────────────────────────────────────────────────────────┤
│ Scenario Plugins │
│ ├─ CPU Burner │
│ ├─ Memory Leaker │
│ ├─ Network Latency │
│ ├─ Health Check Failure │
│ ├─ Goroutine Leak │
│ ├─ Disk IO │
│ ├─ Crash Simulator │
│ └─ Dependency Failure │
└─────────────────────────────────────────────────────────┘
Edit etc/mockserver.yaml:
Name: mockserver
Host: 0.0.0.0
Port: 8888
Log:
Mode: console
Level: infocurl -X POST http://localhost:8888/api/v1/composite/start \
-H "Content-Type: application/json" \
-d '{
"scenarios": [
{
"name": "cpu_burner",
"params": {"target_percent": 70},
"duration": 600
},
{
"name": "memory_leaker",
"params": {"target_mb": 1024, "leak_rate_mb": 20},
"duration": 600
},
{
"name": "network_latency",
"params": {"latency_ms": 300},
"duration": 600
},
{
"name": "health_check",
"params": {"failure_mode": "intermittent", "fail_rate": 0.3},
"duration": 600
}
]
}'All scenarios will automatically stop after 10 minutes (600 seconds).
MIT