Skip to content

Commit

Permalink
ci: further crash test deflaking
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Feb 28, 2022
1 parent a6f055b commit 2bec123
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 20 deletions.
6 changes: 5 additions & 1 deletion test/Scripts.Integration.Test/crash-test-server.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
51 changes: 32 additions & 19 deletions test/Scripts.Integration.Test/integration-run-smoke-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}

0 comments on commit 2bec123

Please sign in to comment.