For integration tests on a Azure Devops Pipeline we start the CosmosDbEmulator with the following task (just before dotnet test).
- task: PowerShell@2
displayName: "Starting Cosmos Emulator for Integration Tests"
inputs:
targetType: "inline"
workingDirectory: $(Pipeline.Workspace)
script: |
Write-Host "Starting CosmosDB Emulator"
Import-Module "$env:ProgramFiles\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"
$startEmulatorCmd = "Start-CosmosDbEmulator -NoFirewall -NoUI -Timeout 900"
Invoke-Expression -Command $startEmulatorCmd
Note: For this purpose we use the "windows-latest" image.
Sometimes the CosmosDbEmulator takes ~2 minutes to start up (which is OK), other times he timed out around ~4 minutes (that is why I now set the timeout to 15 minutes). But even with a timeout of 15 minutes, in rare cases it still times out(!)
I would like to improve performance of the CosmosDbEmulator.
- Is this there a better, more reliable approach to run integration tests with CosmosDbEmulator?
- Should I switch to a self hosted agent to boost performance?
- Is there another workaround to my current situation?