【问题标题】:ansible - run tests for specific module/package (from source)ansible - 为特定模块/包运行测试(来自源代码)
【发布时间】:2019-10-01 14:10:00
【问题描述】:

所以我克隆了 ansible 存储库并使用 venv 进行了设置。而且我想运行特定的模块/包单元测试(如果我没有指定任何模式或指定特定文件,它确实会完全运行单元测试)。

我尝试了这些变体(前两个不起作用):

第一:

source venv/bin/activate && source hacking/env-setup && ansible-test units --tox --python 3.6 google

ERROR: Target pattern not matched: google

第二:

source venv/bin/activate && source hacking/env-setup && ansible-test units --tox --python 3.6 cloud

ERROR: Target pattern not matched: cloud

第三:

source venv/bin/activate && source hacking/env-setup && ansible-test units --tox --python 3.6 test/units/modules/cloud/google/test_gce_tag.py

...
- generated xml file: /home/oerp/src/ansible/test/results/junit/python3.6-units.xml -
============================== 3 passed in 1.68s ===============================
___________________________________ summary ____________________________________
  py36: commands succeeded
  congratulations :)

文档中有一个示例,展示了如何为特定文件运行测试: ansible-test units --tox --python 2.7 apt

也许我对那个示例的理解有误?或者我应该如何为 google 或整个组 cloud 运行包的单元测试?

更新。也试过test/units/modules/cloud/google,但得到同样的错误。

【问题讨论】:

    标签: python unit-testing ansible tox


    【解决方案1】:

    如果要测试 gce_tag 模块,只需将其指定为目标,因为在 test/units 下的适当位置有一个 test_gce_tag.py 文件。

    source venv/bin/activate
    source hacking/env-setup
    ansible-test units --tox --python 2.7 gce_tag
    

    如果你想测试所有的 cloud/google,你的第三个例子就是要走的路,它有一个完整的路径和一个通配符,你的 shell 将为你扩展:

    ansible-test units --tox --python 2.7 test/units/modules/cloud/google/test*.py
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-08
      • 1970-01-01
      相关资源
      最近更新 更多