Coder Social home page Coder Social logo

mkhoin / testinfra Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unity-technologies/testinfra

0.0 0.0 0.0 442 KB

Testinfra test your infrastructures

Home Page: https://testinfra.readthedocs.io

License: Apache License 2.0

Makefile 0.04% Dockerfile 5.59% Python 94.38%

testinfra's Introduction

Testinfra test your infrastructure

Latest documentation: https://testinfra.readthedocs.io/en/latest

About

With Testinfra you can write unit tests in Python to test actual state of your servers configured by managements tools like Salt, Ansible, Puppet, Chef and so on.

Testinfra aims to be a Serverspec equivalent in python and is written as a plugin to the powerful Pytest test engine

Quick start

Install testinfra using pip:

$ pip install testinfra

# or install the devel version
$ pip install 'git+https://github.com/philpep/testinfra@master#egg=testinfra'

Write your first tests file to test_myinfra.py:

def test_passwd_file(File):
    passwd = File("/etc/passwd")
    assert passwd.contains("root")
    assert passwd.user == "root"
    assert passwd.group == "root"
    assert passwd.mode == 0o644


def test_nginx_is_installed(Package):
    nginx = Package("nginx")
    assert nginx.is_installed
    assert nginx.version.startswith("1.2")


def test_nginx_running_and_enabled(Service):
    nginx = Service("nginx")
    assert nginx.is_running
    assert nginx.is_enabled

And run it:

$ testinfra -v test_myinfra.py


====================== test session starts ======================
platform linux -- Python 2.7.3 -- py-1.4.26 -- pytest-2.6.4
plugins: testinfra
collected 3 items

test_myinfra.py::test_passwd_file[local] PASSED
test_myinfra.py::test_nginx_is_installed[local] PASSED
test_myinfra.py::test_nginx_running_and_enabled[local] PASSED

=================== 3 passed in 0.66 seconds ====================

testinfra's People

Contributors

philpep avatar opdude avatar jesselang avatar benoitknecht avatar retr0h avatar mr-ice avatar cheesesashimi avatar georgealton avatar mhdali avatar rosstimson avatar queeno avatar manics avatar realloc avatar brettlangdon avatar goodwillcoding avatar karmab avatar rfgtid avatar swordsp avatar elementalvoid avatar jcftang-r7 avatar jcftang avatar jaakkosipari avatar d-higuchi avatar giovtorres avatar gbirke avatar mchugh19 avatar ashb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.