From 487ebec24fa54678adab9e5ef0fee9adc2b1c5d5 Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Tue, 9 Jan 2018 17:12:00 +0000 Subject: [PATCH] Clean up packaging and docs to make this consumable * add a convenience Makefile * add license headers * rationalized requirements.txt * add wheel building capabilities * update README --- Makefile | 23 +++++++++++++ README.rst | 59 ++++++++++++++++++++++++--------- gabbi_tempest/__init__.py | 14 ++++++++ gabbi_tempest/tests/__init__.py | 11 ++++++ requirements.txt | 2 ++ samples/multi.yaml | 2 ++ setup.cfg | 5 ++- 7 files changed, 99 insertions(+), 17 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b397713 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +# simple Makefile for some common tasks +.PHONY: clean dist release pypi tagv + +clean: + find . -name "*.pyc" |xargs rm || true + rm -r dist || true + rm -r build || true + rm -r .eggs || true + rm -r gabbi_tempest.egg-info || true + +tagv: + git tag -s \ + -m `python -c 'import gabbi_tempest; print gabbi_tempest.__version__'` \ + `python -c 'import gabbi_tempest; print gabbi_tempest.__version__'` + git push origin master --tags + +dist: + python setup.py sdist bdist_wheel + +release: clean tagv pypi + +pypi: + python setup.py sdist bdist_wheel upload --sign diff --git a/README.rst b/README.rst index 775fa79..893e810 100644 --- a/README.rst +++ b/README.rst @@ -2,16 +2,26 @@ Gabbi + Tempest =============== -This is an exploration of running gabbi_ as a tempest plugin. This -code is based entirely on the work of Mehdi Abaakouk who made a -tempest plugin for gnocchi_. This code models that but tries to -be more generic: it allows you to set a ``GABBI_TEMPEST_PATH`` -environment variable pointing to multiple directories containing -gabbi YAML files. +Gabbi-tempest is an experimental Tempest_ plugin_ that enables +testing the APIs of running OpenStack services, integrated with +tempest but without needing to write Python. Instead the YAML +format_ provided by gabbi_ is used to write and evaluate HTTP +requests and responses. + +Tests are placed in YAML files in one or more directories. Those +directories are added to a ``GABBI_TEMPEST_PATH`` environment +variable. When that variable is passed into a tempest test +runner that is aware of the gabbi plugin, the files on that path +will be used to create tempests tests. The test harness sets a series of enviornment variables that can -be used in the YAML to reach the available services. These will -eventually need to be extended (or can be extended by subclasses). +be used in the YAML to reach the available services. The available +variables may be extended in two ways: + +* Adding them to the environment that calls tempest if the values are + known. +* Setting them in a subclass of the plugin if the values need to + be calculated from what tempest knows. For each service in the service catalog there are ``_SERVICE`` and ``_BASE`` variables @@ -19,38 +29,55 @@ For each service in the service catalog there are ``SERVICE_TOKEN``, ``IMAGE_REF``, ``FLAVOR_REF`` and ``FLAVOR_REF_ALT`` are also available. +For the time being the ``SERVICE_TOKEN`` is ``admin``. + Trying It --------- To experiment with this you need a working tempest installation and -configuration. I used devstack with:: +configuration. One way to do that is to use devstack_ with the +following added to the local.conf:: enable_service tempest INSTALL_TEMPEST=True in local.conf. -Once tempest is confirmed to be working, make a clone of this repo, -cd into it and do the equivalent of:: +Once tempest is confirmed to be working, gabbi-tempest must be +installed. Either install it from PyPI:: + + pip install gabbi-tempest + +Or make a clone of this repo_, cd into it, and do the equivalent of:: pip install -e . If you are using virtualenvs or need sudo, your form will be different. +Create some gabbi_ tests that exercise the OpenStack services. There +are sample files in the ``samples`` directory in the repo_. + Go to the tempest directory (often ``/opt/stack/tempest``) and run -tempest limiting the test run to gabbi related tests and setting -the PATH variable:: +tempest as follows. Adding the ``regex`` will limit the test run +to just gabbi related tests:: GABBI_TEMPEST_PATH=/path/one:/path/two tempest run --regex gabbi This will run the tests described by the YAML files in ``/path/one`` and ``/path/two``. -There is a sample files in ``samples`` in the repo which you can try -with:: +History +------- - GABBI_TEMPEST_PATH=/path/to/samples tempest run --regex gabbi +This code is based on the work of Mehdi Abaakouk who made a tempest +plugin for gnocchi_ that worked with gabbi_. He figured out the +details of the plugin structure. +.. _devstack: https://docs.openstack.org/devstack/latest/ +.. _Tempest: https://docs.openstack.org/tempest/latest/ +.. _plugin: https://docs.openstack.org/tempest/latest/plugin.html .. _gnocchi: https://review.openstack.org/#/c/301585/ .. _gabbi: https://gabbi.readthedocs.org/ +.. _format: https://gabbi.readthedocs.io/en/latest/format.html +.. _repo: https://github.com/cdent/gabbi-tempest diff --git a/gabbi_tempest/__init__.py b/gabbi_tempest/__init__.py index e69de29..a6eaf4e 100644 --- a/gabbi_tempest/__init__.py +++ b/gabbi_tempest/__init__.py @@ -0,0 +1,14 @@ +# +# 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. + +__version__ = '0.1.0' diff --git a/gabbi_tempest/tests/__init__.py b/gabbi_tempest/tests/__init__.py index e69de29..94e731d 100644 --- a/gabbi_tempest/tests/__init__.py +++ b/gabbi_tempest/tests/__init__.py @@ -0,0 +1,11 @@ +# 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. diff --git a/requirements.txt b/requirements.txt index b95349a..88971cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ +pbr gabbi +six diff --git a/samples/multi.yaml b/samples/multi.yaml index a04b69e..a8d40a3 100644 --- a/samples/multi.yaml +++ b/samples/multi.yaml @@ -89,7 +89,9 @@ tests: response_json_paths: $.server.status: VERIFY_RESIZE + # expected to fail because we don't double this way anymore - name: check for double allocations + xfail: True GET: *s1_alloc poll: count: 10 diff --git a/setup.cfg b/setup.cfg index 9133dbb..6bf97bf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,8 +15,8 @@ classifier = Programming Language :: Python :: 2 Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 - Programming Language :: Python :: 3.4 Programming Language :: Python :: 3.5 + Programming Language :: Python :: 3.6 Topic :: Software Development :: Testing [files] @@ -31,3 +31,6 @@ source-dir = docs/source [entry_points] tempest.test_plugins = gabbi = gabbi_tempest.plugin:GabbiTempestPlugin + +[bdist_wheel] +universal=1