# Local Register Stress Test (3 minutes)

This setup only targets localhost (`127.0.0.1`), for your own backend verification.

## 1. Install dependency

```powershell
python -m pip install -U locust
```

## 2. Default target and route

Current script defaults:
- host: `http://127.0.0.1`
- register route: `/api/user/register`

If your local backend uses different host/port:

```powershell
$env:TARGET_HOST="http://127.0.0.1:8080"
```

If route differs:

```powershell
$env:REGISTER_PATH="/api/user/register"
```

## 3. Run large-scale register test (3 minutes)

```powershell
locust -f locustfile.py --headless --users 300 --spawn-rate 60 --run-time 3m --csv register_stress_report
```
#########################
python -m locust -f locustfile.py --headless --users 300 --spawn-rate 60 --run-time 3m --csv register_stress_report


Notes:
- `--users 300`: concurrent virtual users.
- `--spawn-rate 60`: user ramp-up per second.
- `--run-time 3m`: test duration.

## 4. Payload fields (adjust only when needed)

By default each request sends unique username + password:

```json
{
  "username": "load_user_...",
  "password": "123456",
  "confirmPassword": "123456"
}
```

If your API field names are different, set env vars:

```powershell
$env:USERNAME_FIELD="userName"
$env:PASSWORD_FIELD="passwd"
$env:CONFIRM_PASSWORD_FIELD="confirmPwd"
```

Optional extra fields:

```powershell
$env:INCLUDE_EMAIL="1"
$env:INCLUDE_NICKNAME="1"
```

## 5. Result files and metrics

After run:
- `register_stress_report_stats.csv`
- `register_stress_report_failures.csv`
- `register_stress_report_exceptions.csv`

Focus on:
- requests/s
- p95 and p99 latency
- failure ratio
