diff --git a/test/Scripts.Integration.Test/crash-test-server.ps1 b/test/Scripts.Integration.Test/crash-test-server.ps1 index 71728f0c0..ccfd24a9e 100644 --- a/test/Scripts.Integration.Test/crash-test-server.ps1 +++ b/test/Scripts.Integration.Test/crash-test-server.ps1 @@ -33,10 +33,14 @@ try { # send an empty response $context.Response.ContentLength64 = 0 $context.Response.OutputStream.Close() + if ($context.Request.Url.PathAndQuery -eq "/STOP") { + break + } } } finally { - # This is always called when ctrl+c is used + # This is always called when ctrl+c is used - note, this doesn't seem to be 100 % working... + # instead, you can send a GET request to http://localhost:8000/STOP write-Host "HTTP server stopping!" $httpServer.Stop() } diff --git a/test/Scripts.Integration.Test/integration-run-smoke-test.ps1 b/test/Scripts.Integration.Test/integration-run-smoke-test.ps1 index 7bb2c2d6d..7ece71070 100644 --- a/test/Scripts.Integration.Test/integration-run-smoke-test.ps1 +++ b/test/Scripts.Integration.Test/integration-run-smoke-test.ps1 @@ -119,31 +119,44 @@ if ($Smoke) { # Native crash test if ($Crash) { - $httpServer = RunApiServer - RunTest "smoke-crash" + $runs = 1 # You can increase this to run the crash test multiple times in a loop (until it fails) + for ($run = 1; $run -le $runs; $run++) { + $httpServer = RunApiServer + RunTest "smoke-crash" - $successMessage = "POST http://localhost:8000/api/12345/minidump/" + $httpServerUri = "http://localhost:8000" + $successMessage = "POST $httpServerUri/api/12345/minidump/" - for ($i = 0; $i -lt 100; $i++) { - $output = Get-Content $httpServer.outFile -Raw + # Wait for 1 minute (600 * 100 milliseconds) until the expected message comes in + for ($i = 0; $i -lt 600; $i++) { + $output = Get-Content $httpServer.outFile -Raw - if ($output.Contains($successMessage)) { - break + if ($output.Contains($successMessage)) { + break + } + Start-Sleep -Milliseconds 100 } - Start-Sleep -Milliseconds 100 - } - $httpServer.process | Stop-Process -ErrorAction SilentlyContinue - $httpServer.process | Stop-Process -ErrorAction SilentlyContinue -Force - Remove-Item $httpServer.outFile -ErrorAction Continue + # Stop the HTTP server + Write-Host "Stopping the dummy API server ..." -NoNewline + try { + (Invoke-WebRequest -URI "$httpServerUri/STOP").StatusDescription + } + catch { + $httpServer.process | Stop-Process -Force -ErrorAction SilentlyContinue + } + Start-Sleep -Milliseconds 500 + $output = Get-Content $httpServer.outFile -Raw + Remove-Item $httpServer.outFile -ErrorAction Continue - Write-Host "Standard Output:" -ForegroundColor Yellow - $output + Write-Host "Standard Output:" -ForegroundColor Yellow + $output - if ($output.Contains($successMessage)) { - Write-Host "smoke-crash test: PASSED" -ForegroundColor Green - } - else { - Write-Error "smoke-crash test: FAILED" + if ($output.Contains($successMessage)) { + Write-Host "smoke-crash test $run/$runs : PASSED" -ForegroundColor Green + } + else { + Write-Error "smoke-crash test $run/$runs : FAILED" + } } } \ No newline at end of file