Skip to content

Commit

Permalink
Documents running subset of testinfra tests
Browse files Browse the repository at this point in the history
Since testinfra is based on pytest, the pytest env var for passing
additional options works just fine. We can use the `-k` option to
perform a substring search on test names, and run only those tests
matching the selector.
  • Loading branch information
Conor Schaefer committed Aug 29, 2019
1 parent ccb2b27 commit f6b0a69
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions docs/development/testing_configuration_tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ For the staging VMs:
The VMs will be set up using either the libvirt or virtualbox Vagrant VM provider,
depending on your system settings. You'll need to use the appropriate commands below
based on your choice of provider.
based on your choice of provider.

Then, to run the tests:

libvirt:
~~~~~~~~

.. code:: sh
molecule verify -s libvirt-staging
virtualbox:
Expand All @@ -50,12 +50,15 @@ virtualbox:
molecule verify -s virtualbox-staging
.. tip:: To run only a single test, set ``PYTEST_ADDOPTS="-k name_of_test"``
in your environment.

Test failure against any host will generate a report with informative output
about the specific test that triggered the error. Molecule
will also exit with a non-zero status code.

.. note:: To build and test the VMs with one command, use the Molecule ``test``
action: ``molecule test -s libvirt-staging --destroy=never``, or ``molecule test -s virtualbox-staging --destroy=never``.
action: ``molecule test -s libvirt-staging --destroy=never``, or ``molecule test -s virtualbox-staging --destroy=never``.

Updating the Config Tests
-------------------------
Expand All @@ -75,7 +78,7 @@ than the Ansible playbooks: ::

Any variable changes in the Ansible config should have a corresponding
entry in these vars files. These vars are dynamically loaded for each
host via the ``molecule/testinfra/staging/conftest.py`` file. Make sure to add
host via the ``molecule/testinfra/staging/conftest.py`` file. Make sure to add
your tests to the relevant location for the host you plan to test: ::

molecule/testinfra/staging/app/
Expand Down Expand Up @@ -105,7 +108,7 @@ Molecule configuration: ::
├── app
├── app-code
├── common
├── mon
├── mon
├── ossec
└── vars

Expand Down

0 comments on commit f6b0a69

Please sign in to comment.