Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ jobs:
buildConfiguration: 'Release'

steps:
- pwsh: . "tools/start-emulators.ps1" -NoWait -SkipCosmosDBEmulator
displayName: "Start emulators (-NoWait)"
- pwsh: . "tools/start-emulators.ps1"
displayName: "Start emulators"

- template: ../build/install-dotnet.yml

- task: DotNetCoreCLI@2
displayName: 'Build projects'
inputs:
Expand All @@ -65,8 +65,7 @@ jobs:
}
./setup-e2e-tests.ps1 -FunctionsRuntimeVersion $env:FUNCTIONSRUNTIMEVERSION `
-UseCoreToolsBuildFromIntegrationTests:$useIntegrationTestingCoreTools `
-SkipBuildOnPack `
-SkipCosmosDBEmulator
-SkipBuildOnPack
displayName: "Setup E2E tests"

- task: DotNetCoreCLI@2
Expand Down
2 changes: 1 addition & 1 deletion test/E2ETests/E2ETests/Cosmos/CosmosDBEndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public CosmosDBEndToEndTests(FunctionAppFixture fixture, ITestOutputHelper testO
_disposeLog = _fixture.TestLogs.UseTestLogger(testOutput);
}

[Fact(Skip = "Need to debug why Cosmos emulator does not always start.")]
[Fact]
public async Task CosmosDBTriggerAndOutput_Succeeds()
{
string expectedDocId = Guid.NewGuid().ToString();
Expand Down
49 changes: 40 additions & 9 deletions tools/start-emulators.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Write-Host "Skip Storage Emulator: $SkipStorageEmulator"

if (!$SkipCosmosDBEmulator)
{
Add-MpPreference -ExclusionPath "$env:ProgramFiles\Azure Cosmos DB Emulator"
Import-Module "$env:ProgramFiles\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"
}

Expand Down Expand Up @@ -58,17 +59,17 @@ if (!$SkipCosmosDBEmulator)
Write-Host "CosmosDB emulator status: $cosmosStatus"

if ($cosmosStatus -eq "StartPending")
{
{
$startedCosmos = $true
}
elseif ($cosmosStatus -ne "Running")
{
Write-Host "CosmosDB emulator is not running. Starting emulator."
Start-CosmosDbEmulator -NoWait -NoUI
Start-Process "$env:ProgramFiles\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" "/NoExplorer /NoUI /DisableRateLimiting /PartitionCount=50 /Consistency=Strong /EnablePreview /EnableSqlComputeEndpoint" -Verb RunAs
$startedCosmos = $true
}
else
{
{
Write-Host "CosmosDB emulator is already running."
}
}
Expand All @@ -79,7 +80,7 @@ if (!$SkipStorageEmulator)
Write-Host ""
Write-Host "---Starting Storage emulator---"
$storageEmulatorRunning = IsStorageEmulatorRunning

if ($storageEmulatorRunning -eq $false)
{
if ($IsWindows)
Expand All @@ -102,7 +103,7 @@ if (!$SkipStorageEmulator)
}

Write-Host "------"
Write-Host
Write-Host
}

if ($NoWait -eq $true)
Expand All @@ -123,9 +124,39 @@ if (!$SkipCosmosDBEmulator -and $startedCosmos -eq $true)
if ($waitSuccess -ne $true)
{
Write-Host "CosmosDB emulator not yet running after waiting 60 seconds. Restarting."
Stop-CosmosDbEmulator
Write-Host "Restarting CosmosDB emulator"
Start-CosmosDbEmulator -NoUI
Write-Host "Shutting down and restarting"
Start-Process "$env:ProgramFiles\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" "/Shutdown" -Verb RunAs
sleep 30;

for ($j=0; $j -lt 3; $j++) {
Write-Host "Attempt $j"
Start-Process "$env:ProgramFiles\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" "/NoExplorer /NoUI /DisableRateLimiting /PartitionCount=50 /Consistency=Strong /EnablePreview /EnableSqlComputeEndpoint" -Verb RunAs

for ($i=0; $i -lt 5; $i++) {
$status = Get-CosmosDbEmulatorStatus
Write-Host "Cosmos DB Emulator Status: $status"

if ($status -ne "Running") {
sleep 30;
}
else {
break;
}
}

if ($status -ne "Running") {
Write-Host "Shutting down and restarting"
Start-Process "$env:ProgramFiles\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" "/Shutdown" -Verb RunAs
sleep 30;
}
else {
break;
}
}

if ($status -ne "Running") {
Write-Error "Emulator failed to start"
}
}

Write-Host "------"
Expand All @@ -137,7 +168,7 @@ if (!$SkipStorageEmulator -and $startedStorage -eq $true)
Write-Host "---Waiting for Storage emulator to be running---"
$storageEmulatorRunning = IsStorageEmulatorRunning
while ($storageEmulatorRunning -eq $false)
{
{
Write-Host "Storage emulator not ready."
Start-Sleep -Seconds 5
$storageEmulatorRunning = IsStorageEmulatorRunning
Expand Down