单元/集成测试 Asterisk 配置 [英] Unit/integration testing Asterisk configuration

查看:35
本文介绍了单元/集成测试 Asterisk 配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当然,单元和集成测试通常作为开发过程的一部分进行.我正在寻找在现有系统的配置中使用这种方法的方法,在这种情况下是 星号软PBX.

Unit and integration testing is usually performed as part of a development process, of course. I'm looking for ways to use this methodology in configuration of an existing system, in this case the Asterisk soft PBX.

在 Asterisk 的情况下,配置文件和其他任何东西一样都是一种编程语言,包括循环、跳转、条件等,并且可以变得相当复杂.配置更改通常会遇到与复杂软件产品更改相同的问题——如果没有适当的测试,很难预见所有的影响.更糟糕的是,系统的本质是与外部实体进行通信,即拨打电话.

In the case of Asterisk, the configuration file is as much a programming language as anything else, complete with loops, jumps, conditionals, etc., and can get quite complex. Changes to the configuration often suffers from the same problems as changes to a complex software product - it can be hard to foresee all the effects without tests in place. It's made worse by the fact that the nature of the system is to communicate with external entities, i.e. make phone calls.

我有一些关于使用调用文件(在扩展之间创建特定调用)测试系统的想法,同时观察生成事件的管理器界面.然后测试可以观察预期的结果,即拨打 *99# 应该导致语音邮件应用程序被调用.

I have a few ideas about testing the system using call files (to create specific calls between extensions) while watching the manager interface for generated events. A test could then watch for an expected result, i.e. dialling *99# should result in the Voicemail application getting called.

缺陷很明显 - 它不测试实际结果,只测试系统认为的结果,并且可能需要对被测系统进行一些修改.也很难编写足够健壮的测试以仅触发预期的输出,尤其是在系统正在使用中(即正在进行其他调用).

The flaws are obvious - it doesn't test the actual result, only what the system thinks is the result, and it probably requires some modification of the system under test. It's also really hard to write these tests robustly enough to only trigger on the expected output, especially if the system is in use (i.e. there are other calls in progress).

我想要的 Asterisk 测试系统是不可能的吗?如果没有,您对如何以合理的方式解决这个问题有什么想法吗?我愿意为此投入大量的开发时间,并在友好的许可下发布结果,但我不确定实现它的最佳方式.

Is what I want, a testing system for Asterisk, impossible? If not, do you have any ideas about ways to go about this in a reasonable manner? I'm willing to put a fair amount of development time into this and release the result under a friendly license, but I'm unsure about the best way to approach it.

推荐答案

这显然是一个老问题,所以很有可能当原始答案发布在这里时,Asterisk 不支持单元/集成测试,以至于今天确实如此(尽管单元测试框架 API 于 2009 年 12 月 22 日推出,因此至少确实存在).

This is obviously an old question, so there's a good chance that when the original answers were posted here that Asterisk did not support unit / integration testing to the extent that it does today (although the Unit Test Framework API went in on 12/22/09, so that, at least, did exist).

单元测试框架(David 来自开发列表的电子邮件 here) 让你直接在 Asterisk 中执行单元测试.测试在框架中注册,可以通过 CLI 执行/查看.由于这都是 Asterisk 的一部分,测试被编译成可执行文件.您必须使用 --enable-dev-mode 选项配置 Asterisk,并使用 menuselect 工具标记要编译的测试(某些应用程序,如 app_voicemail,会自动注册测试 - 但它们是少数).

The unit testing framework (David's e-mail from the dev list here) lets you execute unit tests directly within Asterisk. Tests are registered with the framework and can be executed / viewed through the CLI. Since this is all part of Asterisk, the tests are compiled into the executable. You do have to configure Asterisk with the --enable-dev-mode option, and mark the tests for compilation using the menuselect tool (some applications, like app_voicemail, automatically register tests - but they're the minority).

编写单元测试相当简单 - 虽然它(显然)不像商业单元测试框架那样功能齐全,但它可以完成工作并且可以根据需要进行增强.

Writing unit tests is fairly straight-forward - and while it (obviously) isn't as fully featured as a commercial unit test framework, it gets the job done and can be enhanced as needed.

这很可能不是大多数 Asterisk 用户想要使用的 - 尽管强烈建议 Asterisk 开发人员检查一下.用户和开发人员可能都对集成测试感兴趣,Asterisk Test Suite提供.从本质上讲,测试套件是一个执行其他脚本的 Python 脚本——无论是 lua、python 等.测试套件带有一组 python 和 lua 库,有助于编排和执行多个 Asterisk 实例.测试编写者可以使用第三方应用程序,例如 SIPp 或 Asterisk 接口(AMI、AGI)或其组合来测试托管的 Asterisk 实例.

That most likely isn't what the majority of Asterisk users are going to want to use - although Asterisk developers are highly encouraged to check it out. Both users and developers are probably interested in integration tests, which the Asterisk Test Suite provides. At its core, the Test Suite is a python script that executes other scripts - be they lua, python, etc. The Test Suite comes with a set of python and lua libraries that help to orchestrate and execute multiple Asterisk instances. Test writers can use third party applications such as SIPp or Asterisk interfaces (AMI, AGI) or a combination thereof to test the hosted Asterisk instance(s).

测试套件中现在有近 200 个测试,并且会定期添加更多测试.显然,您可以编写自己的测试来使用您的 Asterisk 配置并让它们由测试套件管理 - 如果它们足够通用,您也可以提交它们以包含在测试套件中.

There are close to 200 tests now in the Test Suite, with more being added on a fairly regular basis. You could obviously write your own tests that exercise your Asterisk configuration and have them managed by the Test Suite - if they're generic enough, you could submit them for inclusion in the Test Suite as well.

请注意,设置测试套件可能有点棘手 - Leif 写了一篇关于设置测试套件的好博文 此处.

Note that the Test Suite can be a bit tricky to set up - Leif wrote a good blog post on setting up the Test Suite here.

这篇关于单元/集成测试 Asterisk 配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆