简体   繁体   English

集成测试 Azure function 连接到服务总线队列的应用程序

[英]Integration testing Azure function app that connect to Service Bus queue

I have developed a function app that is triggered by a Http request, and peeks a respective queue (connects to it by a connection string) on the Service Bus for messages with a specific parameter value, and delete them.我开发了一个由 Http 请求触发的 function 应用程序,并在服务总线上查看具有特定参数值的消息的相应队列(通过连接字符串连接到它),然后删除它们。

In addition to regular testing when developing, it would be great to create integration tests and run them in a CI/CD process, but I don't know how to mock the queue that the function app connects too (creating a test queue that resides on the Service bus only to be used for test-purposes is not an option).除了开发时的常规测试,创建集成测试并在 CI/CD 过程中运行它们会很棒,但我不知道如何模拟 function 应用程序连接的队列(创建驻留的测试队列在服务总线上仅用于测试目的不是一个选项)。 Does anyone have any idea how to proceed?有谁知道如何进行?

One of the options would be to provision a temporary Azure Service Bus namespace in the beginning prior to executing an integration test suite and tearing it down at the end.其中一个选项是在执行集成测试套件并在最后将其拆除之前,在开始时提供一个临时的 Azure 服务总线命名空间。 The namespace would be a standard tier namespace.命名空间将是标准层命名空间。 Provisioning and tearing down could be done with either ARM template, PowerShell, or Azure CLI.可以使用 ARM 模板、PowerShell 或 Azure CLI 来完成配置和拆除。

An additional benefit of this approach is security.这种方法的另一个好处是安全性。 A namespace per test suite run will ensure that PR from external contributors can be safely executed, in case your repository is public.每个测试套件运行的命名空间将确保可以安全地执行来自外部贡献者的 PR,以防您的存储库是公共的。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM