aodh/doc/source/contributor/testing.rst
lipan fb686eb95b fix the loaction of api/v2 file.
According to structure of tests file, we know api/v2 be in functional
directory, test_bin be in unit directory.

Change-Id: If1e7bfb756516b6c0f79732cabd576750cce9a44
2018-06-05 15:51:04 +08:00

2.5 KiB
Raw Blame History

Running the Tests

Aodh includes an extensive set of automated unit tests which are run through tox.

  1. Install tox:

    $ sudo pip install tox
  2. On Ubuntu install libmysqlclient-dev packages:

    $ sudo apt-get install libmysqlclient-dev

    For Fedora20 there is no libmysqlclient-dev package, so youll need to install mariadb-devel.x86-64 (or mariadb-devel.i386) instead:

    $ sudo yum install mariadb-devel.x86_64
  3. Run the unit and code-style tests:

    $ cd /opt/stack/aodh
    $ tox -e py27,pep8

    As tox is a wrapper around testr, it also accepts the same flags as testr. See the testr documentation for details about these additional flags.

    Use a double hyphen to pass options to testr. For example, to run only tests under tests/functional/api/v2:

    $ tox -e py27 -- functional.api.v2

    To debug tests (ie. break into pdb debugger), you can use ''debug'' tox environment. Here's an example, passing the name of a test since you'll normally only want to run the test that hits your breakpoint:

    $ tox -e debug aodh.tests.unit.test_bin

    For reference, the debug tox environment implements the instructions here: https://wiki.openstack.org/wiki/Testr#Debugging_.28pdb.29_Tests

  4. There is a growing suite of tests which use a tool called gabbi to test and validate the behavior of the Aodh API. These tests are run when using the usual functional tox target but if desired they can be run by themselves:

    $ tox -e gabbi

    The YAML files used to drive the gabbi tests can be found in aodh/tests/functional/gabbi/gabbits. If you are adding to or adjusting the API you should consider adding tests here.