diff --git a/test/SmokeTests/OOProcSmokeTests/DotNetIsolated/run-smoke-tests.ps1 b/test/SmokeTests/OOProcSmokeTests/DotNetIsolated/run-smoke-tests.ps1 new file mode 100644 index 000000000..b21553176 --- /dev/null +++ b/test/SmokeTests/OOProcSmokeTests/DotNetIsolated/run-smoke-tests.ps1 @@ -0,0 +1,57 @@ +# This is a simple smoke test runner to validate the .NET isolated smoke tests. +# It supercedes the usual e2e-tests.ps1 script for the .NET isolated scenario because building the tests on the docker image +# is unreliable. For more details, see: https://github.com/Azure/azure-functions-host/issues/7995 +param( + [Parameter(Mandatory=$true)] + [string]$HttpStartPath +) + +try { + # Make sure the Functions runtime is up and running + $pingUrl = "http://localhost:8080/admin/host/ping" + Write-Host "Pinging app at $pingUrl to ensure the host is healthy" -ForegroundColor Yellow + Invoke-RestMethod -Method Post -Uri "http://localhost:8080/admin/host/ping" + Write-Host "Host is healthy!" -ForegroundColor Green + Exit-OnError + + if ($NoValidation -eq $false) { + # Note that any HTTP protocol errors (e.g. HTTP 4xx or 5xx) will cause an immediate failure + $startOrchestrationUri = "http://localhost:8080/$HttpStartPath" + Write-Host "Starting a new orchestration instance via POST to $startOrchestrationUri..." -ForegroundColor Yellow + + $result = Invoke-RestMethod -Method Post -Uri $startOrchestrationUri + Write-Host "Started orchestration with instance ID '$($result.id)'!" -ForegroundColor Yellow + Write-Host "Waiting for orchestration to complete..." -ForegroundColor Yellow + + $retryCount = 0 + $success = $false + $statusUrl = $result.statusQueryGetUri + + while ($retryCount -lt 15) { + $result = Invoke-RestMethod -Method Get -Uri $statusUrl + $runtimeStatus = $result.runtimeStatus + Write-Host "Orchestration is $runtimeStatus" -ForegroundColor Yellow + + if ($result.runtimeStatus -eq "Completed") { + $success = $true + Write-Host $result + break + } + + Start-Sleep -Seconds 1 + $retryCount = $retryCount + 1 + } + } + + if ($success -eq $false) { + throw "Orchestration didn't complete in time! :(" + } +} catch { + Write-Host "An error occurred:" -ForegroundColor Red + Write-Host $_ -ForegroundColor Red + + # Rethrow the original exception + throw +} + +Write-Host "Success!" -ForegroundColor Green \ No newline at end of file