Add Docs for plugin
Change-Id: I0064553874e621da17fcc742868b4373c233bb7b
This commit is contained in:
parent
f90cfcf912
commit
c392cf94fd
|
@ -0,0 +1,249 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# designate documentation build configuration file, created by
|
||||
# sphinx-quickstart on Wed Oct 31 18:58:17 2012.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os, subprocess
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
sys.path.insert(0, os.path.abspath('../../'))
|
||||
sys.path.insert(0, os.path.abspath('../'))
|
||||
sys.path.insert(0, os.path.abspath('./'))
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = []
|
||||
|
||||
import openstackdocstheme
|
||||
|
||||
html_theme = 'openstackdocs'
|
||||
html_theme_path = [openstackdocstheme.get_html_theme_path()]
|
||||
|
||||
# We ask git for the SHA checksum
|
||||
# The git SHA checksum is used by "log-a-bug"
|
||||
git_cmd = ["/usr/bin/git", "rev-parse", "HEAD"]
|
||||
gitsha = subprocess.Popen(
|
||||
git_cmd, stdout=subprocess.PIPE).communicate()[0].strip('\n')
|
||||
# tag that reported bugs will be tagged with
|
||||
bug_tag = "tempest-plugin-docs"
|
||||
# source tree
|
||||
pwd = os.getcwd()
|
||||
# html_context allows us to pass arbitrary values into the html template
|
||||
html_context = {"pwd": pwd, "gitsha": gitsha}
|
||||
# Must set this variable to include year, month, day, hours, and minutes.
|
||||
html_last_updated_fmt = '%Y-%m-%d %H:%M'
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'designate'
|
||||
copyright = u'2012, Managed I.T.'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = []
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
modindex_common_prefix = ["designate_tempest_plugin."]
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'designatedoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'designate.tex', u'Designate Tempest Plugin Documentation',
|
||||
u'Managed I.T.', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
# ('index', 'designate', u'Designate Documentation',
|
||||
# [u'Managed I.T.'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'designate', u'Designate Tempest Plugin Documentation',
|
||||
u'Managed I.T.', 'designate_tempest_plugin', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
|
@ -0,0 +1,291 @@
|
|||
..
|
||||
Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
|
||||
|
||||
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.
|
||||
|
||||
.. _tempest:
|
||||
|
||||
=======================
|
||||
Designat Tempest Plugin
|
||||
=======================
|
||||
|
||||
The Designate team maintains a set of tempest tests to exercise the Designate
|
||||
service and APIs.
|
||||
|
||||
Intro and References
|
||||
====================
|
||||
* `Tempest Docs`_ - Tempest docs
|
||||
* `Tempest HACKING`_ - General tempest style and coding guidelines
|
||||
* `Tempest Plugins`_ - Tempest Test Plugin Interface guide
|
||||
|
||||
Quick Start
|
||||
===========
|
||||
|
||||
To run all tests from this plugin, install the plugin into your environment
|
||||
and from the tempest repo, run::
|
||||
|
||||
$ tox -e all-plugin -- designate
|
||||
|
||||
If that doesn't run any tests, ensure that the designate-tempest-plugin is installed
|
||||
in the tox venv. Replace ``../designate-tempest-plugin/`` with the path to the plugin
|
||||
on your system. Then execute the above tox command again::
|
||||
|
||||
$ .tox/all-plugin/bin/pip install ../designate-tempest-plugin/
|
||||
$ tox -e all-plugin -- designate
|
||||
|
||||
.. note:: This is not necessary if ``designate-tempest-plugin`` is installed to
|
||||
site-packages before the ``all-plugin`` tox venv is created.
|
||||
|
||||
To run a single test case, run with the test case name, for example::
|
||||
|
||||
$ tox -e all-plugin -- designate_tempest_plugin.tests.api.v2.test_zones.ZonesAdminTest.test_get_other_tenant_zone
|
||||
|
||||
To run all tempest tests including this plugin, run::
|
||||
|
||||
$ tox -e all-plugin
|
||||
|
||||
Writing new tests
|
||||
=================
|
||||
|
||||
Writing new tests is easy, and we encourage contributors to write tests for
|
||||
any new or changed functionality. Most of the patterns you will find in the
|
||||
Designate tests will look familiar if you have contributed to tempest, so rather
|
||||
than re-type all their docs here, please have a read of the `Tempest Docs`_.
|
||||
|
||||
Test Clients
|
||||
------------
|
||||
|
||||
In Tempest tests, it is forbidden to use a services python bindings or client,
|
||||
as doing so would allow API changes to go unnoticed when the server and client
|
||||
are updated. As such, each service is expected to have a minimal in-tree
|
||||
client. Designate's client can be found in:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ tree -P "*_client.py" designate_tempest_plugin/services/dns/
|
||||
|
||||
designate_tempest_plugin/services/dns/
|
||||
├── json
|
||||
│ └── versions_client.py
|
||||
└── v2
|
||||
└── json
|
||||
├── recordsets_client.py
|
||||
└── zones_client.py
|
||||
|
||||
An example client, in this case for a subset of /v2/zones is included below:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class ZonesClient(base.DnsClientV2Base):
|
||||
"""API V2 Tempest REST client for Designate API"""
|
||||
|
||||
@base.handle_errors
|
||||
def create_zone(self, name=None, email=None, ttl=None, description=None,
|
||||
wait_until=False, params=None):
|
||||
"""Create a zone with the specified parameters.
|
||||
|
||||
:param name: The name of the zone.
|
||||
Default: Random Value
|
||||
:param email: The email for the zone.
|
||||
Default: Random Value
|
||||
:param ttl: The ttl for the zone.
|
||||
Default: Random Value
|
||||
:param description: A description of the zone.
|
||||
Default: Random Value
|
||||
:param wait_until: Block until the zone reaches the desired status
|
||||
:param params: A Python dict that represents the query parameters to
|
||||
include in the request URI.
|
||||
:return: A tuple with the server response and the created zone.
|
||||
"""
|
||||
zone = {
|
||||
'name': name or dns_data_utils.rand_zone_name(),
|
||||
'email': email or dns_data_utils.rand_email(),
|
||||
'ttl': ttl or dns_data_utils.rand_ttl(),
|
||||
'description': description or data_utils.rand_name('test-zone'),
|
||||
}
|
||||
|
||||
resp, body = self._create_request('zones', zone, params=params)
|
||||
|
||||
if wait_until:
|
||||
waiters.wait_for_zone_status(self, body['id'], wait_until)
|
||||
|
||||
return resp, body
|
||||
|
||||
Some items to note, client methods should be wrapped in the
|
||||
`base.handle_errors` decorator, which is used to allow for ignoring certain
|
||||
types of errors, in certain cases. Most commonly, this will be ignoring 404's
|
||||
when cleaning up resources.
|
||||
|
||||
Test Cases
|
||||
----------
|
||||
|
||||
Designate's tests can be found in:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ tree -P "test_*.py" designate_tempest_plugin/tests/
|
||||
|
||||
designate_tempest_plugin/tests/
|
||||
├── api
|
||||
│ ├── test_versions.py
|
||||
│ └── v2
|
||||
│ ├── test_recordsets.py
|
||||
│ └── test_zones.py
|
||||
└── scenario
|
||||
└── v2
|
||||
├── test_recordsets.py
|
||||
└── test_zones.py
|
||||
|
||||
There are two groupings of tests here "api" and "scenario". **API tests**
|
||||
should be quick, and simple. Testing as small a surface area of the API as is
|
||||
possible while still getting the job done. Additionally, API tests should avoid
|
||||
waiting for resources to become ACTIVE etc, as this typically pushes test time
|
||||
out significantly, and would only duplicate scenario tests. **Scenario tests**
|
||||
should cover common real world uses cases. For example, creating a zone,
|
||||
waiting for it to become ACTIVE, adding some records, waiting for ACTIVE,
|
||||
querying the DNS servers themselves, and finally deleting the zone and waiting
|
||||
for it to 404.
|
||||
|
||||
An example test, in this case for a subset of /v2/zones functionality is
|
||||
included below:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class ZonesTest(BaseZonesTest):
|
||||
@classmethod
|
||||
def setup_clients(cls):
|
||||
super(ZonesTest, cls).setup_clients()
|
||||
|
||||
cls.client = cls.os.zones_client
|
||||
|
||||
@test.attr(type='smoke')
|
||||
@decorators.idempotent_id('fbabd6af-238a-462e-b923-de4d736b90a7')
|
||||
def test_create_zone(self):
|
||||
LOG.info('Create a zone')
|
||||
_, zone = self.client.create_zone()
|
||||
self.addCleanup(self.client.delete_zone, zone['id'])
|
||||
|
||||
LOG.info('Ensure we respond with CREATE+PENDING')
|
||||
self.assertEqual('CREATE', zone['action'])
|
||||
self.assertEqual('PENDING', zone['status'])
|
||||
|
||||
LOG.info('Ensure the fetched response matches the created zone')
|
||||
self._assertExpected(zone, body)
|
||||
|
||||
|
||||
Test Cases - Alternative Credentials
|
||||
------------------------------------
|
||||
|
||||
Some tests require more than just a "standard" cloud user, e.g. those tests
|
||||
checking admin only functionality. We can ensure both user and admin
|
||||
credentials are available using the class level "credentials" property like so:
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class ZonesAdminTest(BaseZonesTest):
|
||||
credentials = ['primary', 'admin']
|
||||
|
||||
@classmethod
|
||||
def setup_clients(cls):
|
||||
super(ZonesAdminTest, cls).setup_clients()
|
||||
|
||||
cls.client = cls.os.zones_client
|
||||
cls.adm_client = cls.os_adm.zones_client
|
||||
|
||||
@decorators.idempotent_id('6477f92d-70ba-46eb-bd6c-fc50c405e222')
|
||||
def test_get_other_tenant_zone(self):
|
||||
LOG.info('Create a zone as a user')
|
||||
_, zone = self.client.create_zone()
|
||||
self.addCleanup(self.client.delete_zone, zone['id'])
|
||||
|
||||
LOG.info('Fetch the zone as an admin')
|
||||
_, body = self.adm_client.show_zone(
|
||||
zone['id'], params={'all_tenants': True})
|
||||
|
||||
LOG.info('Ensure the fetched response matches the created zone')
|
||||
self._assertExpected(zone, body)
|
||||
|
||||
|
||||
Test Decorators
|
||||
---------------
|
||||
|
||||
Several different test decorators are used within the test cases, this attempts
|
||||
to explain their purpose and correct usage.
|
||||
|
||||
|
||||
@decorators.idempotent_id
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The `idempotent_id` decorator allows for tracking of tests even after they have
|
||||
been renamed. The UUID should be randomly generated as the test is first
|
||||
written, e.g. with `uuidgen` on most linux hosts, and should not be changed
|
||||
when the test is renamed.
|
||||
|
||||
Every test should have a unique idempotent_id assigned.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class ZonesTest(BaseZonesTest):
|
||||
@decorators.idempotent_id('fbabd6af-238a-462e-b923-de4d736b90a7')
|
||||
def test_create_zone(self):
|
||||
pass
|
||||
|
||||
|
||||
@test.attr
|
||||
~~~~~~~~~~
|
||||
|
||||
The `attr` decorator is used to set test attributes, this is most commonly used
|
||||
to set the test type. Currently, we use one test type "smoke", which should be
|
||||
applied to any tests which test the most basic functionality Designate
|
||||
provides, allowing for the core functionality to be tested quickly, without
|
||||
having to run the entire suite. Another type we use is "slow", which should be
|
||||
applied to tests which take on average 5 seconds or more.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class ZonesTest(BaseZonesTest):
|
||||
@test.attr(type='smoke')
|
||||
def test_create_zone(self):
|
||||
pass
|
||||
|
||||
@test.attr(type='slow')
|
||||
def test_something_else(self):
|
||||
pass
|
||||
|
||||
@test.services
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
The `services` decorator is used to indicate which services are exercised by
|
||||
a given test. The `services` decorator may only be used on scenario tests, and
|
||||
(for now) should not include "dns" itself. For example, given a scenario test
|
||||
that interactions with Designate's Reverse DNS APIs, which in turn talk to
|
||||
Neutron, we would use something like the below:
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class ReverseTest(BaseDnsTest):
|
||||
@test.services('network')
|
||||
def test_reverse_dns_for_fips(self):
|
||||
pass
|
||||
|
||||
|
||||
.. _Tempest Docs: http://docs.openstack.org/developer/tempest/
|
||||
.. _Tempest HACKING: http://docs.openstack.org/developer/tempest/HACKING.html
|
||||
.. _Tempest Plugins: http://docs.openstack.org/developer/tempest/plugin.html
|
|
@ -4,3 +4,5 @@
|
|||
|
||||
# Hacking already pins down pep8, pyflakes and flake8
|
||||
hacking<0.10,>=0.9.2
|
||||
openstackdocstheme>=1.5.0 # Apache-2.0
|
||||
sphinx>=1.5.1 # BSD
|
Loading…
Reference in New Issue