通用单元测试调度

发布于 2024-09-02 20:15:50 字数 795 浏览 1 评论 0 原文

我正在(重新)编写一个执行通用单元测试调度的程序。当前的程序是单线程 Perl 程序,但我愿意将其模块化并并行化测试。我也在考虑用Python重写它。

这是我需要做的:

  • 我有一个测试列表,具有以下属性:
    • uri:要测试的 URI(可以是 HTTP/HTTPS/SSH/local);
    • depends:此测试所依赖的测试/值的关联数组;
    • join:选择此测试中要处理的项目时要添加的数据库连接列表;
    • depends_db:选择在此测试中处理的项目时添加到数据库请求的附加条件。
  • 该程序构建一个依赖树,从没有依赖项的测试开始;
  • 对于每个测试:
    • 使用条件(依赖测试、关节和depends_db的结果)从数据库中选择项目列表;
    • 项目列表被发送到 URI(使用 POST 或 stdin);
    • 结果以 YAML 文件形式检索,列出每个测试项目的测试状态和注释;
    • 结果存储在数据库中;
    • 测试返回,允许执行相关测试。
  • 该程序生成所执行测试的报告(CSV、DB、graphviz)。

目前该程序的主要用途是针对备份、DNS 等服务测试一组机器。测试可以是: - 备份:托管在备份机器上,通过HTTP调用,检查机器的备份是否顺利; - DNS:托管在本地计算机上,通过 stdin 调用,检查计算机的 FQDN 是否具有有效的 DNS 条目。

这样的工具/模块已经存在吗?实现这一目标的最佳实现是什么(使用 Perl 或 Python)?

I'm (re)writing a program that does generic unit test scheduling. The current program is a mono-threaded Perl program, but I'm willing to modularize it and parallelize the tests. I'm also considering rewriting it in Python.

Here is what I need to do:

  • I have a list of tests, with the following attributes:
    • uri: a URI to test (could be HTTP/HTTPS/SSH/local) ;
    • depends: an associative array of tests/values that this test depends on ;
    • join: a list of DB joints to be added when selecting items to process in this test ;
    • depends_db: additional conditions to add to the DB request when selecting items to process in this test.
  • The program builds a dependency tree, beginning with the tests that have no dependencies ;
  • for each test:
    • a list of items is selected from the database using the conditions (results of depending tests, joints and depends_db) ;
    • the list of items is sent to the URI (using POST or stdin) ;
    • the result is retrived as a YAML file listing the state and comments for the test for each tested item ;
    • the results are stored in the DB ;
    • the test returns, allowing depending tests to be performed.
  • the program generates reports (CSV, DB, graphviz) of the performed tests.

The primary use of this program currently is to test a fleet of machines against services such as backup, DNS, etc. The tests can then be:
- backup: hosted on the backup machine(s), called through HTTP, checks if the machines' backup went well ;
- DNS: hosted on the local machine, called via stdin, checks if the machines' fqdn have a valid DNS entry.

Does such a tool/module already exist? What would be the best implementation to achieve this (using Perl or Python)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜味拾荒者 2024-09-09 20:15:50

这种测试不是单元测试

如果您决定不遵循 rjh 的建议以保留您已编写的大部分代码,那么请将您的测试转换为使用标准测试工具链。

This sort of testing is not unit testing.

If you decide not to follow rjh's advice in order to keep most of the code you've already written, then convert your tests to use the standard test toolchain.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文