【问题标题】:How to debug your tests when using testinfra as verifier in Molecule在 Molecule 中使用 testinfra 作为验证器时如何调试测试
【发布时间】:2019-11-22 16:12:26
【问题描述】:

当使用分子工具测试 ansible 角色并使用 testinfra(pytest) 验证结果时,我无法打印或调试某些输出或 ansible 变量。

============================= test session starts ==============================
platform linux2 -- Python 2.7.5, pytest-4.6.6, py-1.8.0, pluggy-0.13.0 -- /root/test1/myenv/bin/python2
using: pytest-4.6.6 pylib-1.8.0
setuptools registered plugins:
  testinfra-3.2.1 at /root/test1/myenv/lib/python2.7/site-packages/testinfra/plugin.py
rootdir: /root/test1/server_manager/molecule/default
plugins: testinfra-3.2.1
collected 1 item

tests/test_default.py::test_Ansible_variable[ansible://instance] PASSED  [100%]

=========================== 1 passed in 3.29 seconds ===========================

有没有办法做到这一点?

【问题讨论】:

  • 您是否尝试将--debug 选项传递给分子命令。这应该将 -vvv 标志附加到 pytest 并增加测试的详细程度。
  • 我已经在使用它了,但没有任何显示

标签: ansible pytest molecule testinfra


【解决方案1】:

molecule.yml 文件中的 testinfra 验证器组件下,启用“s”选项。例如:

---
dependency:
  name: galaxy
driver:
  name: docker
lint:
  name: yamllint
platforms:
  - name: instance
    image: centos:7
provisioner:
  name: ansible
  lint:
    name: ansible-lint
verifier:
  name: testinfra
  lint:
    name: flake8
  options:
    s: true

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-31
    • 2019-12-10
    • 1970-01-01
    • 2012-06-29
    • 1970-01-01
    • 1970-01-01
    • 2015-11-06
    相关资源
    最近更新 更多