run_lobster_comprehensive_parallel.ps1 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # Parallel comprehensive validation: travel / semantic / profile as separate jobs (sequential invoke, split reports for CI).
  2. # Usage:
  3. # cd d:\ylrz_saas_new\java\scripts
  4. # .\run_lobster_comprehensive_parallel.ps1 -CompanyId 338 -TenantId 33
  5. # .\run_lobster_comprehensive_parallel.ps1 -SkipStress -SkipBuild -SkipRestart
  6. param(
  7. [string]$ApiBase = "http://127.0.0.1:8006",
  8. [int]$CompanyId = 338,
  9. [int]$TenantId = 33,
  10. [string]$OpsSecret = "lobster-dev-ops",
  11. [string]$ReportDir = "",
  12. [switch]$SkipBuild,
  13. [switch]$SkipRestart,
  14. [switch]$SkipStress,
  15. [string]$JavaHome = ""
  16. )
  17. $ErrorActionPreference = "Stop"
  18. $repoRoot = Split-Path $PSScriptRoot -Parent
  19. if ([string]::IsNullOrWhiteSpace($ReportDir)) {
  20. $ReportDir = Join-Path $repoRoot "validation-reports"
  21. }
  22. New-Item -ItemType Directory -Force -Path $ReportDir | Out-Null
  23. if ([string]::IsNullOrWhiteSpace($JavaHome)) {
  24. if ($env:JAVA_HOME) { $JavaHome = $env:JAVA_HOME }
  25. elseif (Test-Path "D:\jdk-17.0.2") { $JavaHome = "D:\jdk-17.0.2" }
  26. }
  27. if (-not $SkipBuild -or -not $SkipRestart) {
  28. $ciArgs = @{
  29. ApiBase = $ApiBase
  30. CompanyId = $CompanyId
  31. TenantId = $TenantId
  32. OpsSecret = $OpsSecret
  33. JavaHome = $JavaHome
  34. SkipBuild = $SkipBuild.IsPresent
  35. SkipRestart = $SkipRestart.IsPresent
  36. SkipStress = $true
  37. }
  38. & (Join-Path $PSScriptRoot "run_lobster_travel_validation_ci.ps1") @ciArgs
  39. if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
  40. }
  41. $h = @{
  42. "Content-Type" = "application/json"
  43. "X-Lobster-Ops-Secret" = $OpsSecret
  44. }
  45. function Invoke-LobsterJob {
  46. param(
  47. [string]$Name,
  48. [string]$Uri,
  49. [string]$OutFile
  50. )
  51. Write-Host " start $Name ..." -ForegroundColor Yellow
  52. $sw = [System.Diagnostics.Stopwatch]::StartNew()
  53. try {
  54. $r = Invoke-RestMethod -Method POST -Uri $Uri -Headers $h -TimeoutSec 900
  55. $r | ConvertTo-Json -Depth 30 | Out-File -FilePath $OutFile -Encoding utf8
  56. $passed = $r.passed
  57. Write-Host " done $Name passed=$passed ($([math]::Round($sw.Elapsed.TotalSeconds,1))s)" -ForegroundColor $(if ($passed) { "Green" } else { "Red" })
  58. return [PSCustomObject]@{ Name = $Name; Passed = $passed; Seconds = $sw.Elapsed.TotalSeconds; File = $OutFile; Failures = $r.failures }
  59. } catch {
  60. Write-Host " FAIL $Name : $($_.Exception.Message)" -ForegroundColor Red
  61. return [PSCustomObject]@{ Name = $Name; Passed = $false; Seconds = $sw.Elapsed.TotalSeconds; File = $OutFile; Failures = @($_.Exception.Message) }
  62. }
  63. }
  64. Write-Host "=== Lobster Split Validation (travel + semantic + profile) ===" -ForegroundColor Cyan
  65. $stressQ = if ($SkipStress) { "false" } else { "true" }
  66. $totalSw = [System.Diagnostics.Stopwatch]::StartNew()
  67. $results = @(
  68. (Invoke-LobsterJob -Name "travel-full" `
  69. -Uri "$ApiBase/api/lobster/admin/validation/travel-full/$CompanyId?tenantId=$TenantId&includeStress=$stressQ" `
  70. -OutFile (Join-Path $ReportDir "parallel-travel.json")),
  71. (Invoke-LobsterJob -Name "semantic-full" `
  72. -Uri "$ApiBase/api/lobster/admin/validation/semantic-context/$CompanyId?tenantId=$TenantId&mode=full" `
  73. -OutFile (Join-Path $ReportDir "parallel-semantic.json")),
  74. (Invoke-LobsterJob -Name "profile-full" `
  75. -Uri "$ApiBase/api/lobster/admin/validation/profile-domain-full/$CompanyId?tenantId=$TenantId" `
  76. -OutFile (Join-Path $ReportDir "parallel-profile.json"))
  77. )
  78. $allPassed = ($results | Where-Object { -not $_.Passed }).Count -eq 0
  79. $summary = [ordered]@{
  80. companyId = $CompanyId
  81. tenantId = $TenantId
  82. includeStress = (-not $SkipStress)
  83. startedAt = (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
  84. durationSec = [math]::Round($totalSw.Elapsed.TotalSeconds, 1)
  85. allPassed = $allPassed
  86. jobs = $results
  87. }
  88. $summaryPath = Join-Path $ReportDir "parallel-summary.json"
  89. $summary | ConvertTo-Json -Depth 8 | Out-File -FilePath $summaryPath -Encoding utf8
  90. Write-Host ""
  91. Write-Host "Summary: allPassed=$allPassed total=$($summary.durationSec)s -> $summaryPath" -ForegroundColor $(if ($allPassed) { "Green" } else { "Red" })
  92. if (-not $allPassed) {
  93. foreach ($r in $results | Where-Object { -not $_.Passed }) {
  94. Write-Host " FAILED: $($r.Name)" -ForegroundColor Red
  95. if ($r.Failures) { $r.Failures | ForEach-Object { Write-Host " $_" } }
  96. }
  97. exit 1
  98. }
  99. exit 0