139 lines
3.5 KiB
Markdown
139 lines
3.5 KiB
Markdown
# Custom URL Usage Guide
|
|
|
|
## 🎯 Overview
|
|
|
|
The load test script now supports a `--url` argument to use any frontend URL dynamically.
|
|
|
|
---
|
|
|
|
## 📝 Usage
|
|
|
|
### Basic Usage
|
|
|
|
```bash
|
|
# Use default URL from config (localhost:3983 or live)
|
|
python3 tests/load_tests/test_generic_load_assessments.py \
|
|
--csv students_with_passwords_2025-12-15T10-49-08_01.csv \
|
|
--start 0 --end 1 --workers 1 --headless
|
|
```
|
|
|
|
### Custom URL Usage
|
|
|
|
```bash
|
|
# Use custom local URL
|
|
python3 tests/load_tests/test_generic_load_assessments.py \
|
|
--csv students_with_passwords_2025-12-15T10-49-08_01.csv \
|
|
--start 0 --end 1 --workers 1 --headless \
|
|
--url http://localhost:3983
|
|
|
|
# Use custom port
|
|
python3 tests/load_tests/test_generic_load_assessments.py \
|
|
--csv students_with_passwords_2025-12-15T10-49-08_01.csv \
|
|
--start 0 --end 1 --workers 1 --headless \
|
|
--url http://localhost:5000
|
|
|
|
# Use live/staging URL
|
|
python3 tests/load_tests/test_generic_load_assessments.py \
|
|
--csv students_with_passwords_2025-12-15T10-49-08_01.csv \
|
|
--start 0 --end 1 --workers 1 --headless \
|
|
--url https://cognitiveprism.tech4bizsolutions.com
|
|
|
|
# Use any custom URL
|
|
python3 tests/load_tests/test_generic_load_assessments.py \
|
|
--csv students_with_passwords_2025-12-15T10-49-08_01.csv \
|
|
--start 0 --end 100 --workers 30 --headless \
|
|
--url https://staging.example.com
|
|
```
|
|
|
|
---
|
|
|
|
## 🔧 How It Works
|
|
|
|
1. **URL Override**: When `--url` is provided, it overrides `BASE_URL` in `config.config`
|
|
2. **Derived URLs**: Automatically updates:
|
|
- `LOGIN_URL`: `{url}/`
|
|
- `DASHBOARD_URL`: `{url}/student/dashboard`
|
|
- `ASSESSMENTS_URL`: `{url}/assessments`
|
|
- `PROFILE_EDITOR_URL`: `{url}/student/profile-builder`
|
|
3. **Page Objects**: All page objects use the updated URLs when instantiated
|
|
|
|
---
|
|
|
|
## 📋 Examples
|
|
|
|
### Example 1: Local Development
|
|
```bash
|
|
python3 tests/load_tests/test_generic_load_assessments.py \
|
|
--csv students.csv \
|
|
--start 0 --end 10 \
|
|
--workers 5 \
|
|
--headless \
|
|
--url http://localhost:3983
|
|
```
|
|
|
|
### Example 2: Staging Environment
|
|
```bash
|
|
python3 tests/load_tests/test_generic_load_assessments.py \
|
|
--csv students.csv \
|
|
--start 0 --end 100 \
|
|
--workers 30 \
|
|
--headless \
|
|
--url https://staging.cognitiveprism.com
|
|
```
|
|
|
|
### Example 3: Production (with visible browsers for debugging)
|
|
```bash
|
|
python3 tests/load_tests/test_generic_load_assessments.py \
|
|
--csv students.csv \
|
|
--start 0 --end 1 \
|
|
--workers 1 \
|
|
--visible \
|
|
--url https://cognitiveprism.tech4bizsolutions.com
|
|
```
|
|
|
|
---
|
|
|
|
## ⚙️ URL Format
|
|
|
|
- **With protocol**: `http://localhost:3983` or `https://example.com`
|
|
- **Trailing slash**: Automatically removed (both `http://localhost:3983/` and `http://localhost:3983` work)
|
|
- **Port**: Can specify any port (e.g., `http://localhost:5000`)
|
|
|
|
---
|
|
|
|
## 🔍 Verification
|
|
|
|
When you run the script, it will print:
|
|
- `🌐 Using custom URL: {your_url}` if `--url` is provided
|
|
- `🌐 Using default URL: {default_url}` if `--url` is not provided
|
|
|
|
---
|
|
|
|
## 📝 Notes
|
|
|
|
- The URL override happens **before** page objects are instantiated
|
|
- All page objects will use the custom URL automatically
|
|
- No need to modify config files or environment variables
|
|
- Works with all existing functionality (login, password reset, profile, assessments, etc.)
|
|
|
|
---
|
|
|
|
## 🚀 Quick Reference
|
|
|
|
```bash
|
|
# Full command with all options
|
|
python3 tests/load_tests/test_generic_load_assessments.py \
|
|
--csv <csv_file> \
|
|
--start <start_index> \
|
|
--end <end_index> \
|
|
--workers <num_workers> \
|
|
--headless \
|
|
--url <custom_url> \
|
|
--metrics-interval <interval>
|
|
```
|
|
|
|
---
|
|
|
|
**Status**: ✅ Ready to Use
|
|
|