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