4.3 KiB
4.3 KiB
Load Test Script - Issue Analysis & Resolution
🔴 The Original Issue
Error from JSON report:
TypeError: complete_assessment_flow_for_student() got multiple values for argument 'headless'
Root Cause:
LoadTestBase.execute_test_for_user()calls:test_function(user_id, *args, **kwargs)- We were calling it with:
execute_test_for_user(user_id=1, func, student_info, idx, headless=True) - This becomes:
func(1, student_info, idx, headless=True) - Original function signature (BROKEN):
def complete_assessment_flow_for_student( student_info: Dict, # ← Expected student_info first, but got user_id=1! student_index: int, headless: bool = True ) - Python tried to assign:
student_info = 1❌ (wrong type!)student_index = student_info❌ (wrong!)headless = idx❌ (wrong!)- Then
headless=Truein kwargs → CONFLICT! ❌
✅ The Fix
New function signature (CORRECT):
def complete_assessment_flow_for_student(
user_id: int, # ← Now accepts user_id as first parameter
student_info: Dict,
student_index: int,
headless: bool = True
)
Now when called:
func(1, student_info, idx, headless=True)- Python correctly assigns:
user_id = 1✅student_info = student_info✅student_index = idx✅headless = True✅
✅ Verification Steps Completed
- ✅ Function signature fixed - Added
user_idas first parameter - ✅ Validation script created -
validate_function_signature.pyconfirms signature is correct - ✅ Input validation added - Validates all inputs before execution
- ✅ Error handling enhanced - Better error messages and cleanup
- ✅ Pre-submission validation - Validates students before submitting to thread pool
🧪 How to Verify It Works
Step 1: Validate Signature
cd /home/tech4biz/work/CP_Front_Automation_Test
source venv/bin/activate
python3 tests/load_tests/validate_function_signature.py
Expected: ✅ Function signature is valid!
Step 2: Test with 1 Student (Dry Run)
python3 tests/load_tests/test_generic_load_assessments.py \
--csv students_with_passwords_2025-12-12T13-19-32.csv \
--start 0 \
--end 1 \
--workers 1 \
--headless \
--metrics-interval 1
Expected: Should complete successfully without the TypeError
Step 3: Test with 10 Students
python3 tests/load_tests/test_generic_load_assessments.py \
--csv students_with_passwords_2025-12-12T13-19-32.csv \
--start 0 \
--end 10 \
--workers 10 \
--headless \
--metrics-interval 5
Step 4: Full Load Test (100+ Students)
python3 tests/load_tests/test_generic_load_assessments.py \
--csv students_with_passwords_2025-12-12T13-19-32.csv \
--start 0 \
--end 100 \
--workers 100 \
--headless \
--metrics-interval 10
📋 What Each Student Does
Complete Flow:
- Login - Excel password first, fallback to Admin@123
- Password Reset - If modal appears (smart detection)
- Profile Fill - Complete to 100% if incomplete (smart detection)
- Navigate to Assessments - Go to assessments page
- Start Assessment - Click first available assessment
- Select Domain - Click first unlocked domain
- Answer All Questions - Answer all questions in domain (handles all 5 question types)
- Submit Assessment - Submit when all questions answered
- Feedback - Submit domain feedback if modal appears
🎯 Current Status
- ✅ Issue Identified: Function signature mismatch
- ✅ Issue Fixed: Added
user_idas first parameter - ✅ Validated: Signature validation script confirms fix
- ⚠️ Not Yet Tested: Need to run actual test to confirm it works end-to-end
🚀 Next Steps
- Run validation script (already done - ✅ passed)
- Run test with 1 student to verify end-to-end
- If successful, scale up to 10, then 100, then 500
🔍 Code Flow Verification
Call Chain:
run_load_test()
└─> executor.submit(execute_test_for_user, user_id, func, student_info, idx, headless=True)
└─> execute_test_for_user()
└─> test_function(user_id, *args, **kwargs)
└─> complete_assessment_flow_for_student(user_id, student_info, idx, headless=True) ✅
This matches perfectly now!