CP_AUTOMATION/SETUP_GUIDE.md
2025-12-12 20:59:50 +05:30

5.9 KiB
Raw Permalink Blame History

Complete Setup Guide - Load Testing Environment

📦 What's Included

1. requirements.txt

Complete list of Python dependencies needed for load testing:

  • pytest (testing framework)
  • selenium (browser automation)
  • webdriver-manager (automatic ChromeDriver management)
  • And more...

2. setup_load_test_environment.sh

World-class setup script that:

  • Checks Python version (3.8+)
  • Creates virtual environment
  • Installs all dependencies
  • Validates Chrome/ChromeDriver
  • Verifies function signature
  • Creates necessary directories
  • Provides clear feedback and next steps

🚀 Quick Start

For Fresh Systems

# 1. Navigate to project
cd /home/tech4biz/work/CP_Front_Automation_Test

# 2. Run setup script
./setup_load_test_environment.sh

# 3. Activate virtual environment (if not auto-activated)
source venv/bin/activate

# 4. Validate setup
python3 tests/load_tests/validate_function_signature.py

# 5. Run your first test
python3 tests/load_tests/test_generic_load_assessments.py \
    --csv your_students.csv \
    --start 0 --end 1 \
    --workers 1 --headless

📋 What the Setup Script Does

Step-by-Step Process

  1. Python Check - Verifies Python 3.8+ is installed
  2. pip Check - Ensures pip is available
  3. Virtual Environment - Creates/validates venv
  4. Dependencies - Installs all packages from requirements.txt
  5. Chrome Check - Verifies Chrome browser (or notes auto-install)
  6. ChromeDriver - Notes that webdriver-manager handles it automatically
  7. Function Validation - Validates load test function signature
  8. Project Structure - Verifies all required files/directories exist
  9. Reports Directory - Creates reports/load_tests directory
  10. Final Verification - Tests Python imports

Output Example

================================================================================
🚀 World-Class Load Test Environment Setup
================================================================================

Step 1: Checking Python version...
✅ Python 3.10.12 found (>= 3.8 required)

Step 2: Checking pip...
✅ pip3 found

Step 3: Setting up virtual environment...
✅ Virtual environment created

Step 4: Activating virtual environment...
✅ Virtual environment activated

Step 5: Upgrading pip...
✅ pip upgraded to latest version

Step 6: Installing Python dependencies...
✅ All Python dependencies installed

Step 7: Checking Chrome browser...
✅ Chrome found: Google Chrome 120.0.6099.109

Step 8: Checking ChromeDriver...
⚠️  ChromeDriver not found in PATH
  webdriver-manager will automatically download and manage ChromeDriver
✅ ChromeDriver will be handled automatically

Step 9: Validating load test function signature...
✅ Function signature validation passed

Step 10: Validating project structure...
✅ Directory exists: pages
✅ Directory exists: utils
✅ Directory exists: tests/load_tests
✅ Directory exists: config
✅ File exists: tests/load_tests/test_generic_load_assessments.py
✅ File exists: config/config.py

Step 11: Creating reports directory...
✅ Reports directory created: reports/load_tests

Step 12: Final verification...
✅ Core dependencies imported successfully
✅ Python imports working correctly

================================================================================
✅ Setup Complete!
================================================================================

📋 Next Steps:
...

🔧 Manual Setup (Alternative)

If you prefer manual setup or the script doesn't work:

# 1. Create virtual environment
python3 -m venv venv

# 2. Activate it
source venv/bin/activate

# 3. Upgrade pip
pip install --upgrade pip

# 4. Install dependencies
pip install -r requirements.txt

# 5. Validate
python3 tests/load_tests/validate_function_signature.py

Verification Checklist

After setup, verify everything works:

  • Virtual environment created and activated
  • All dependencies installed (pip list shows selenium, pytest, etc.)
  • Function signature validated (no errors)
  • Chrome browser accessible
  • Project structure intact
  • Reports directory created

🐛 Troubleshooting

Issue: "Permission denied" when running setup script

Solution:

chmod +x setup_load_test_environment.sh
./setup_load_test_environment.sh

Issue: "Python 3 not found"

Solution:

# Ubuntu/Debian
sudo apt-get update
sudo apt-get install python3 python3-pip python3-venv

# Or check if python3 is installed
which python3

Issue: "pip install fails"

Solution:

# Upgrade pip first
python3 -m pip install --upgrade pip

# Then install requirements
pip install -r requirements.txt

Issue: "Chrome not found"

Solution:

# Ubuntu/Debian
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get install -f  # Fix dependencies if needed

Note: webdriver-manager will handle ChromeDriver automatically, so you don't need to install it manually.

  • requirements.txt - Python dependencies
  • setup_load_test_environment.sh - Automated setup script
  • tests/load_tests/README.md - Complete documentation
  • tests/load_tests/QUICK_START.md - Quick reference
  • tests/load_tests/validate_function_signature.py - Validation script

🎯 Next Steps

After setup is complete:

  1. Validate Setup:

    python3 tests/load_tests/validate_function_signature.py
    
  2. Run First Test:

    python3 tests/load_tests/test_generic_load_assessments.py \
        --csv your_students.csv \
        --start 0 --end 1 \
        --workers 1 --headless
    
  3. Read Documentation:

    • Full guide: tests/load_tests/README.md
    • Quick start: tests/load_tests/QUICK_START.md

Status: Production Ready Last Updated: 2025-12-12