# Lobster full engine validation: health + integration + all UI page probes + travel lifecycle chain. # Usage: # cd d:\ylrz_saas_new\java\scripts # .\lobster_full_engine_validation.ps1 # .\lobster_full_engine_validation.ps1 -CompanyId 338 -TenantId 33 # .\lobster_full_engine_validation.ps1 -SkipTravelChain # .\lobster_full_engine_validation.ps1 -PagesOnly param( [string]$ApiBase = "http://127.0.0.1:8006", [int]$CompanyId = 338, [int]$TenantId = 33, [string]$OpsSecret = "lobster-dev-ops", [switch]$SkipTravelChain, [switch]$IncludeTravelStress, [switch]$PagesOnly ) $ErrorActionPreference = "Stop" try { [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8 } catch { } $utf8NoBom = New-Object System.Text.UTF8Encoding $false $reportDir = Join-Path $PSScriptRoot "reports" if (-not (Test-Path $reportDir)) { New-Item -ItemType Directory -Path $reportDir | Out-Null } $stamp = Get-Date -Format "yyyyMMdd-HHmmss" $reportFile = Join-Path $reportDir "lobster-full-engine-validation-$stamp.json" $travelChainFlag = "true" if ($SkipTravelChain -eq $true -or $PagesOnly -eq $true) { $travelChainFlag = "false" } $travelStressFlag = "false" if ($IncludeTravelStress -eq $true) { $travelStressFlag = "true" } Write-Host "=== Lobster Full Engine Validation ===" -ForegroundColor Cyan Write-Host "ApiBase=$ApiBase CompanyId=$CompanyId TenantId=$TenantId includeTravelChain=$travelChainFlag includeTravelStress=$travelStressFlag" try { $pingHeaders = @{ "X-Lobster-Ops-Secret" = $OpsSecret } Invoke-RestMethod -Uri "$ApiBase/api/lobster/admin/phase2/verify/$CompanyId?tenantId=$TenantId" -Headers $pingHeaders -TimeoutSec 15 | Out-Null Write-Host "OK service reachable" -ForegroundColor Green } catch { Write-Host "FAIL service not reachable at $ApiBase" -ForegroundColor Red Write-Host "Start fs-saas-company on port 8006 first." exit 1 } $uri = "$($ApiBase.TrimEnd('/'))/api/lobster/admin/validation/full-engine/${CompanyId}?tenantId=${TenantId}&includeTravelChain=${travelChainFlag}&includeTravelStress=${travelStressFlag}" $headers = @{ "Content-Type" = "application/json" "X-Lobster-Ops-Secret" = $OpsSecret } Write-Host "POST $uri" Write-Host "Running full engine validation (pages ~30s; with travel chain 3-5 min)..." try { $resp = Invoke-RestMethod -Uri $uri -Method Post -Headers $headers -TimeoutSec 1800 $json = $resp | ConvertTo-Json -Depth 30 [System.IO.File]::WriteAllText($reportFile, $json, $utf8NoBom) Write-Host "Report saved: $reportFile" -ForegroundColor Green } catch { Write-Host "FAIL request error: $($_.Exception.Message)" -ForegroundColor Red exit 1 } $passed = $resp.passed $durationMs = $resp.durationMs $pageRatio = $resp.requiredPagesPassed Write-Host "" Write-Host "Duration: ${durationMs}ms" -ForegroundColor $(if ($passed) { "Green" } else { "Yellow" }) Write-Host "Required pages: $pageRatio" -ForegroundColor $(if ($passed) { "Green" } else { "Yellow" }) if ($resp.sections.pageLinkProbes) { $pages = $resp.sections.pageLinkProbes.pages $failedPages = @($pages | Where-Object { $_.required -and -not $_.passed }) if ($failedPages.Count -gt 0) { Write-Host "Failed required pages:" -ForegroundColor Red foreach ($p in $failedPages) { Write-Host " $($p.path) [$($p.probe)] $($p.message)" -ForegroundColor Red } } else { Write-Host "All required UI page probes passed." -ForegroundColor Green } } if ($resp.integrationWarning) { Write-Host "Integration warning: $($resp.integrationWarning)" -ForegroundColor Yellow } if ($resp.failures -and $resp.failures.Count -gt 0) { Write-Host "Failures ($($resp.failures.Count)):" -ForegroundColor Red foreach ($f in $resp.failures) { Write-Host " - $f" -ForegroundColor Red } } if ($passed) { Write-Host "RESULT: PASS" -ForegroundColor Green exit 0 } else { Write-Host "RESULT: FAIL" -ForegroundColor Red exit 1 }