Files
roa2web-service-auto/reports-app/frontend/run-comprehensive-tests.sh
Marius Mutu 6b13ffa183 Initial commit: ROA2WEB - FastAPI + Vue.js + Telegram Bot
Modern ERP Reports Application with microservices architecture

Tech Stack:
- Backend: FastAPI + python-oracledb (Oracle DB integration)
- Frontend: Vue.js 3 + PrimeVue + Vite
- Telegram Bot: python-telegram-bot + SQLite
- Infrastructure: Shared database pool, JWT authentication, SSH tunnel

Features:
- FastAPI backend with async Oracle connection pool
- Vue.js 3 responsive frontend with PrimeVue components
- Telegram bot alternative interface
- Microservices architecture with shared components
- Complete deployment support (Linux Docker + Windows IIS)
- Comprehensive testing (Playwright E2E + pytest)

Repository Structure:
- reports-app/ - Main application (backend, frontend, telegram-bot)
- shared/ - Shared components (database pool, auth, utils)
- deployment/ - Deployment scripts (Linux & Windows)
- docs/ - Project documentation
- security/ - Security scanning and git hooks
2025-10-25 14:55:08 +03:00

514 lines
16 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# ROA2WEB Comprehensive Test Execution and Reporting Script
# Executes all tests, identifies errors, and generates detailed reports
# Created: 2025-08-04
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FRONTEND_DIR="$SCRIPT_DIR"
BACKEND_DIR="$SCRIPT_DIR/../backend"
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
REPORT_DIR="test-reports-$TIMESTAMP"
DETAILED_LOG="$REPORT_DIR/detailed-test-log.txt"
# Test execution flags
RUN_CLEANUP=true
RUN_BASIC_TESTS=true
RUN_REAL_WORLD_TESTS=true
RUN_DEBUGGING_TESTS=true
GENERATE_SCREENSHOTS=true
CHECK_SERVICES=true
# Results tracking
TOTAL_TESTS=0
PASSED_TESTS=0
FAILED_TESTS=0
ISSUES_FOUND=()
RECOMMENDATIONS=()
echo -e "${PURPLE}"
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ ROA2WEB Comprehensive Test Execution Suite ║"
echo "║ ║"
echo "║ • Error Detection & Analysis ║"
echo "║ • Performance Monitoring ║"
echo "║ • Real-World Scenario Testing ║"
echo "║ • Detailed Reporting & Recommendations ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo -e "${NC}"
echo ""
# Logging functions
log_info() {
echo -e "${BLUE} $1${NC}"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] INFO: $1" >> "$DETAILED_LOG"
}
log_success() {
echo -e "${GREEN}$1${NC}"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] SUCCESS: $1" >> "$DETAILED_LOG"
}
log_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] WARNING: $1" >> "$DETAILED_LOG"
}
log_error() {
echo -e "${RED}$1${NC}"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ERROR: $1" >> "$DETAILED_LOG"
ISSUES_FOUND+=("$1")
}
log_test() {
echo -e "${CYAN}🧪 $1${NC}"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] TEST: $1" >> "$DETAILED_LOG"
}
add_recommendation() {
RECOMMENDATIONS+=("$1")
echo "[$(date '+%Y-%m-%d %H:%M:%S')] RECOMMENDATION: $1" >> "$DETAILED_LOG"
}
# Create report directory
mkdir -p "$REPORT_DIR"
touch "$DETAILED_LOG"
# Initialize log
echo "ROA2WEB Comprehensive Test Execution Log" > "$DETAILED_LOG"
echo "Started: $(date)" >> "$DETAILED_LOG"
echo "=========================================" >> "$DETAILED_LOG"
echo "" >> "$DETAILED_LOG"
main() {
local start_time=$(date +%s)
log_info "Starting comprehensive test execution..."
log_info "Report directory: $REPORT_DIR"
echo ""
# Step 1: Cleanup previous test artifacts
if [ "$RUN_CLEANUP" = true ]; then
log_test "Step 1: Cleaning up previous test artifacts"
if [ -f "./cleanup-tests.sh" ]; then
./cleanup-tests.sh 2>&1 | tee -a "$DETAILED_LOG"
else
log_warning "Cleanup script not found, skipping cleanup"
fi
echo ""
fi
# Step 2: Environment and Service Check
if [ "$CHECK_SERVICES" = true ]; then
log_test "Step 2: Checking service availability"
check_services
echo ""
fi
# Step 3: Execute Basic Test Suite
if [ "$RUN_BASIC_TESTS" = true ]; then
log_test "Step 3: Executing basic test suite"
execute_basic_tests
echo ""
fi
# Step 4: Execute Real-World Tests
if [ "$RUN_REAL_WORLD_TESTS" = true ]; then
log_test "Step 4: Executing real-world comprehensive tests"
execute_real_world_tests
echo ""
fi
# Step 5: Execute Debugging Tests
if [ "$RUN_DEBUGGING_TESTS" = true ]; then
log_test "Step 5: Executing debugging and issue detection tests"
execute_debugging_tests
echo ""
fi
# Step 6: Performance Analysis
log_test "Step 6: Analyzing performance metrics"
analyze_performance
echo ""
# Step 7: Generate Comprehensive Report
log_test "Step 7: Generating comprehensive report"
generate_comprehensive_report
# Calculate execution time
local end_time=$(date +%s)
local execution_time=$((end_time - start_time))
local minutes=$((execution_time / 60))
local seconds=$((execution_time % 60))
echo ""
echo -e "${PURPLE}╔══════════════════════════════════════════════════════════════╗${NC}"
echo -e "${PURPLE}║ Execution Summary ║${NC}"
echo -e "${PURPLE}╚══════════════════════════════════════════════════════════════╝${NC}"
echo ""
log_info "Total Execution Time: ${minutes}m ${seconds}s"
log_info "Total Tests: $TOTAL_TESTS"
log_success "Passed Tests: $PASSED_TESTS"
if [ $FAILED_TESTS -gt 0 ]; then
log_error "Failed Tests: $FAILED_TESTS"
else
log_success "Failed Tests: $FAILED_TESTS"
fi
log_info "Issues Found: ${#ISSUES_FOUND[@]}"
log_info "Recommendations: ${#RECOMMENDATIONS[@]}"
echo ""
log_success "📊 Comprehensive test report generated: $REPORT_DIR/comprehensive-test-report.md"
log_info "📋 Detailed log available: $DETAILED_LOG"
if [ ${#ISSUES_FOUND[@]} -gt 0 ]; then
echo ""
log_warning "🚨 Issues found - check the detailed report for recommendations"
exit 1
else
echo ""
log_success "🎉 All tests completed successfully - no critical issues found!"
exit 0
fi
}
check_services() {
log_info "Checking required services..."
# Check backend
if curl -s http://localhost:8000/health > /dev/null 2>&1; then
log_success "Backend service (port 8000) is available"
else
log_error "Backend service (port 8000) is not available"
add_recommendation "Start backend service: cd ../backend && uvicorn app.main:app --reload --host 0.0.0.0 --port 8000"
fi
# Check frontend
if curl -s http://localhost:3001 > /dev/null 2>&1; then
log_success "Frontend service (port 3001) is available"
else
log_error "Frontend service (port 3001) is not available"
add_recommendation "Start frontend service: npm run dev"
fi
# Check SSH tunnel (Oracle database)
if nc -z localhost 1521 2>/dev/null; then
log_success "SSH tunnel (port 1521) appears to be active"
else
log_warning "SSH tunnel (port 1521) may not be active"
add_recommendation "Start SSH tunnel: cd ../../../.. && ./ssh_tunnel.sh start"
fi
# Check Node.js and npm
if command -v node &> /dev/null && command -v npm &> /dev/null; then
local node_version=$(node --version)
local npm_version=$(npm --version)
log_success "Node.js $node_version and npm $npm_version are available"
else
log_error "Node.js or npm not found"
add_recommendation "Install Node.js and npm"
fi
}
execute_basic_tests() {
log_info "Running basic authentication and UI tests..."
local basic_result=0
# Run login tests
if npx playwright test auth/login.spec.js --project=chromium --reporter=json > "$REPORT_DIR/basic-tests-result.json" 2>&1; then
log_success "Basic authentication tests passed"
PASSED_TESTS=$((PASSED_TESTS + 10))
else
log_error "Basic authentication tests failed"
FAILED_TESTS=$((FAILED_TESTS + 10))
basic_result=1
fi
TOTAL_TESTS=$((TOTAL_TESTS + 10))
# Analyze basic test results
if [ -f "$REPORT_DIR/basic-tests-result.json" ]; then
analyze_test_results "$REPORT_DIR/basic-tests-result.json" "Basic Tests"
fi
return $basic_result
}
execute_real_world_tests() {
log_info "Running real-world comprehensive tests..."
local real_world_result=0
if npx playwright test e2e/real-world-comprehensive.spec.js --project=chromium --reporter=json > "$REPORT_DIR/real-world-tests-result.json" 2>&1; then
log_success "Real-world comprehensive tests passed"
PASSED_TESTS=$((PASSED_TESTS + 4))
else
log_error "Real-world comprehensive tests failed"
FAILED_TESTS=$((FAILED_TESTS + 4))
real_world_result=1
fi
TOTAL_TESTS=$((TOTAL_TESTS + 4))
# Analyze real-world test results
if [ -f "$REPORT_DIR/real-world-tests-result.json" ]; then
analyze_test_results "$REPORT_DIR/real-world-tests-result.json" "Real-World Tests"
fi
return $real_world_result
}
execute_debugging_tests() {
log_info "Running debugging and issue detection tests..."
local debug_result=0
if npx playwright test e2e/debugging-real-issues.spec.js --project=chromium --reporter=json > "$REPORT_DIR/debugging-tests-result.json" 2>&1; then
log_success "Debugging tests passed"
PASSED_TESTS=$((PASSED_TESTS + 4))
else
log_error "Debugging tests failed"
FAILED_TESTS=$((FAILED_TESTS + 4))
debug_result=1
fi
TOTAL_TESTS=$((TOTAL_TESTS + 4))
# Analyze debugging test results
if [ -f "$REPORT_DIR/debugging-tests-result.json" ]; then
analyze_test_results "$REPORT_DIR/debugging-tests-result.json" "Debugging Tests"
fi
return $debug_result
}
analyze_test_results() {
local result_file="$1"
local test_category="$2"
if [ ! -f "$result_file" ]; then
log_warning "Result file $result_file not found for $test_category"
return
fi
log_info "Analyzing $test_category results..."
# Extract key information from JSON results
if command -v jq &> /dev/null; then
local total_tests=$(jq -r '.stats.total // 0' "$result_file")
local passed_tests=$(jq -r '.stats.passed // 0' "$result_file")
local failed_tests=$(jq -r '.stats.failed // 0' "$result_file")
local duration=$(jq -r '.stats.duration // 0' "$result_file")
log_info "$test_category: $passed_tests/$total_tests passed (${duration}ms)"
# Extract failed test details
local failed_test_titles=$(jq -r '.tests[] | select(.status == "failed") | .title' "$result_file" 2>/dev/null || echo "")
if [ -n "$failed_test_titles" ]; then
log_warning "Failed tests in $test_category:"
echo "$failed_test_titles" | while read -r title; do
log_error " - $title"
done
fi
else
log_warning "jq not available for detailed JSON analysis"
add_recommendation "Install jq for better test result analysis: sudo apt-get install jq"
fi
}
analyze_performance() {
log_info "Analyzing application performance..."
# Check if we have performance data from tests
local perf_issues=()
# Look for performance-related issues in logs
if grep -q "slow" "$DETAILED_LOG" 2>/dev/null; then
perf_issues+=("Slow requests detected")
fi
if grep -q "timeout" "$DETAILED_LOG" 2>/dev/null; then
perf_issues+=("Timeout issues detected")
fi
if [ ${#perf_issues[@]} -gt 0 ]; then
log_warning "Performance issues found:"
for issue in "${perf_issues[@]}"; do
log_warning " - $issue"
ISSUES_FOUND+=("Performance: $issue")
done
add_recommendation "Review performance bottlenecks and optimize slow endpoints"
else
log_success "No significant performance issues detected"
fi
}
generate_comprehensive_report() {
local report_file="$REPORT_DIR/comprehensive-test-report.md"
cat > "$report_file" << EOF
# 🧪 ROA2WEB Comprehensive Test Report
**Generated:** $(date)
**Execution Time:** Total execution logged in detailed log
**Test Environment:** Development (localhost)
## 📊 Executive Summary
| Metric | Value |
|--------|-------|
| Total Tests | $TOTAL_TESTS |
| Passed Tests | $PASSED_TESTS |
| Failed Tests | $FAILED_TESTS |
| Success Rate | $(( PASSED_TESTS * 100 / (TOTAL_TESTS > 0 ? TOTAL_TESTS : 1) ))% |
| Issues Found | ${#ISSUES_FOUND[@]} |
| Recommendations | ${#RECOMMENDATIONS[@]} |
## 🚨 Issues Identified
EOF
if [ ${#ISSUES_FOUND[@]} -gt 0 ]; then
echo "### Critical Issues:" >> "$report_file"
for issue in "${ISSUES_FOUND[@]}"; do
echo "- ❌ $issue" >> "$report_file"
done
echo "" >> "$report_file"
else
echo "✅ **No critical issues found!**" >> "$report_file"
echo "" >> "$report_file"
fi
cat >> "$report_file" << EOF
## 💡 Recommendations
EOF
if [ ${#RECOMMENDATIONS[@]} -gt 0 ]; then
for rec in "${RECOMMENDATIONS[@]}"; do
echo "- 🔧 $rec" >> "$report_file"
done
else
echo "✅ **No specific recommendations - application is performing well!**" >> "$report_file"
fi
cat >> "$report_file" << EOF
## 📋 Test Categories Executed
### 1. 🔐 Authentication Tests
- Login form validation
- Authentication flow
- Error handling
- Session management
### 2. 🌍 Real-World Tests
- Complete user journeys
- Network performance analysis
- Error handling stress tests
- Responsive design validation
### 3. 🔍 Debugging Tests
- API request format validation
- Button state logic verification
- Error message format checking
- Network monitoring
## 📁 Report Files
- **Detailed Log:** \`$(basename "$DETAILED_LOG")\`
- **Basic Tests:** \`basic-tests-result.json\`
- **Real-World Tests:** \`real-world-tests-result.json\`
- **Debugging Tests:** \`debugging-tests-result.json\`
## 🎯 Next Steps
1. **Address Critical Issues:** Review and fix any issues listed above
2. **Implement Recommendations:** Follow the recommendations for optimal performance
3. **Regular Testing:** Run this comprehensive test suite regularly
4. **Monitor Performance:** Keep track of response times and error rates
---
*Report generated by ROA2WEB Comprehensive Test Suite*
EOF
log_success "Comprehensive report generated: $report_file"
}
# Handle cleanup on exit
cleanup_on_exit() {
if [ -d "$REPORT_DIR" ]; then
log_info "Test reports saved in: $REPORT_DIR"
fi
}
trap cleanup_on_exit EXIT
# Show usage if help requested
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
echo "ROA2WEB Comprehensive Test Execution Script"
echo ""
echo "Usage: $0 [options]"
echo ""
echo "Options:"
echo " --no-cleanup Skip cleanup of previous test artifacts"
echo " --no-basic Skip basic test suite"
echo " --no-real-world Skip real-world tests"
echo " --no-debugging Skip debugging tests"
echo " --no-services Skip service availability check"
echo " --help, -h Show this help message"
echo ""
echo "Prerequisites:"
echo " - SSH tunnel active: ./ssh_tunnel.sh start"
echo " - Backend running: uvicorn app.main:app --reload --host 0.0.0.0 --port 8000"
echo " - Frontend running: npm run dev"
echo ""
exit 0
fi
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--no-cleanup)
RUN_CLEANUP=false
shift
;;
--no-basic)
RUN_BASIC_TESTS=false
shift
;;
--no-real-world)
RUN_REAL_WORLD_TESTS=false
shift
;;
--no-debugging)
RUN_DEBUGGING_TESTS=false
shift
;;
--no-services)
CHECK_SERVICES=false
shift
;;
*)
log_warning "Unknown option: $1"
shift
;;
esac
done
# Execute main function
main "$@"