微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

testinfra 基础设施测试工具

testinfra 是基于python 开发的基础设施测试工具,我们可以用来方便的测试基础设施
是否符合我们的要求(系统,软件。。。)

一个参考demo

 
def test_passwd_file(host):
    passwd = host.file("/etc/passwd")
    assert passwd.contains("root")
    assert passwd.user == "root"
    assert passwd.group == "root"
    assert passwd.mode == 0o644
 
def test_Nginx_is_installed(host):
    Nginx = host.package("Nginx")
    assert Nginx.is_installed
    assert Nginx.version.startswith("1.2")
def test_Nginx_running_and_enabled(host):
    Nginx = host.service("Nginx")
    assert Nginx.is_running
    assert Nginx.is_enabled

说明

golang 版本的goss 也是一个不错的选择

参考资料

https://github.com/philpep/testinfra
https://github.com/aelsabbahy/goss
https://www.cnblogs.com/rongfengliang/p/9693345.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐