testinfra 基礎設施測試工具

testinfra 是基於python 開發的基礎設施測試工具,咱們能夠用來方便的測試基礎設施
是否符合咱們的要求(系統,軟件。。。)html

一個參考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 也是一個不錯的選擇python

參考資料

https://github.com/philpep/testinfra
https://github.com/aelsabbahy/goss
http://www.javashuo.com/article/p-wdnhfupq-mc.htmlnginx

相關文章
相關標籤/搜索