| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- # One-click CI/local gate: build fs-saas-company, restart, run travel full validation.
- # Usage:
- # cd d:\ylrz_saas_new\java\scripts
- # .\run_lobster_travel_validation_ci.ps1 -CompanyId 338 -TenantId 33
- # .\run_lobster_travel_validation_ci.ps1 -SkipBuild -SkipRestart
- param(
- [string]$ApiBase = "http://127.0.0.1:8006",
- [int]$CompanyId = 338,
- [int]$TenantId = 33,
- [string]$OpsSecret = "lobster-dev-ops",
- [string]$JavaHome = "",
- [switch]$SkipBuild,
- [switch]$SkipRestart,
- [switch]$SkipStress
- )
- $ErrorActionPreference = "Stop"
- $repoRoot = Split-Path $PSScriptRoot -Parent
- $jarPath = Join-Path $repoRoot "fs-saas-company\target\fs-saas-company.jar"
- $logPath = Join-Path $repoRoot "fs-saas-company-travel-validation-run.log"
- if ([string]::IsNullOrWhiteSpace($JavaHome)) {
- if ($env:JAVA_HOME) { $JavaHome = $env:JAVA_HOME }
- elseif (Test-Path "D:\jdk-17.0.2") { $JavaHome = "D:\jdk-17.0.2" }
- else { throw "Set -JavaHome or JAVA_HOME" }
- }
- $mvn = "D:\maven\apache-maven-3.9.15\bin\mvn.cmd"
- if (-not (Test-Path $mvn)) {
- $mvn = "mvn"
- }
- Write-Host "=== Lobster Travel Validation CI ===" -ForegroundColor Cyan
- if (-not $SkipBuild) {
- Write-Host "[1/3] mvn package fs-saas-company ..." -ForegroundColor Yellow
- $env:JAVA_HOME = $JavaHome
- $env:PATH = "$JavaHome\bin;$env:PATH"
- Push-Location $repoRoot
- & $mvn -pl fs-saas-company -am package -DskipTests -q
- if ($LASTEXITCODE -ne 0) { throw "Maven build failed" }
- Pop-Location
- } else {
- Write-Host "[1/3] skip build" -ForegroundColor DarkGray
- }
- if (-not $SkipRestart) {
- Write-Host "[2/3] restart fs-saas-company :8006 ..." -ForegroundColor Yellow
- Get-NetTCPConnection -LocalPort 8006 -ErrorAction SilentlyContinue |
- ForEach-Object { Stop-Process -Id $_.OwningProcess -Force -ErrorAction SilentlyContinue }
- Start-Sleep -Seconds 2
- if (-not (Test-Path $jarPath)) { throw "Jar missing: $jarPath" }
- Start-Process -FilePath "$JavaHome\bin\java.exe" `
- -ArgumentList @("-jar", $jarPath, "--spring.profiles.active=dev") `
- -RedirectStandardOutput $logPath `
- -RedirectStandardError "${logPath}.err" `
- -WindowStyle Hidden
- $deadline = (Get-Date).AddMinutes(5)
- $ready = $false
- do {
- Start-Sleep -Seconds 3
- try {
- $pingHeaders = @{ "X-Lobster-Ops-Secret" = $OpsSecret }
- Invoke-RestMethod -Uri "$ApiBase/api/lobster/admin/phase2/verify/$CompanyId?tenantId=$TenantId" `
- -Headers $pingHeaders -TimeoutSec 8 | Out-Null
- $ready = $true
- break
- } catch {
- if ((Get-Date) -gt $deadline) { break }
- }
- } while ((Get-Date) -lt $deadline)
- if (-not $ready) { throw "Service not ready on $ApiBase (see $logPath)" }
- Write-Host " service is up" -ForegroundColor Green
- } else {
- Write-Host "[2/3] skip restart" -ForegroundColor DarkGray
- }
- Write-Host "[3/3] run lobster_travel_full_validation.ps1 ..." -ForegroundColor Yellow
- $valArgs = @{
- ApiBase = $ApiBase
- CompanyId = $CompanyId
- TenantId = $TenantId
- OpsSecret = $OpsSecret
- }
- if ($SkipStress) { $valArgs.SkipStress = $true }
- & (Join-Path $PSScriptRoot "lobster_travel_full_validation.ps1") @valArgs
- exit $LASTEXITCODE
|