CP_StressTest
This commit is contained in:
parent
e7b7a7538a
commit
a6736372dc
98
scripts/6_PC_LOAD_TEST_WITH_URLS.md
Normal file
98
scripts/6_PC_LOAD_TEST_WITH_URLS.md
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
# 6 PC Load Test Commands - With Custom URLs
|
||||||
|
|
||||||
|
## 🎯 Overview
|
||||||
|
|
||||||
|
Each PC can hit a different URL by adding `--url` argument.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚀 Complete Commands with Custom URLs
|
||||||
|
|
||||||
|
### **PC 1 - 50 Students from CSV 1 (0-49)**
|
||||||
|
```bash
|
||||||
|
cd /home/tech4biz/work/CP_Front_Automation_Test && source venv/bin/activate && python3 tests/load_tests/test_generic_load_assessments.py --csv students_with_passwords_2025-12-15T10-49-08_01.csv --start 0 --end 50 --workers 50 --headless --metrics-interval 10 --url http://localhost:3983
|
||||||
|
```
|
||||||
|
|
||||||
|
### **PC 2 - 50 Students from CSV 1 (50-99)**
|
||||||
|
```bash
|
||||||
|
cd /home/tech4biz/work/CP_Front_Automation_Test && source venv/bin/activate && python3 tests/load_tests/test_generic_load_assessments.py --csv students_with_passwords_2025-12-15T10-49-08_01.csv --start 50 --end 100 --workers 50 --headless --metrics-interval 10 --url http://localhost:3983
|
||||||
|
```
|
||||||
|
|
||||||
|
### **PC 3 - 50 Students from CSV 2 (0-49)**
|
||||||
|
```bash
|
||||||
|
cd /home/tech4biz/work/CP_Front_Automation_Test && source venv/bin/activate && python3 tests/load_tests/test_generic_load_assessments.py --csv students_with_passwords_2025-12-15T10-59-02_03.csv --start 0 --end 50 --workers 50 --headless --metrics-interval 10 --url http://localhost:3983
|
||||||
|
```
|
||||||
|
|
||||||
|
### **PC 4 - 50 Students from CSV 2 (50-99)**
|
||||||
|
```bash
|
||||||
|
cd /home/tech4biz/work/CP_Front_Automation_Test && source venv/bin/activate && python3 tests/load_tests/test_generic_load_assessments.py --csv students_with_passwords_2025-12-15T10-59-02_03.csv --start 50 --end 100 --workers 50 --headless --metrics-interval 10 --url http://localhost:3983
|
||||||
|
```
|
||||||
|
|
||||||
|
### **PC 5 - 50 Students from CSV 3 (0-49)**
|
||||||
|
```bash
|
||||||
|
cd /home/tech4biz/work/CP_Front_Automation_Test && source venv/bin/activate && python3 tests/load_tests/test_generic_load_assessments.py --csv students_with_passwords_2025-12-15T11-06-37_05.csv --start 0 --end 50 --workers 50 --headless --metrics-interval 10 --url http://localhost:3983
|
||||||
|
```
|
||||||
|
|
||||||
|
### **PC 6 - 50 Students from CSV 3 (50-99)**
|
||||||
|
```bash
|
||||||
|
cd /home/tech4biz/work/CP_Front_Automation_Test && source venv/bin/activate && python3 tests/load_tests/test_generic_load_assessments.py --csv students_with_passwords_2025-12-15T11-06-37_05.csv --start 50 --end 100 --workers 50 --headless --metrics-interval 10 --url http://localhost:3983
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🌐 Different URLs Per PC (Example)
|
||||||
|
|
||||||
|
### **PC 1 - Local**
|
||||||
|
```bash
|
||||||
|
cd /home/tech4biz/work/CP_Front_Automation_Test && source venv/bin/activate && python3 tests/load_tests/test_generic_load_assessments.py --csv students_with_passwords_2025-12-15T10-49-08_01.csv --start 0 --end 50 --workers 50 --headless --metrics-interval 10 --url http://localhost:3983
|
||||||
|
```
|
||||||
|
|
||||||
|
### **PC 2 - Staging**
|
||||||
|
```bash
|
||||||
|
cd /home/tech4biz/work/CP_Front_Automation_Test && source venv/bin/activate && python3 tests/load_tests/test_generic_load_assessments.py --csv students_with_passwords_2025-12-15T10-49-08_01.csv --start 50 --end 100 --workers 50 --headless --metrics-interval 10 --url https://staging.example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
### **PC 3 - Production**
|
||||||
|
```bash
|
||||||
|
cd /home/tech4biz/work/CP_Front_Automation_Test && source venv/bin/activate && python3 tests/load_tests/test_generic_load_assessments.py --csv students_with_passwords_2025-12-15T10-59-02_03.csv --start 0 --end 50 --workers 50 --headless --metrics-interval 10 --url https://cognitiveprism.tech4bizsolutions.com
|
||||||
|
```
|
||||||
|
|
||||||
|
### **PC 4 - Different Port**
|
||||||
|
```bash
|
||||||
|
cd /home/tech4biz/work/CP_Front_Automation_Test && source venv/bin/activate && python3 tests/load_tests/test_generic_load_assessments.py --csv students_with_passwords_2025-12-15T10-59-02_03.csv --start 50 --end 100 --workers 50 --headless --metrics-interval 10 --url http://localhost:5000
|
||||||
|
```
|
||||||
|
|
||||||
|
### **PC 5 - Custom URL**
|
||||||
|
```bash
|
||||||
|
cd /home/tech4biz/work/CP_Front_Automation_Test && source venv/bin/activate && python3 tests/load_tests/test_generic_load_assessments.py --csv students_with_passwords_2025-12-15T11-06-37_05.csv --start 0 --end 50 --workers 50 --headless --metrics-interval 10 --url http://192.168.1.100:3983
|
||||||
|
```
|
||||||
|
|
||||||
|
### **PC 6 - Another Custom URL**
|
||||||
|
```bash
|
||||||
|
cd /home/tech4biz/work/CP_Front_Automation_Test && source venv/bin/activate && python3 tests/load_tests/test_generic_load_assessments.py --csv students_with_passwords_2025-12-15T11-06-37_05.csv --start 50 --end 100 --workers 50 --headless --metrics-interval 10 --url https://api.example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📝 URL Format Examples
|
||||||
|
|
||||||
|
- `http://localhost:3983` - Local development
|
||||||
|
- `http://localhost:5000` - Different port
|
||||||
|
- `https://staging.example.com` - Staging environment
|
||||||
|
- `https://cognitiveprism.tech4bizsolutions.com` - Production
|
||||||
|
- `http://192.168.1.100:3983` - Local network IP
|
||||||
|
- `https://api.example.com` - Any custom URL
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 💡 Notes
|
||||||
|
|
||||||
|
- **Each PC can use a different URL** - just change the `--url` value
|
||||||
|
- **No URL = uses default** from config (localhost:3983 or live)
|
||||||
|
- **Trailing slash is optional** - both `http://localhost:3983` and `http://localhost:3983/` work
|
||||||
|
- **All URLs are supported** - local, staging, production, custom IPs, etc.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Status**: ✅ Ready - Each PC Can Hit Different URLs
|
||||||
|
|
||||||
@ -26,6 +26,7 @@ import threading
|
|||||||
import time
|
import time
|
||||||
import csv
|
import csv
|
||||||
import argparse
|
import argparse
|
||||||
|
import sys
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
@ -33,6 +34,22 @@ from selenium.webdriver.chrome.options import Options
|
|||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.common.exceptions import WebDriverException
|
from selenium.common.exceptions import WebDriverException
|
||||||
|
|
||||||
|
# CRITICAL: Parse --url argument EARLY (before importing pages) to override BASE_URL
|
||||||
|
# This ensures pages use the custom URL when they import BASE_URL
|
||||||
|
_pre_parser = argparse.ArgumentParser(add_help=False)
|
||||||
|
_pre_parser.add_argument('--url', type=str, default=None)
|
||||||
|
_pre_args, _ = _pre_parser.parse_known_args()
|
||||||
|
|
||||||
|
if _pre_args.url:
|
||||||
|
# Override BASE_URL in config BEFORE pages import it
|
||||||
|
import config.config as config_module
|
||||||
|
custom_url = _pre_args.url.rstrip('/')
|
||||||
|
config_module.BASE_URL = custom_url
|
||||||
|
config_module.LOGIN_URL = f"{custom_url}/"
|
||||||
|
config_module.DASHBOARD_URL = f"{custom_url}/student/dashboard"
|
||||||
|
config_module.ASSESSMENTS_URL = f"{custom_url}/assessments"
|
||||||
|
config_module.PROFILE_EDITOR_URL = f"{custom_url}/student/profile-builder"
|
||||||
|
|
||||||
from utils.load_test_base import LoadTestBase, LoadTestResult, TestStatus
|
from utils.load_test_base import LoadTestBase, LoadTestResult, TestStatus
|
||||||
from pages.login_page import LoginPage
|
from pages.login_page import LoginPage
|
||||||
from pages.mandatory_reset_page import MandatoryResetPage
|
from pages.mandatory_reset_page import MandatoryResetPage
|
||||||
@ -767,21 +784,12 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Override BASE_URL if --url is provided
|
# URL override already happened before page imports (above)
|
||||||
|
# Just print confirmation
|
||||||
if args.url:
|
if args.url:
|
||||||
# Remove trailing slash if present
|
|
||||||
custom_url = args.url.rstrip('/')
|
custom_url = args.url.rstrip('/')
|
||||||
# Override BASE_URL in config before importing pages
|
|
||||||
import config.config as config_module
|
|
||||||
config_module.BASE_URL = custom_url
|
|
||||||
# Update all derived URLs
|
|
||||||
config_module.LOGIN_URL = f"{custom_url}/"
|
|
||||||
config_module.DASHBOARD_URL = f"{custom_url}/student/dashboard"
|
|
||||||
config_module.ASSESSMENTS_URL = f"{custom_url}/assessments"
|
|
||||||
config_module.PROFILE_EDITOR_URL = f"{custom_url}/student/profile-builder"
|
|
||||||
print(f"🌐 Using custom URL: {custom_url}")
|
print(f"🌐 Using custom URL: {custom_url}")
|
||||||
else:
|
else:
|
||||||
# Import to show default URL
|
|
||||||
from config.config import BASE_URL
|
from config.config import BASE_URL
|
||||||
print(f"🌐 Using default URL: {BASE_URL}")
|
print(f"🌐 Using default URL: {BASE_URL}")
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user