# Comprehensive CURL Functionality Test Script Write-Host "`n========================================" -ForegroundColor Cyan Write-Host " CURL FUNCTIONALITY TESTS" -ForegroundColor Cyan Write-Host "========================================`n" -ForegroundColor Cyan $testResults = @() # Test 1: Webapp Write-Host "1. WEBAPP" -ForegroundColor Yellow Write-Host " Testing: http://localhost:3000" -ForegroundColor Gray try { $response = Invoke-WebRequest -Uri "http://localhost:3000" -TimeoutSec 5 -UseBasicParsing -ErrorAction Stop Write-Host " ✅ Status: $($response.StatusCode)" -ForegroundColor Green $testResults += @{ Test = "Webapp"; Status = "PASS"; Code = $response.StatusCode } } catch { Write-Host " ❌ Error: $($_.Exception.Message)" -ForegroundColor Red $testResults += @{ Test = "Webapp"; Status = "FAIL"; Code = "Error" } } # Test 2: Orchestrator Root Write-Host "`n2. ORCHESTRATOR ROOT" -ForegroundColor Yellow Write-Host " Testing: http://localhost:8080" -ForegroundColor Gray try { $response = Invoke-WebRequest -Uri "http://localhost:8080" -TimeoutSec 5 -UseBasicParsing -ErrorAction Stop Write-Host " ⚠️ Status: $($response.StatusCode) (Expected 404)" -ForegroundColor Yellow $testResults += @{ Test = "Orchestrator Root"; Status = "PASS"; Code = $response.StatusCode } } catch { if ($_.Exception.Response.StatusCode -eq 404) { Write-Host " ✅ Status: 404 (Expected - no root route)" -ForegroundColor Green $testResults += @{ Test = "Orchestrator Root"; Status = "PASS"; Code = 404 } } else { Write-Host " ❌ Error: $($_.Exception.Message)" -ForegroundColor Red $testResults += @{ Test = "Orchestrator Root"; Status = "FAIL"; Code = "Error" } } } # Test 3: Health Check Write-Host "`n3. HEALTH CHECK" -ForegroundColor Yellow Write-Host " Testing: http://localhost:8080/health" -ForegroundColor Gray try { $response = Invoke-WebRequest -Uri "http://localhost:8080/health" -TimeoutSec 5 -UseBasicParsing -ErrorAction Stop $health = $response.Content | ConvertFrom-Json Write-Host " ✅ Status: $($response.StatusCode)" -ForegroundColor Green Write-Host " Status: $($health.status)" -ForegroundColor $(if ($health.status -eq "healthy") { "Green" } else { "Yellow" }) Write-Host " Database: $($health.checks.database)" -ForegroundColor $(if ($health.checks.database -eq "up") { "Green" } else { "Yellow" }) Write-Host " Memory: $($health.checks.memory)" -ForegroundColor $(if ($health.checks.memory -eq "ok") { "Green" } else { "Yellow" }) $testResults += @{ Test = "Health Check"; Status = "PASS"; Code = $response.StatusCode } } catch { if ($_.Exception.Response.StatusCode -eq 503) { Write-Host " ⚠️ Status: 503 (Service initializing or database not connected)" -ForegroundColor Yellow $testResults += @{ Test = "Health Check"; Status = "PARTIAL"; Code = 503 } } else { Write-Host " ❌ Error: $($_.Exception.Message)" -ForegroundColor Red $testResults += @{ Test = "Health Check"; Status = "FAIL"; Code = "Error" } } } # Test 4: Metrics Write-Host "`n4. METRICS" -ForegroundColor Yellow Write-Host " Testing: http://localhost:8080/metrics" -ForegroundColor Gray try { $response = Invoke-WebRequest -Uri "http://localhost:8080/metrics" -TimeoutSec 5 -UseBasicParsing -ErrorAction Stop Write-Host " ✅ Status: $($response.StatusCode)" -ForegroundColor Green $metricLines = ($response.Content -split "`n" | Where-Object { $_ -match "^[^#]" -and $_.Trim() -ne "" }).Count Write-Host " Metrics: $metricLines lines" -ForegroundColor White $testResults += @{ Test = "Metrics"; Status = "PASS"; Code = $response.StatusCode } } catch { Write-Host " ❌ Error: $($_.Exception.Message)" -ForegroundColor Red $testResults += @{ Test = "Metrics"; Status = "FAIL"; Code = "Error" } } # Test 5: Readiness Write-Host "`n5. READINESS" -ForegroundColor Yellow Write-Host " Testing: http://localhost:8080/ready" -ForegroundColor Gray try { $response = Invoke-WebRequest -Uri "http://localhost:8080/ready" -TimeoutSec 5 -UseBasicParsing -ErrorAction Stop $ready = $response.Content | ConvertFrom-Json Write-Host " ✅ Status: $($response.StatusCode)" -ForegroundColor Green Write-Host " Ready: $($ready.ready)" -ForegroundColor $(if ($ready.ready) { "Green" } else { "Yellow" }) $testResults += @{ Test = "Readiness"; Status = "PASS"; Code = $response.StatusCode } } catch { Write-Host " ⚠️ Status: $($_.Exception.Response.StatusCode) (May be expected)" -ForegroundColor Yellow $testResults += @{ Test = "Readiness"; Status = "PARTIAL"; Code = $_.Exception.Response.StatusCode } } # Test 6: Liveness Write-Host "`n6. LIVENESS" -ForegroundColor Yellow Write-Host " Testing: http://localhost:8080/live" -ForegroundColor Gray try { $response = Invoke-WebRequest -Uri "http://localhost:8080/live" -TimeoutSec 5 -UseBasicParsing -ErrorAction Stop $live = $response.Content | ConvertFrom-Json Write-Host " ✅ Status: $($response.StatusCode)" -ForegroundColor Green Write-Host " Alive: $($live.alive)" -ForegroundColor Green $testResults += @{ Test = "Liveness"; Status = "PASS"; Code = $response.StatusCode } } catch { Write-Host " ❌ Error: $($_.Exception.Message)" -ForegroundColor Red $testResults += @{ Test = "Liveness"; Status = "FAIL"; Code = "Error" } } # Test 7: CORS Headers Write-Host "`n7. CORS HEADERS" -ForegroundColor Yellow Write-Host " Testing: http://localhost:8080/health" -ForegroundColor Gray try { $response = Invoke-WebRequest -Uri "http://localhost:8080/health" -TimeoutSec 5 -UseBasicParsing -ErrorAction Stop if ($response.Headers["Access-Control-Allow-Origin"]) { Write-Host " ✅ CORS headers present" -ForegroundColor Green Write-Host " Access-Control-Allow-Origin: $($response.Headers['Access-Control-Allow-Origin'])" -ForegroundColor White $testResults += @{ Test = "CORS Headers"; Status = "PASS"; Code = "Present" } } else { Write-Host " ⚠️ CORS headers not found" -ForegroundColor Yellow $testResults += @{ Test = "CORS Headers"; Status = "PARTIAL"; Code = "Missing" } } } catch { Write-Host " ❌ Error: $($_.Exception.Message)" -ForegroundColor Red $testResults += @{ Test = "CORS Headers"; Status = "FAIL"; Code = "Error" } } # Test 8: Error Handling Write-Host "`n8. ERROR HANDLING" -ForegroundColor Yellow Write-Host " Testing: http://localhost:8080/api/nonexistent" -ForegroundColor Gray try { $response = Invoke-WebRequest -Uri "http://localhost:8080/api/nonexistent" -TimeoutSec 5 -UseBasicParsing -ErrorAction Stop Write-Host " ⚠️ Unexpected status: $($response.StatusCode)" -ForegroundColor Yellow $testResults += @{ Test = "Error Handling"; Status = "PARTIAL"; Code = $response.StatusCode } } catch { if ($_.Exception.Response.StatusCode -eq 404) { Write-Host " ✅ Status: 404 (Proper error handling)" -ForegroundColor Green $testResults += @{ Test = "Error Handling"; Status = "PASS"; Code = 404 } } else { Write-Host " ⚠️ Status: $($_.Exception.Response.StatusCode)" -ForegroundColor Yellow $testResults += @{ Test = "Error Handling"; Status = "PARTIAL"; Code = $_.Exception.Response.StatusCode } } } # Test 9: Response Times Write-Host "`n9. RESPONSE TIMES" -ForegroundColor Yellow $endpoints = @( @{ Name = "Webapp"; URL = "http://localhost:3000" }, @{ Name = "Health"; URL = "http://localhost:8080/health" }, @{ Name = "Metrics"; URL = "http://localhost:8080/metrics" } ) foreach ($endpoint in $endpoints) { try { $stopwatch = [System.Diagnostics.Stopwatch]::StartNew() $response = Invoke-WebRequest -Uri $endpoint.URL -TimeoutSec 5 -UseBasicParsing -ErrorAction Stop $stopwatch.Stop() $ms = $stopwatch.ElapsedMilliseconds $color = if ($ms -lt 100) { "Green" } elseif ($ms -lt 500) { "Yellow" } else { "Red" } Write-Host " $($endpoint.Name): $ms ms" -ForegroundColor $color } catch { Write-Host " $($endpoint.Name): Error" -ForegroundColor Red } } # Summary Write-Host "`n========================================" -ForegroundColor Cyan Write-Host " TEST SUMMARY" -ForegroundColor Cyan Write-Host "========================================`n" -ForegroundColor Cyan $passed = ($testResults | Where-Object { $_.Status -eq "PASS" }).Count $partial = ($testResults | Where-Object { $_.Status -eq "PARTIAL" }).Count $failed = ($testResults | Where-Object { $_.Status -eq "FAIL" }).Count foreach ($result in $testResults) { $color = switch ($result.Status) { "PASS" { "Green" } "PARTIAL" { "Yellow" } "FAIL" { "Red" } } Write-Host "$($result.Test): $($result.Status) (Code: $($result.Code))" -ForegroundColor $color } Write-Host "`nTotal: $passed Passed, $partial Partial, $failed Failed" -ForegroundColor White Write-Host ""