【问题标题】:How to run cosmos emulator in Azure devops with Ubuntu?如何使用 Ubuntu 在 Azure devops 中运行 cosmos 模拟器?
【发布时间】:2021-09-15 20:43:46
【问题描述】:

如何使用 Spring Boot 集成测试 (java) 在 Azure devops 中运行 Azure cosmos DB Emulator?

目前cosmos DB模拟器只支持windows服务器不支持linux?

有什么建议可以在这里进行吗?

更新:1 对于 windows 构建代理,可以使用来自 azure 管道的以下任务。

- task: CosmosDbEmulator@2       
    inputs:        
        containerName: 'azure-cosmosdb-emulator'   
        enableAPI: 'SQL'    
        portMapping: '8081:8081, 8901:8901, 8902:8902, 8979:8979, 10250:10250, 10251:10251, 10252:10252, 10253:10253, 10254:10254, 10255:10255, 10256:10256, 10350:10350'       
        hostDirectory: '$(Build.BinariesDirectory)\azure-cosmosdb-emulator'
    

对于 Linux: 我使用的和@Ricardo 一样

【问题讨论】:

  • 你试过Docker docker pull microsoft/azure-cosmosdb-emulator吗?
  • @4EACH CosmosDB 模拟器仅支持 Windows。 Windows 容器与 Linux 容器不同。
  • 好的,据我了解,Azure Devops 没有为 linux 构建代理预定义任务,我们需要为基于 linux 的代理创建自己的任务?
  • @4EACH 我正在尝试使用官方文档中提到的docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
  • @sen 如何你运行它?共享您的管道 YAML。

标签: java spring-boot azure-devops azure-pipelines azure-cosmosdb


【解决方案1】:

CosmosDB emulator for linux 有尝试:here

它们提供了在 linux 机器上运行它的命令,我们只是将它们放在一个 bash 步骤中,以便能够在我们的 yaml 管道中运行它:

*睡眠是为了让模拟器有时间在容器内启动

- bash: |
        ipaddr="`ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}' | head -n 1`"
        ifconfig | grep "inet " | grep -Fv 127.0.0.1
        docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
        docker run -p 8081:8081 -p 10251:10251 -p 10252:10252 -p 10253:10253 -p 10254:10254 -m 4g --cpus=2.0 --name=test-linux-emulator  -e AZURE_COSMOS_EMULATOR_PARTITION_COUNT=10 -e AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=false -e AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=$ipaddr -d -it mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
        sleep 30
        curl -k https://localhost:8081/_explorer/emulator.pem > /tmp/emulatorcert.crt
        keytool -cacerts -storepass changeit -noprompt -importcert -alias emulator_cert -file /tmp/emulatorcert.crt
      displayName: Install CosmosDB Emulator Docker

【讨论】:

  • 是的,最后,我们也遵循相同的步骤。您使用的是 Azure 管道还是自托管代理?因为我们间歇性地收到读取超时和服务不可用错误.. @Ricardo
  • 我们正在使用 Azure 管道,目前面临相同的随机读取超时。我们看到 docker 镜像在某个时候达到了 100% 的 CPU 使用率,然后无法处理新的请求。即使我们总共只是阅读/更新 3-4 个文档......我们已经能够在本地复制它并在日志中看到这些:error code: ReceiveTimeout [0x0010], base error: HRESULT ... 0x80131500,10.202.176.95:10253, payload sent: True, CPU history: (2021-09-16T06:38:37.8611156Z 100.000), (2021-09-16T06:38:37.8611156Z 100.000) ... , (2021-09-16T06:39:07.8653702Z 100.000), CPU count: 12)
  • 如果你能解决这个问题,你能分享一下吗?由于间歇性的 ReadTimeouts 和服务不可用错误,我们对此持怀疑态度。
猜你喜欢
  • 2023-01-14
  • 2019-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多