fix: make fixes for issues identified by G30

This commit is contained in:
James Westbrook
2026-01-04 12:35:01 -07:00
parent 10a6768ccf
commit dec7ca25b0
7 changed files with 109 additions and 37 deletions
+8 -6
View File
@@ -4,15 +4,17 @@
# Base URL of the Open WebUI instance to benchmark
OPEN_WEBUI_URL=http://localhost:8080
# Admin user credentials (REQUIRED - must exist in Open WebUI)
# The admin account is used to:
# - Create test channels
# - Create temporary benchmark users dynamically
# - Clean up benchmark users after tests
# Ollama instance URL (use host.docker.internal for local Ollama)
OLLAMA_BASE_URL=http://host.docker.internal:11434
# Enable Channels feature
ENABLE_CHANNELS=true
# Admin credentials for creating test channels and users
ADMIN_USER_EMAIL=admin@example.com
ADMIN_USER_PASSWORD=adminpassword123
# Benchmark settings (optional - defaults shown)
# Benchmark settings (optional)
MAX_CONCURRENT_USERS=50
USER_STEP_SIZE=10
SUSTAIN_TIME_SECONDS=30
+17 -11
View File
@@ -71,7 +71,7 @@ owb run channels -p cloud_medium
3. **View results:**
Results are saved to the `results/` directory in JSON and CSV formats.
Results are saved to `results/` in JSON, CSV, and text formats.
## Compute Profiles
@@ -126,19 +126,25 @@ Configuration files are located in `config/`:
### Environment Variables
All configuration can be set via environment variables (loaded from `.env` file):
| Variable | Description | Default |
|----------|-------------|---------|
| `OPEN_WEBUI_URL` | Open WebUI URL for benchmarking | `http://localhost:8080` |
| `ADMIN_USER_EMAIL` | Admin user email (required) | - |
| `ADMIN_USER_PASSWORD` | Admin user password (required) | - |
| `OPEN_WEBUI_PORT` | Port for Docker container | `8080` |
| `CPU_LIMIT` | CPU limit for container | `2.0` |
| `MEMORY_LIMIT` | Memory limit for container | `8g` |
## Extending the Benchmark Suite
### Adding a New Benchmark
| Variable | Description | Default |
|----------|-------------|---------|
| `OPEN_WEBUI_URL` | Open WebUI URL | `http://localhost:8080` |
| `OLLAMA_BASE_URL` | Ollama API URL | `http://host.docker.internal:11434` |
| `ENABLE_CHANNELS` | Enable Channels feature | `true` |
| `ADMIN_USER_EMAIL` | Admin email | - |
| `ADMIN_USER_PASSWORD` | Admin password | - |
| `MAX_CONCURRENT_USERS` | Max concurrent users | `50` |
| `USER_STEP_SIZE` | User increment step | `10` |
| `SUSTAIN_TIME_SECONDS` | Test duration per level | `30` |
| `MESSAGE_FREQUENCY` | Messages/sec per user | `0.5` |
| `OPEN_WEBUI_PORT` | Container port | `8080` |
| `CPU_LIMIT` | CPU limit | `2.0` |
| `MEMORY_LIMIT` | Memory limit | `8g` |
1. Create a new file in `benchmark/scenarios/`:
```python
+38
View File
@@ -102,6 +102,37 @@ async def run_channel_benchmark(
return result
async def run_channel_ws_benchmark(
profile_id: str = "default",
target_url: Optional[str] = None,
max_users: Optional[int] = None,
output_dir: Optional[str] = None,
):
"""Run the channel WebSocket benchmark."""
# Load config with overrides
overrides = {}
if target_url:
overrides["target_url"] = target_url
config = load_config(profile_id, overrides=overrides)
if max_users:
config.channels.max_concurrent_users = max_users
# Create runner
runner = BenchmarkRunner(
config=config,
profile_id=profile_id,
output_dir=Path(output_dir) if output_dir else None,
)
# Run benchmark
result = await runner.run_benchmark(ChannelWebSocketBenchmark)
runner.display_final_summary()
return result
async def run_all_benchmarks(
profile_id: str = "default",
target_url: Optional[str] = None,
@@ -214,6 +245,13 @@ def main():
step_size=args.step_size,
output_dir=args.output,
))
elif args.benchmark == "channels-ws":
asyncio.run(run_channel_ws_benchmark(
profile_id=args.profile,
target_url=args.url,
max_users=args.max_users,
output_dir=args.output,
))
else:
console.print(f"[red]Unknown benchmark: {args.benchmark}[/red]")
sys.exit(1)
+3
View File
@@ -126,6 +126,9 @@ class BenchmarkRunner:
# Display result summary
self._display_result_summary(result)
# Write results to file
self._write_results([result])
return result
async def run_all(self) -> List[BenchmarkResult]:
+30 -18
View File
@@ -96,15 +96,21 @@ class ChannelConcurrencyBenchmark(BaseBenchmark):
if not await self._admin_client.wait_for_ready():
raise RuntimeError("Open WebUI service not ready")
# Authenticate admin (must already exist)
# Authenticate admin
admin_config = self.config.admin_user
try:
await self._admin_client.signin(admin_config.email, admin_config.password)
except Exception as e:
raise RuntimeError(
f"Failed to sign in as admin ({admin_config.email}). "
f"Make sure this user exists in Open WebUI. Error: {e}"
)
except Exception:
try:
await self._admin_client.signup(
admin_config.email,
admin_config.password,
admin_config.name,
)
except Exception as e:
raise RuntimeError(
f"Failed to authenticate admin ({admin_config.email}): {e}"
)
# Create test channel
channel_name = f"benchmark-channel-{int(time.time())}"
@@ -502,22 +508,27 @@ class ChannelWebSocketBenchmark(BaseBenchmark):
if not await self._admin_client.wait_for_ready():
raise RuntimeError("Open WebUI service not ready")
# Authenticate admin
# Authenticate admin (create if doesn't exist - first user becomes admin)
admin_config = self.
admin_config = self.config.admin_user
if admin_config:
if not admin_config:
raise RuntimeError(
"Admin credentials not configured. "
"Set ADMIN_USER_EMAIL and ADMIN_USER_PASSWORD."
)
try:
await self._admin_client.signin(admin_config.email, admin_config.password)
except Exception:
try:
await self._admin_client.signin(admin_config.email, admin_config.password)
except Exception:
await self._admin_client.signup(
admin_config.email,
admin_config.password,
admin_config.name,
)
else:
try:
await self._admin_client.signin("admin@benchmark.local", "benchmark_admin_123")
except Exception:
await self._admin_client.signup("admin@benchmark.local", "benchmark_admin_123", "Benchmark Admin")
except Exception as e:
raise RuntimeError(
f"Failed to authenticate admin ({admin_config.email}): {e
# Create test channel
channel_name = f"benchmark-ws-channel-{int(time.time())}"
@@ -543,10 +554,11 @@ class ChannelWebSocketBenchmark(BaseBenchmark):
channel_config = self.config.channels
user_count = min(channel_config.max_concurrent_users, 50) # Limit for WS test
# Create HTTP clients for users
clients = await self._client_pool.create_clients(
# Create HTTP clients for users via admin API
clients = await self._client_pool.create_benchmark_users(
admin_client=self._admin_client,
count=user_count,
email_pattern=self.config.user_template.email_pattern,
emailtest usersmail_pattern,
password=self.config.user_template.password,
name_pattern=self.config.user_template.name_pattern,
)
+2 -2
View File
@@ -13,8 +13,8 @@ services:
environment:
- WEBUI_SECRET_KEY=${WEBUI_SECRET_KEY:-benchmark-secret-key}
- ENABLE_WEBSOCKET_SUPPORT=true
# Disable external services for isolated benchmarking
- OLLAMA_BASE_URL=
- OLLAMA_BASE_URL=${OLLAMA_BASE_URL:-}
- ENABLE_CHANNELS=${ENABLE_CHANNELS:-true}
- OPENAI_API_KEY=
extra_hosts:
- host.docker.internal:host-gateway
+11
View File
@@ -6,6 +6,13 @@ set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BENCHMARK_DIR="$(dirname "$SCRIPT_DIR")"
# Load .env file if present
if [ -f "$BENCHMARK_DIR/.env" ]; then
set -a
source "$BENCHMARK_DIR/.env"
set +a
fi
# Default profile values (matches "default" compute profile)
CPU_LIMIT="${CPU_LIMIT:-2.0}"
MEMORY_LIMIT="${MEMORY_LIMIT:-8g}"
@@ -58,12 +65,16 @@ echo "Starting Open WebUI with profile: $PROFILE"
echo " CPU Limit: $CPU_LIMIT"
echo " Memory Limit: $MEMORY_LIMIT"
echo " Port: $OPEN_WEBUI_PORT"
echo " Ollama Base URL: ${OLLAMA_BASE_URL:-not set}"
echo " Channels Enabled: ${ENABLE_CHANNELS:-true}"
export CPU_LIMIT
export MEMORY_LIMIT
export CPU_RESERVATION
export MEMORY_RESERVATION
export OPEN_WEBUI_PORT
export OLLAMA_BASE_URL
export ENABLE_CHANNELS
cd "$SCRIPT_DIR"
docker compose -f docker-compose.benchmark.yaml up -d