简体   繁体   English

使用 Docker 集成测试 Azure 服务总线

[英]Integration testing Azure Service Bus with Docker

What is an appropriate way to integration test systems that use ASB?什么是集成使用 ASB 的测试系统的合适方法? With something like Kafka and using docker-compose, I could spin up two services that will communicate asynchronously over Kafka.使用 Kafka 之类的东西并使用 docker-compose,我可以启动两个服务,这些服务将通过 Kafka 进行异步通信。 Is there a way to do something similar with ASB?有没有办法用 ASB 做类似的事情? If not, what is a common integration testing pattern?如果不是,常见的集成测试模式是什么?

The pricing model for Service Bus has 12.5 million operations per month included for free . Service Bus 的定价模型 每月免费提供1250 万次操作 Past that, it's less than a dollar per millions of messages sent.过去,每发送数百万条消息不到一美元。 With these kinds of services it should be simple for you to spin up and tear down instances with absolutely zero cost to you as part of integration tests.使用这些类型的服务,作为集成测试的一部分,您应该可以轻松地以绝对零成本启动和拆除实例。

NUnit, for example provides the [OneTimeSetup] and [OneTimeTearDown] methods which you could use as part of an integration test suite to provision and subsequently delete a Service Bus instance.例如,NUnit 提供了[OneTimeSetup][OneTimeTearDown]方法,您可以将它们用作集成测试套件的一部分来提供并随后删除服务总线实例。

Sadly, I don't think Azure Storage Emulator supports the service bus yet, but you could extract the functionality to an interface and either write a fake ASB and use that or have the interface use the queue in the Emulator.遗憾的是,我认为Azure 存储模拟器尚不支持服务总线,但您可以将功能提取到接口,然后编写一个虚假的 ASB 并使用它,或者让接口使用模拟器中的队列。 If you want to use the actual ASB and don't mind incurring costs, you could spin up a new one with a guid for a name or if create evanescent queues or topics/subscriptions with guids for their names as well, then tear it all down when you're done.如果您想使用实际的 ASB 并且不介意产生成本,您可以使用名称的 guid 启动一个新的,或者如果创建具有名称的 guid 的消失队列或主题/订阅,然后将其全部撕掉完成后放下。

Not ideal perhaps, but it gives you some options.也许并不理想,但它为您提供了一些选择。 Perhaps if you shared more detail about what you're using ASB for, we could offer better solutions.也许如果您分享更多关于您使用 ASB 的目的的详细信息,我们可以提供更好的解决方案。

There is a Azure Storage Emulator Docker Image in docker hub. docker hub 中有一个Azure Storage Emulator Docker Image When using it, remember that you must use Windows emulation:使用的时候记得一定要使用Windows仿真:

在此处输入图片说明

given image can be used in docker compose:给定的图像可以在 docker compose 中使用:

version: '3.7'

services:
    azure_sb:
        container_name: azure_sb
        image: microsoft/azure-storage-emulator
        tty: true
        restart: always
        ports:
            - "10000:10000"
            - "10001:10001"
            - "10002:10002"

For test or dev usages considec using lightway version of it which is Azurite link to doc对于测试或开发使用,考虑使用它的 lightway 版本,这是到 doc 的Azurite 链接

version: '3.7'

services:
    azurite:
        container_name: azurite
        image: mcr.microsoft.com/azure-storage/azurite
        tty: true
        restart: always
        ports:
            - "10000:10000"
            - "10001:10001"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 集成测试 Azure function 连接到服务总线队列的应用程序 - Integration testing Azure function app that connect to Service Bus queue 天蓝色服务总线和动态CRM集成 - azure service bus & dynamics crm integration 具有Service Bus主题集成的Azure Web作业 - Azure Web Jobs with Service Bus Topic Integration .NET中的Azure Service Bus队列集成方法 - Azure Service Bus Queues integration approaches in .NET 测试Azure死信服务总线队列 - Testing Azure dead letter service bus queues Azure 服务总线无法连接到 kubernetes docker - Azure service bus fails connecting to kubernetes docker 在C#和PHP之间集成Azure Service Bus消息 - Integration of Azure Service Bus messages between C# and PHP Azure和本地测试中的服务总线输出绑定引发错误 - Service Bus Output Bindings Throwing Error in both Azure and Local Testing 在 Azure Functions 上使用服务总线触发器进行本地测试时提供 UserProperties - Providing UserProperties when testing locally on Azure Functions with Service Bus Triggers 使用代理消息在门户中测试Azure功能服务总线触发器 - Testing an Azure Function Service Bus Trigger in the Portal with a Brokered Message
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM