update
This commit is contained in:
@@ -1,11 +1,212 @@
|
||||
# Lokaler Dev-Start: Bibliothek + Doku-Prompt Testbuild v3 (kein Release, kein Deploy)
|
||||
# Lokaler Dev-Start: Konsistenter Office-Release-Candidate v5 (Stable 1.3.12 unveraendert)
|
||||
# Startet zuerst den lokalen HTML-Proxy als persistenten Prozess, wartet auf HTTP 200, dann Desktop.
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Write-TestLog {
|
||||
param([string]$Message)
|
||||
Write-Host ("[{0}] {1}" -f (Get-Date -Format "yyyy-MM-dd HH:mm:ss.fff"), $Message)
|
||||
}
|
||||
|
||||
$env:AZA_DOKU_PROMPT_TEST = "1"
|
||||
Set-Location $PSScriptRoot
|
||||
Write-Host "Starte AzA Testbuild Bibliothek + Doku-Prompt v3 (Stable 1.3.12 unveraendert)..."
|
||||
$testExe = Join-Path $PSScriptRoot "dist\test_bibliothek_doku_prompt_v3\aza_desktop.exe"
|
||||
$ProjectRoot = $PSScriptRoot
|
||||
Set-Location $ProjectRoot
|
||||
|
||||
Write-Host "Starte AzA Testbuild test_final_release_candidate_v13 (Stable 1.3.12 unveraendert)..."
|
||||
|
||||
$testExe = Join-Path $ProjectRoot "dist\test_final_release_candidate_v13\aza_desktop.exe"
|
||||
if (-not (Test-Path $testExe)) {
|
||||
Write-Error "Testbuild v3 nicht gefunden: $testExe`nBitte zuerst den v3-Testbuild erzeugen."
|
||||
Write-Error "Testbuild nicht gefunden: $testExe`nBitte zuerst build_test_final_release_candidate_v13.ps1 ausfuehren."
|
||||
exit 1
|
||||
}
|
||||
Set-Location (Split-Path $testExe)
|
||||
& $testExe
|
||||
|
||||
$shellExe = Join-Path (Split-Path $testExe) "AZA_EmpfangShell.exe"
|
||||
$panelExe = Join-Path (Split-Path $testExe) "AZA_KontaktPanel.exe"
|
||||
if (-not (Test-Path $shellExe)) {
|
||||
Write-Warning "AZA_EmpfangShell.exe fehlt neben dem Testbuild: $shellExe"
|
||||
}
|
||||
if (-not (Test-Path $panelExe)) {
|
||||
Write-Warning "AZA_KontaktPanel.exe fehlt neben dem Testbuild: $panelExe"
|
||||
}
|
||||
|
||||
# Upstream-API (backend_url.txt)
|
||||
$upstream = "https://api.aza-medwork.ch"
|
||||
$backendFile = Join-Path $ProjectRoot "backend_url.txt"
|
||||
if (Test-Path $backendFile) {
|
||||
$line = Get-Content $backendFile -ErrorAction SilentlyContinue | Where-Object { $_ -and -not $_.StartsWith("#") } | Select-Object -First 1
|
||||
if ($line) { $upstream = $line.Trim().TrimEnd("/") }
|
||||
}
|
||||
$env:AZA_EMPFANG_TEST_UPSTREAM = $upstream
|
||||
|
||||
# Python + Proxy-Skript (absolute Pfade)
|
||||
$pythonExe = (Get-Command python -ErrorAction Stop).Source
|
||||
$proxyScript = Join-Path $ProjectRoot "aza_empfang_test_html_proxy.py"
|
||||
if (-not (Test-Path $proxyScript)) {
|
||||
Write-Error "Proxy-Skript fehlt: $proxyScript"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$logDir = Join-Path $ProjectRoot ".aza_test_proxy_logs"
|
||||
New-Item -ItemType Directory -Path $logDir -Force | Out-Null
|
||||
$ts = Get-Date -Format "yyyyMMdd_HHmmss"
|
||||
$stdoutLog = Join-Path $logDir "proxy_stdout_$ts.log"
|
||||
$stderrLog = Join-Path $logDir "proxy_stderr_$ts.log"
|
||||
|
||||
# Veraltete Test-Proxy-Prozesse beenden: sonst bedient ein frueher gestarteter
|
||||
# Proxy (mit altem Code im Speicher) denselben Port und bricht SSO/Redirect.
|
||||
try {
|
||||
$staleProxies = Get-CimInstance Win32_Process -Filter "Name='python.exe'" -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.CommandLine -and ($_.CommandLine -match 'aza_empfang_test_html_proxy\.py') }
|
||||
foreach ($sp in $staleProxies) {
|
||||
Write-Host ("Beende veralteten Test-Proxy PID {0}" -f $sp.ProcessId)
|
||||
Stop-Process -Id $sp.ProcessId -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
if ($staleProxies) { Start-Sleep -Milliseconds 500 }
|
||||
} catch {
|
||||
Write-Warning ("Stale-Proxy-Cleanup uebersprungen: {0}" -f $_.Exception.Message)
|
||||
}
|
||||
|
||||
Write-Host "Starte Test-HTML-Proxy (persistenter Prozess)..."
|
||||
Write-Host " Python: $pythonExe"
|
||||
Write-Host " Skript: $proxyScript"
|
||||
Write-Host " Upstream: $upstream"
|
||||
Write-Host " Log stdout: $stdoutLog"
|
||||
Write-Host " Log stderr: $stderrLog"
|
||||
|
||||
$proxyProc = Start-Process `
|
||||
-FilePath $pythonExe `
|
||||
-ArgumentList @("aza_empfang_test_html_proxy.py", "--serve") `
|
||||
-WorkingDirectory $ProjectRoot `
|
||||
-PassThru `
|
||||
-WindowStyle Hidden `
|
||||
-RedirectStandardOutput $stdoutLog `
|
||||
-RedirectStandardError $stderrLog
|
||||
|
||||
$proxyPort = $null
|
||||
$deadline = (Get-Date).AddSeconds(15)
|
||||
while ((Get-Date) -lt $deadline) {
|
||||
if ($proxyProc.HasExited) {
|
||||
$errTail = ""
|
||||
if (Test-Path $stderrLog) {
|
||||
$errTail = (Get-Content $stderrLog -Raw -ErrorAction SilentlyContinue)
|
||||
}
|
||||
$outTail = ""
|
||||
if (Test-Path $stdoutLog) {
|
||||
$outTail = (Get-Content $stdoutLog -Raw -ErrorAction SilentlyContinue)
|
||||
}
|
||||
Write-Error @"
|
||||
Test-HTML-Proxy-Prozess beendet (Exit $($proxyProc.ExitCode)) bevor READY.
|
||||
stdout: $stdoutLog
|
||||
stderr: $stderrLog
|
||||
--- stdout ---
|
||||
$outTail
|
||||
--- stderr ---
|
||||
$errTail
|
||||
"@
|
||||
exit 1
|
||||
}
|
||||
if (Test-Path $stdoutLog) {
|
||||
$out = Get-Content $stdoutLog -Raw -ErrorAction SilentlyContinue
|
||||
if ($out -match 'READY port=(\d+)') {
|
||||
$proxyPort = [int]$Matches[1]
|
||||
break
|
||||
}
|
||||
}
|
||||
Start-Sleep -Milliseconds 300
|
||||
}
|
||||
|
||||
if (-not $proxyPort) {
|
||||
if (-not $proxyProc.HasExited) {
|
||||
Stop-Process -Id $proxyProc.Id -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
Write-Error "Test-HTML-Proxy: READY-Timeout nach 15s. Logs: $stdoutLog / $stderrLog"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$proxyBase = "http://127.0.0.1:$proxyPort"
|
||||
$healthUrl = "$proxyBase/health"
|
||||
$empfangUrl = "$proxyBase/empfang/"
|
||||
|
||||
Write-TestLog ("Proxy READY auf Port {0} (PID {1})" -f $proxyPort, $proxyProc.Id)
|
||||
|
||||
# HTTP-Healthcheck (zusaetzlich zur READY-Zeile)
|
||||
try {
|
||||
$healthResp = Invoke-WebRequest -Uri $healthUrl -UseBasicParsing -TimeoutSec 5
|
||||
if ($healthResp.StatusCode -ne 200) {
|
||||
throw "Health Status $($healthResp.StatusCode)"
|
||||
}
|
||||
Write-Host ("Healthcheck OK: {0}" -f $healthUrl)
|
||||
} catch {
|
||||
Stop-Process -Id $proxyProc.Id -Force -ErrorAction SilentlyContinue
|
||||
Write-Error ("Healthcheck fehlgeschlagen: {0} - {1}`nstderr: {2}" -f $healthUrl, $_.Exception.Message, $stderrLog)
|
||||
exit 1
|
||||
}
|
||||
|
||||
try {
|
||||
$htmlResp = Invoke-WebRequest -Uri $empfangUrl -UseBasicParsing -TimeoutSec 8
|
||||
if ($htmlResp.StatusCode -ne 200) {
|
||||
throw "Empfang HTML Status $($htmlResp.StatusCode)"
|
||||
}
|
||||
if ($htmlResp.Headers["Cache-Control"] -notmatch "no-store") {
|
||||
Write-Warning "Empfang HTML ohne Cache-Control no-store (weiterhin OK)"
|
||||
}
|
||||
Write-Host ("Empfang HTML OK: {0} ({1} Bytes)" -f $empfangUrl, $htmlResp.RawContentLength)
|
||||
} catch {
|
||||
Stop-Process -Id $proxyProc.Id -Force -ErrorAction SilentlyContinue
|
||||
Write-Error ("Empfang-HTML-Check fehlgeschlagen: {0} - {1}`nstderr: {2}" -f $empfangUrl, $_.Exception.Message, $stderrLog)
|
||||
exit 1
|
||||
}
|
||||
|
||||
$env:AZA_EMPFANG_TEST_PROXY_PORT = [string]$proxyPort
|
||||
$env:AZA_EMPFANG_WEB_BASE = $proxyBase
|
||||
$env:AZA_EMPFANG_CHAT_SHELL_URL = "$proxyBase/empfang/"
|
||||
|
||||
Write-Host "Umgebung gesetzt:"
|
||||
Write-Host " AZA_EMPFANG_WEB_BASE=$($env:AZA_EMPFANG_WEB_BASE)"
|
||||
Write-Host " AZA_EMPFANG_CHAT_SHELL_URL=$($env:AZA_EMPFANG_CHAT_SHELL_URL)"
|
||||
Write-TestLog "Starte Desktop-Testbuild..."
|
||||
|
||||
try {
|
||||
$desktopProc = Start-Process `
|
||||
-FilePath $testExe `
|
||||
-WorkingDirectory (Split-Path $testExe) `
|
||||
-PassThru
|
||||
|
||||
Write-TestLog ("Desktop-Prozess gestartet (PID {0})" -f $desktopProc.Id)
|
||||
Start-Sleep -Seconds 2
|
||||
|
||||
if ($proxyProc.HasExited) {
|
||||
Write-Error ("Proxy beendet unerwartet nach Desktopstart. stderr: {0}" -f $stderrLog)
|
||||
exit 1
|
||||
}
|
||||
|
||||
$postHealth = Invoke-WebRequest -Uri $healthUrl -UseBasicParsing -TimeoutSec 5
|
||||
if ($postHealth.StatusCode -ne 200) {
|
||||
throw ("Post-Desktop Health Status {0}" -f $postHealth.StatusCode)
|
||||
}
|
||||
Write-TestLog ("Proxy nach Desktopstart erreichbar: health {0}" -f $postHealth.StatusCode)
|
||||
|
||||
$postHtml = Invoke-WebRequest -Uri $empfangUrl -UseBasicParsing -TimeoutSec 8
|
||||
if ($postHtml.StatusCode -ne 200) {
|
||||
throw ("Post-Desktop Empfang Status {0}" -f $postHtml.StatusCode)
|
||||
}
|
||||
Write-TestLog ("Proxy Empfang nach Desktopstart: {0} ({1} Bytes)" -f $postHtml.StatusCode, $postHtml.RawContentLength)
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "V5-Test laeuft."
|
||||
Write-Host "Proxy bleibt aktiv."
|
||||
Write-Host "Nach Abschluss aller AzA-Testfenster hier ENTER druecken, um den Proxy zu beenden."
|
||||
Write-Host ""
|
||||
Read-Host | Out-Null
|
||||
} finally {
|
||||
Write-TestLog ("Beende Test-HTML-Proxy (PID {0})..." -f $proxyProc.Id)
|
||||
if (-not $proxyProc.HasExited) {
|
||||
Stop-Process -Id $proxyProc.Id -Force -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Milliseconds 200
|
||||
}
|
||||
if (-not $proxyProc.HasExited) {
|
||||
Write-Warning ("Proxy-Prozess {0} laeuft noch - bitte manuell pruefen." -f $proxyProc.Id)
|
||||
} else {
|
||||
Write-Host "Proxy beendet."
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user