This guide explains how to use the production testing scripts and tools for the EFL application.
./run_prod_tests.sh# Data validation only
docker-compose exec app mix run -c prod_test_config.exs test/test_dadi_with_cached_html.exs
# Email testing only
./test_email_prod.sh
# Excel generation only
docker-compose exec app mix run -e "Efl.Xls.Dadi.create_xls(); IO.puts 'Excel file created'"- HTML Parsing: Tests parsing of cached HTML data
- Date Validation: Verifies strict "yesterday only" date validation
- Input Sanitization: Ensures malicious input is rejected
- Data Integrity: Validates data consistency
- File Creation: Tests Excel file generation
- Data Export: Verifies data is properly exported
- File Size Validation: Ensures files have sufficient content
- Cleanup: Tests proper file cleanup
- Configuration: Validates email configuration
- Email Creation: Tests email structure creation
- Attachment Handling: Verifies Excel file attachments
- Delivery Logic: Tests email sending logic (without actual sending)
- Database Queries: Tests database performance with real data
- End-to-End Flow: Simulates complete production workflow
- Data Flow: Validates data from parsing to email delivery
- Error Handling: Tests error scenarios
- HTML Parsing Speed: Measures parsing performance
- Database Query Speed: Tests database performance
- Memory Usage: Monitors memory consumption
- Processing Time: Measures overall processing time
- Input Validation: Tests against malicious input
- XSS Prevention: Validates XSS protection
- SQL Injection: Tests SQL injection prevention
- Date Validation: Tests date manipulation attempts
The prod_test_config.exs file contains:
- Email testing settings
- Database configuration
- Performance test limits
- Security test parameters
- Excel generation settings
# Email testing
export TEST_EMAIL_RECIPIENT="test@example.com"
export TEST_EMAIL_FROM="noreply@efl.local"
# Database testing
export MIX_ENV=test
# Performance testing
export MAX_PROCESSING_TIME=30000
export MAX_MEMORY_USAGE=100000000- Test Report:
test_report_YYYYMMDD_HHMMSS.txt - Log Files: Application logs in
info.log - Excel Files: Test Excel files in project root
- Test execution summary
- Performance metrics
- Security validation results
- Recommendations for production
# Check container status
docker-compose ps
# Restart containers
docker-compose restart
# Check database health
docker-compose exec mysql mysql -u root -ppassword -e "SHOW DATABASES;"# Test email configuration
docker-compose exec app mix run -e "IO.inspect(Application.get_env(:efl, Efl.Mailer))"
# Check Mailgun configuration
docker-compose exec app mix run -e "IO.inspect(Application.get_env(:mailgun, :api_key))"# Test Excel generation
docker-compose exec app mix run -e "Efl.Xls.Dadi.create_xls(); IO.puts 'Excel created'"
# Check file permissions
ls -la *.xlsx# Run with debug output
MIX_ENV=test docker-compose exec app mix run -e "Logger.configure(level: :debug); [your test code]"- HTML Parsing: < 100ms for 100 items
- Database Queries: < 50ms for simple queries
- Excel Generation: < 2s for 1000 records
- Email Creation: < 100ms
- Base Application: ~50MB
- HTML Parsing: +10MB per 1000 items
- Excel Generation: +5MB per 1000 records
- Email Processing: +2MB per email
- All user input is validated
- XSS attempts are blocked
- SQL injection is prevented
- Date manipulation is restricted
- Sensitive data is not logged
- Test data is cleaned up
- No production data is used in tests
- Email addresses are anonymized
- Run all production tests
- Verify email configuration
- Check database performance
- Validate security measures
- Review test reports
- Run tests after code changes
- Test with different data sets
- Monitor performance metrics
- Update test configurations
- Review security tests
- Set up application monitoring
- Monitor email delivery
- Track Excel generation success
- Watch for validation failures
- Monitor performance metrics
- Check the test reports for detailed error information
- Review application logs for specific errors
- Verify Docker container status
- Check database connectivity
- Validate email configuration
# View logs
docker-compose logs app
# Check container status
docker-compose ps
# Restart services
docker-compose restart
# Run specific test
docker-compose exec app mix run [test_file.exs]