# Quick Start - Load Testing Script

## What Happened?

The script was using **student names** instead of **CPIDs** because:
- CSV column is `"Student CPID"` (with space)
- Script was looking for `"cpid"` or `"CPID"` 
- When not found, it used the first column (`"First Name"`)

**✅ FIXED**: Script now correctly extracts CPID from `"Student CPID"` column.

## How to Run

### 1. Basic Test (2 students, visible mode for debugging)
```bash
python scripts/load_test_e2e_assessment.py --students 2 --csv students_with_passwords_2025-12-10T12-00-33.csv --no-headless
```

### 2. Small Load Test (5 students, headless)
```bash
python scripts/load_test_e2e_assessment.py --students 5 --csv students_with_passwords_2025-12-10T12-00-33.csv
```

### 3. Medium Load Test (20 students, 5 concurrent)
```bash
python scripts/load_test_e2e_assessment.py --students 20 --csv students_with_passwords_2025-12-10T12-00-33.csv --concurrent 5
```

### 4. Large Load Test (50+ students, 10 concurrent)
```bash
python scripts/load_test_e2e_assessment.py --students 50 --csv students_with_passwords_2025-12-10T12-00-33.csv --concurrent 10
```

## Arguments

- `--students N`: Number of students to test (required)
- `--csv FILE`: Path to CSV file (required)
- `--concurrent N`: Number of concurrent students (default: 5)
- `--no-headless`: Run in visible mode (for debugging)
- `--headless`: Run in headless mode (default)

## CSV Format

Your CSV should have:
- `Student CPID` column (or `cpid`, `CPID`)
- `Password` column (or `password`, `PASSWORD`)
- Other student data (First Name, Last Name, etc.)

## What It Does

For each student:
1. ✅ Login (smart password handling)
2. ✅ Password reset (if needed)
3. ✅ Profile completion (if needed)
4. ✅ Complete ONE domain assessment (all 5 question types)
5. ✅ Submit and provide feedback

## Expected Output

```
🚀 Starting flow for: SC309TB0284 (Vijaya Reddy)
✅ Completed: SC309TB0284 (Vijaya Reddy) - success - 245.32s

🚀 Starting flow for: SC3010A037W (M N Suresh Narayanan)
✅ Completed: SC3010A037W (M N Suresh Narayanan) - success - 198.76s

================================================================================
LOAD TEST SUMMARY
================================================================================
✅ Success: 2/2
❌ Failed: 0/2
⏱️  Total Duration: 245.32s
📊 Average per Student: 122.66s
```

## Troubleshooting

### "User not found" error
- ✅ **FIXED**: Script now correctly extracts CPID from CSV
- Verify CSV has `Student CPID` column
- Check CPID values are correct

### High failure rate
- Reduce `--concurrent` value
- Check backend server capacity
- Verify network stability

### Browser crashes
- Reduce `--concurrent` value
- Check system RAM (need ~500MB per concurrent student)
- Use `--headless` mode for better performance

---

**Status**: ✅ **READY TO USE** - CPID extraction fixed!


