Running CosmosDB Emulator in Azure Pipeline is very slow
Asked Answered
P

0

6

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?
Penny answered 3/3, 2023 at 16:19 Comment(3)
Did you stumble across any solution to this problem?Archaeozoic
@AbhaySibal I am afraid not. Increasing the timeout is a good workaround (Rather have a slow than a broke CI pipeline).Penny
We had the same issue and we ended up with another instance of Cosmos DB in Azure that has only a small subset of data used for integration tests. This Cosmos DB instance only costs us a few EUR/month so it was a very acceptable solution for usBorst

© 2022 - 2024 — McMap. All rights reserved.