| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- # Lobster travel full-chain validation (21 sections + stress).
- # Usage:
- # cd d:\ylrz_saas_new\java\scripts
- # .\lobster_travel_full_validation.ps1
- # .\lobster_travel_full_validation.ps1 -CompanyId 338 -TenantId 33
- # .\lobster_travel_full_validation.ps1 -SkipStress
- # CI one-click (build + restart + validate):
- # .\run_lobster_travel_validation_ci.ps1 -CompanyId 338 -TenantId 33
- param(
- [string]$ApiBase = "http://127.0.0.1:8006",
- [int]$CompanyId = 338,
- [int]$TenantId = 33,
- [string]$OpsSecret = "lobster-dev-ops",
- [string]$DialogueIndustry = "travel",
- [switch]$SkipStress
- )
- $ErrorActionPreference = "Stop"
- # Windows 控制台与报告文件统一 UTF-8,避免中文乱码
- 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-travel-validation-$stamp.json"
- Write-Host "=== Lobster Travel Full Validation ===" -ForegroundColor Cyan
- Write-Host "ApiBase=$ApiBase CompanyId=$CompanyId TenantId=$TenantId DialogueIndustry=$DialogueIndustry"
- # 1) Service reachable
- 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
- }
- $includeStress = if ($SkipStress) { "false" } else { "true" }
- $uri = "$($ApiBase.TrimEnd('/'))/api/lobster/admin/validation/travel-full/${CompanyId}?tenantId=${TenantId}&includeStress=$includeStress&dialogueIndustry=$DialogueIndustry"
- $headers = @{
- "Content-Type" = "application/json"
- "X-Lobster-Ops-Secret" = $OpsSecret
- }
- Write-Host "POST $uri" -ForegroundColor DarkGray
- Write-Host "Running validation (may take 1-3 min)..." -ForegroundColor Yellow
- try {
- $r = Invoke-WebRequest -Uri $uri -Method POST -Headers $headers -UseBasicParsing -TimeoutSec 900
- $body = $r.Content
- [System.IO.File]::WriteAllText($reportFile, $body, $utf8NoBom)
- Write-Host "Report saved: $reportFile" -ForegroundColor Green
- $json = $body | ConvertFrom-Json
- Copy-Item -Path $reportFile -Destination (Join-Path $reportDir "lobster-travel-validation-latest.json") -Force
- Write-Host ""
- Write-Host "--- Section Summary ---" -ForegroundColor Cyan
- if ($json.sections) {
- $json.sections.PSObject.Properties | ForEach-Object {
- $name = $_.Name
- $sec = $_.Value
- if ($sec -is [PSCustomObject] -and $sec.passed -ne $null) {
- $color = if ($sec.passed -eq $true) { "Green" } else { "Red" }
- Write-Host (" {0}: {1} ({2})" -f $name, $sec.passed, $sec.message) -ForegroundColor $color
- } elseif ($name -eq "stress" -and $sec) {
- Write-Host " stress:" -ForegroundColor Cyan
- $sec.PSObject.Properties | ForEach-Object {
- $st = $_.Value
- if ($st.passed -ne $null) {
- $color = if ($st.passed -eq $true) { "Green" } else { "Red" }
- Write-Host (" {0}: {1}" -f $_.Name, $st.passed) -ForegroundColor $color
- }
- }
- }
- }
- }
- Write-Host ("Duration: {0}ms Overall: {1}" -f $json.durationMs, $json.passed) -ForegroundColor Cyan
- Write-Host ""
- if ($json.passed -eq $true) {
- Write-Host "PASSED all checks" -ForegroundColor Green
- exit 0
- } else {
- Write-Host "FAILED some checks did not pass" -ForegroundColor Red
- if ($json.failures) {
- foreach ($f in $json.failures) {
- Write-Host " - $f" -ForegroundColor Yellow
- }
- }
- exit 1
- }
- } catch {
- Write-Host "FAIL request error: $($_.Exception.Message)" -ForegroundColor Red
- exit 1
- }
|