Testinfra test your infrastructures
Перейти к файлу
Philippe Pepiot 339a597763 doc: Fix readthedocs build 2015-05-27 13:50:35 +02:00
doc doc: typo 2015-05-27 13:36:31 +02:00
images Tests: salt-minion and puppet in debian_jessie 2015-05-25 15:33:55 +02:00
testinfra Warn about ignored arguments 2015-05-27 12:24:25 +02:00
.gitignore Gitignore .coverage files generated by pytest-xdist 2015-05-19 12:38:56 +02:00
.travis.yml travis: py34 2015-03-15 22:17:57 +01:00
LICENSE First commit: version 1.0a1 2015-03-15 21:48:38 +01:00
Makefile Warn about ignored arguments 2015-05-27 12:24:25 +02:00
README.rst doc for connection backends 2015-05-27 13:13:19 +02:00
Vagrantfile Vagrant: systemd in docker 2015-05-18 17:50:06 +02:00
dev-requirements.txt doc: Fix readthedocs build 2015-05-27 13:50:35 +02:00
requirements.txt requirements: remove paramiko 2015-04-13 17:39:51 +02:00
setup.cfg Fix develop install 2015-05-13 23:42:34 +02:00
setup.py First commit: version 1.0a1 2015-03-15 21:48:38 +01:00
test-requirements.txt OpenBSD, FreeBSD and NetBSD support 2015-03-29 12:08:34 +02:00
tox.ini Fix tox build 2015-04-13 17:42:56 +02:00

README.rst

##################################
Testinfra test your infrastructure
##################################

.. image:: https://readthedocs.org/projects/testinfra/badge/?version=latest
   :target: https://readthedocs.org/projects/testinfra/?badge=latest
   :alt: Documentation Status


.. image:: https://travis-ci.org/philpep/testinfra.svg?branch=master
   :target: https://travis-ci.org/philpep/testinfra


Latest documentation: http://testinfra.readthedocs.org/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 powerfull Pytest_ test engine

.. warning:: Testinfra is currently *alpha* software, API may change before the
             first release, and OS support is limited.


Quick start
===========

Install testinfra using pip::

    $ pip install --pre testinfra

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


Write your first tests 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 == 644


    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 ====================


.. _Salt: http://saltstack.com/
.. _Ansible: http://www.ansible.com/
.. _Puppet: https://puppetlabs.com/
.. _Chef: https://www.chef.io/
.. _ServerSpec: http://serverspec.org/
.. _Pytest: http://pytest.org
.. _paramiko: http://www.paramiko.org/
.. _pytest-xdist: http://pytest.org/latest/xdist.html