diff --git a/test/SmokeTests/OOProcSmokeTests/DotNetIsolated/FaultyOrchestrators.cs b/test/SmokeTests/OOProcSmokeTests/DotNetIsolated/FaultyOrchestrators.cs index 66b2bdf31..dd7327f94 100644 --- a/test/SmokeTests/OOProcSmokeTests/DotNetIsolated/FaultyOrchestrators.cs +++ b/test/SmokeTests/OOProcSmokeTests/DotNetIsolated/FaultyOrchestrators.cs @@ -110,7 +110,7 @@ public static async Task HttpStartOOMOrchestrator( // Function input comes from the request content. string instanceId = await client.ScheduleNewOrchestrationInstanceAsync( - nameof(OOMOrchestrator), instanceId: "OOMOrchestrator"); + nameof(OOMOrchestrator)); logger.LogInformation("Started orchestration with ID = '{instanceId}'.", instanceId); @@ -129,7 +129,7 @@ public static async Task HttpStartProcessExitOrchestrator( // Function input comes from the request content. string instanceId = await client.ScheduleNewOrchestrationInstanceAsync( - nameof(ProcessExitOrchestrator), instanceId: "ProcessExitOrchestrator"); + nameof(ProcessExitOrchestrator)); logger.LogInformation("Started orchestration with ID = '{instanceId}'.", instanceId); @@ -148,7 +148,7 @@ public static async Task HttpStartTimeoutOrchestrator( // Function input comes from the request content. string instanceId = await client.ScheduleNewOrchestrationInstanceAsync( - nameof(TimeoutOrchestrator), instanceId: "TimeoutOrchestrator"); + nameof(TimeoutOrchestrator)); logger.LogInformation("Started orchestration with ID = '{instanceId}'.", instanceId); diff --git a/test/SmokeTests/OOProcSmokeTests/DotNetIsolated/run-smoke-tests.ps1 b/test/SmokeTests/OOProcSmokeTests/DotNetIsolated/run-smoke-tests.ps1 index ffba1db24..aa2dd123b 100644 --- a/test/SmokeTests/OOProcSmokeTests/DotNetIsolated/run-smoke-tests.ps1 +++ b/test/SmokeTests/OOProcSmokeTests/DotNetIsolated/run-smoke-tests.ps1 @@ -6,55 +6,76 @@ param( [string]$HttpStartPath ) -# This delay a bit excessive, but we want to make sure the Functions runtime is up and running before we start the orchestration -# This number was determined, through trial and error, to be a safe amount of time to wait -Start-Sleep -Seconds 40 - -try { - # Make sure the Functions runtime is up and running - $pingUrl = "http://localhost:7071/admin/host/ping" - Write-Host "Pinging app at $pingUrl to ensure the host is healthy" -ForegroundColor Yellow - Invoke-RestMethod -Method Post -Uri "http://localhost:7071/admin/host/ping" - Write-Host "Host is healthy!" -ForegroundColor Green - - # Note that any HTTP protocol errors (e.g. HTTP 4xx or 5xx) will cause an immediate failure - $startOrchestrationUri = "http://localhost:7071/$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 65) { - $result = Invoke-RestMethod -Method Get -Uri $statusUrl - $runtimeStatus = $result.runtimeStatus - Write-Host "Orchestration is $runtimeStatus" -ForegroundColor Yellow - Write-Host $result - - if ($result.runtimeStatus -eq "Completed") { - $success = $true +Do { + $testIsRunning = $true; + + # Start the functions host if it's not running already. + # Then give it 40 seconds to start up. This is a long wait, but from experience the CI can be slow to start up the host. + $isFunctionsHostRunning = (Get-Process -Name func -ErrorAction SilentlyContinue) + if ($isFunctionsHostRunning -eq $null) { + Write-Host "Starting the Functions host..." -ForegroundColor Yellow + + # The '&' operator is used to run the command in the background + cd ./test/SmokeTests/OOProcSmokeTests/DotNetIsolated && func host start --port 7071 & + + Write-Host "Waiting for the Functions host to start up..." -ForegroundColor Yellow + Start-Sleep -Seconds 40 + } + + + try { + # Make sure the Functions runtime is up and running + $pingUrl = "http://localhost:7071/admin/host/ping" + Write-Host "Pinging app at $pingUrl to ensure the host is healthy" -ForegroundColor Yellow + Invoke-RestMethod -Method Post -Uri "http://localhost:7071/admin/host/ping" + Write-Host "Host is healthy!" -ForegroundColor Green + + # Note that any HTTP protocol errors (e.g. HTTP 4xx or 5xx) will cause an immediate failure + $startOrchestrationUri = "http://localhost:7071/$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 65) { + $result = Invoke-RestMethod -Method Get -Uri $statusUrl + $runtimeStatus = $result.runtimeStatus + Write-Host "Orchestration is $runtimeStatus" -ForegroundColor Yellow Write-Host $result - break + + if ($result.runtimeStatus -eq "Completed") { + $success = $true + $testIsRunning = $false + break + } + + cd ./test/SmokeTests/OOProcSmokeTests/DotNetIsolated && func host start --port 7071 & + Start-Sleep -Seconds 30 + $retryCount = $retryCount + 1 } - cd ./test/SmokeTests/OOProcSmokeTests/DotNetIsolated && func host start --port 7071 & - Start-Sleep -Seconds 30 - $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 } - if ($success -eq $false) { - throw "Orchestration didn't complete in time! :(" - } -} catch { - Write-Host "An error occurred:" -ForegroundColor Red - Write-Host $_ -ForegroundColor Red + + # This delay a bit excessive, but we want to make sure the Functions runtime is up and running before we start the orchestration + # This number was determined, through trial and error, to be a safe amount of time to wait + Start-Sleep -Seconds 40 +} while ($testIsRunning -eq $true) + - # Rethrow the original exception - throw -} Write-Host "Success!" -ForegroundColor Green \ No newline at end of file