82 lines
3.0 KiB
PowerShell
82 lines
3.0 KiB
PowerShell
# SANDBOX Tesztelõ Script
|
|
# Futtatás: .\test-sandbox.ps1
|
|
|
|
$ErrorActionPreference = "Continue"
|
|
$projectPath = $PSScriptRoot
|
|
$url = "http://localhost:59579"
|
|
|
|
Write-Host "=== SANDBOX TESZTELÕ ===" -ForegroundColor Cyan
|
|
|
|
# 1. Build
|
|
Write-Host "`n[1/5] Building..." -ForegroundColor Yellow
|
|
$buildResult = dotnet build $projectPath --verbosity quiet 2>&1
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "BUILD FAILED!" -ForegroundColor Red
|
|
$buildResult | Where-Object { $_ -match "error" } | ForEach-Object { Write-Host $_ -ForegroundColor Red }
|
|
exit 1
|
|
}
|
|
Write-Host "Build OK" -ForegroundColor Green
|
|
|
|
# 2. Ellenõrizzük, fut-e már
|
|
$existingProcess = Get-Process -Name "Mango.Sandbox.EndPoints" -ErrorAction SilentlyContinue
|
|
if ($existingProcess) {
|
|
Write-Host "`n[2/5] Stopping existing SANDBOX..." -ForegroundColor Yellow
|
|
Stop-Process -Name "Mango.Sandbox.EndPoints" -Force
|
|
Start-Sleep -Seconds 2
|
|
}
|
|
|
|
# 3. Indítás háttérben
|
|
Write-Host "`n[3/5] Starting SANDBOX..." -ForegroundColor Yellow
|
|
$process = Start-Process -FilePath "dotnet" -ArgumentList "run", "--project", $projectPath, "--urls", $url -PassThru -RedirectStandardOutput "$projectPath\sandbox-stdout.log" -RedirectStandardError "$projectPath\sandbox-stderr.log"
|
|
Start-Sleep -Seconds 10
|
|
|
|
# 4. Health check
|
|
Write-Host "`n[4/5] Testing endpoints..." -ForegroundColor Yellow
|
|
|
|
try {
|
|
$response = Invoke-WebRequest -Uri "$url/" -UseBasicParsing -TimeoutSec 5
|
|
if ($response.StatusCode -eq 200) {
|
|
Write-Host " / endpoint: OK" -ForegroundColor Green
|
|
}
|
|
} catch {
|
|
Write-Host " / endpoint: FAILED - $_" -ForegroundColor Red
|
|
}
|
|
|
|
try {
|
|
$response = Invoke-WebRequest -Uri "$url/health" -UseBasicParsing -TimeoutSec 5
|
|
if ($response.StatusCode -eq 200) {
|
|
Write-Host " /health endpoint: OK" -ForegroundColor Green
|
|
}
|
|
} catch {
|
|
Write-Host " /health endpoint: FAILED - $_" -ForegroundColor Red
|
|
}
|
|
|
|
# SignalR negotiate teszt
|
|
try {
|
|
$response = Invoke-WebRequest -Uri "$url/fbHub/negotiate?negotiateVersion=1" -Method POST -UseBasicParsing -TimeoutSec 5
|
|
Write-Host " SignalR negotiate: OK" -ForegroundColor Green
|
|
} catch {
|
|
Write-Host " SignalR negotiate: FAILED - $_" -ForegroundColor Red
|
|
}
|
|
|
|
# 5. SignalR Hub hívás teszt (GetMeasuringUsers - tag 70)
|
|
Write-Host "`n[5/5] Testing SignalR Hub method..." -ForegroundColor Yellow
|
|
Write-Host " GetMeasuringUsers (tag 70) - Check SANDBOX console for logs" -ForegroundColor Gray
|
|
|
|
# Hibák kiírása
|
|
Write-Host "`n=== STDERR LOG (last 50 lines) ===" -ForegroundColor Cyan
|
|
if (Test-Path "$projectPath\sandbox-stderr.log") {
|
|
Get-Content "$projectPath\sandbox-stderr.log" -Tail 50 | ForEach-Object {
|
|
if ($_ -match "error|fail|exception") {
|
|
Write-Host $_ -ForegroundColor Red
|
|
} elseif ($_ -match "warn") {
|
|
Write-Host $_ -ForegroundColor Yellow
|
|
} else {
|
|
Write-Host $_ -ForegroundColor Gray
|
|
}
|
|
}
|
|
}
|
|
|
|
Write-Host "`n=== SANDBOX PID: $($process.Id) ===" -ForegroundColor Cyan
|
|
Write-Host "Leállítás: Stop-Process -Id $($process.Id)" -ForegroundColor Gray
|