
A 'gabbi' tox target is added which runs a declarative HTTP tests described in YAML files in 'ceilometer/tests/gabbi/gabbits' and loaded by 'ceilometer/tests/gabbi/test_gabbi.py'. These are driven by the 'gabbi' python package (available from PyPI). tox and testr are configured to start and run the tests efficiently: * a mongodb server, using multiple databases, is made available * the API wsgi application is used directly via 'wsgi-intercept', no web server required * each YAML file is run as a sequence and where number of processors allows, in a different test process * individual tests can be requested in the usual way: tox -egabbi -- <test pattern> If this is done, all the tests prior to the one requested, from its YAML file, will be run as ordered prerequisites. * tox targets that already run the tests in ceilometer/tests will also discover gabbi tests. If there is no mongodb, they will be skipped. A ConfigFixture does the necessary work of adjusting the configuration and pipeline to use the mongodb database and nothing else. An internal InterceptFixture uses wsgi-intercept to access the ceilometer API. Each yaml file has its own intercepted host. Fixtures are implemented as nested context managers that are declared per YAML file, see ceilometer/gabbi/fixtures.py and fixtures-samples.yaml for an example of how they can be used. Every yaml file uses at least ConfigFixture. YAML files can use a variety of strategies for formatting requests and evaluating the correctness of response. See: http://gabbi.readthedocs.org/en/latest/format.html The YAML files included here test simple API features for creating and retrieving samples. Subsequent patches can (and should) create additional YAML files to describe more complex scenarios that cover the entire API (for example alarms are not touched at all by this patch). Change-Id: I52551f88bc3beac4bf8a92afa45ac70cd97ffcec Implements: blueprint declarative-http-tests
123 lines
3.8 KiB
ReStructuredText
123 lines
3.8 KiB
ReStructuredText
..
|
||
Copyright 2012 New Dream Network, LLC (DreamHost)
|
||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||
not use this file except in compliance with the License. You may obtain
|
||
a copy of the License at
|
||
|
||
http://www.apache.org/licenses/LICENSE-2.0
|
||
|
||
Unless required by applicable law or agreed to in writing, software
|
||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||
License for the specific language governing permissions and limitations
|
||
under the License.
|
||
|
||
=========================
|
||
Working with the Source
|
||
=========================
|
||
|
||
Setting up a Development Sandbox
|
||
================================
|
||
|
||
1. Set up a server or virtual machine to run OpenStack using
|
||
devstack_.
|
||
|
||
.. _devstack: http://www.devstack.org/
|
||
|
||
2. Clone the ceilometer project to the machine::
|
||
|
||
$ cd /opt/stack
|
||
$ git clone https://git.openstack.org/openstack/ceilometer
|
||
$ cd ./ceilometer
|
||
|
||
3. Once this is done, you need to setup the review process::
|
||
|
||
$ git remote add gerrit ssh://<username>@review.openstack.org:29418/openstack/ceilometer.git
|
||
|
||
4. If you are preparing a patch, create a topic branch and switch to
|
||
it before making any changes::
|
||
|
||
$ git checkout -b TOPIC-BRANCH
|
||
|
||
Running the Tests
|
||
=================
|
||
|
||
Ceilometer includes an extensive set of automated unit tests which are
|
||
run through tox_.
|
||
|
||
1. Install ``tox``::
|
||
|
||
$ sudo pip install tox
|
||
|
||
2. On Ubuntu install ``mongodb`` and ``libmysqlclient-dev`` packages::
|
||
|
||
$ sudo apt-get install mongodb
|
||
$ sudo apt-get install libmysqlclient-dev
|
||
|
||
For Fedora20 there is no ``libmysqlclient-dev`` package, so you’ll need
|
||
to install ``mariadb-devel.x86-64`` (or ``mariadb-devel.i386``) instead::
|
||
|
||
$ sudo yum install mongodb
|
||
$ sudo yum install mariadb-devel.x86_64
|
||
|
||
3. Install the test dependencies::
|
||
|
||
$ sudo pip install -r /opt/stack/ceilometer/test-requirements.txt
|
||
|
||
4. Run the unit and code-style tests::
|
||
|
||
$ cd /opt/stack/ceilometer
|
||
$ 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.
|
||
|
||
.. _testr documentation: https://testrepository.readthedocs.org/en/latest/MANUAL.html
|
||
|
||
Use a double hyphen to pass options to testr. For example, to run only tests under tests/api/v2::
|
||
|
||
$ tox -e py27 -- 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 ceilometer.tests.test_bin
|
||
|
||
For reference, the ``debug`` tox environment implements the instructions
|
||
here: https://wiki.openstack.org/wiki/Testr#Debugging_.28pdb.29_Tests
|
||
|
||
5. There is a growing suite of tests which use a tool called `gabbi`_ to
|
||
test and validate the behavior of the Ceilometer API. These tests are run
|
||
when using the usual ``py27`` 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
|
||
``ceilometer/tests/gabbi/gabbits``. If you are adding to or adjusting the
|
||
API you should consider adding tests here.
|
||
|
||
.. _gabbi: https://gabbi.readthedocs.org/
|
||
|
||
.. seealso::
|
||
|
||
* tox_
|
||
|
||
.. _tox: http://tox.testrun.org/latest/
|
||
|
||
Code Reviews
|
||
============
|
||
|
||
Ceilometer uses the OpenStack review process for all code and
|
||
developer documentation contributions. Code reviews are managed
|
||
through gerrit.
|
||
|
||
.. seealso::
|
||
|
||
* http://docs.openstack.org/infra/manual/developers.html#development-workflow
|
||
* `OpenStack Gerrit instance`_.
|
||
|
||
.. _OpenStack Gerrit instance: https://review.openstack.org/#/q/status:open+project:openstack/ceilometer,n,z
|