Add test documentation for docs tox target

Enable sphinx to generate documentation from docstrings by running
'tox -e docs'.

Change-Id: I5996e5f07493f69f14172b4bb0535852e89d5456
This commit is contained in:
Elod Illes 2023-11-06 19:30:29 +01:00
parent 9aa8eb4530
commit f2e985e8fd
14 changed files with 96 additions and 65 deletions

3
.gitignore vendored
View File

@ -43,6 +43,7 @@ output/*/index.html
# Sphinx # Sphinx
doc/build doc/build
doc/source/tests
# pbr generates these # pbr generates these
AUTHORS AUTHORS
@ -54,4 +55,4 @@ ChangeLog
.*sw? .*sw?
# Files created by releasenotes build # Files created by releasenotes build
releasenotes/build releasenotes/build

View File

@ -15,7 +15,14 @@
import os import os
import sys import sys
sys.path.insert(0, os.path.abspath('../..')) def autodoc_skip_member_handler(app, what, name, obj, skip, options):
return skip or (what == "class" and not name.startswith("test"))
def setup(app):
app.connect('autodoc-skip-member', autodoc_skip_member_handler)
sys.path.insert(0, os.path.abspath('../../neutron_tempest_plugin'))
# -- General configuration ---------------------------------------------------- # -- General configuration ----------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be # Add any Sphinx extension module names here, as strings. They can be

View File

@ -15,6 +15,7 @@ Contents:
readme readme
installation installation
contributing contributing
test_descriptions
Indices and tables Indices and tables
================== ==================

View File

@ -0,0 +1,7 @@
Description of Tests
====================
.. toctree::
:maxdepth: 2
tests/modules

View File

@ -47,18 +47,18 @@ def execute(command, ssh_client=None, timeout=None, check=True):
:param timeout: command execution timeout in seconds :param timeout: command execution timeout in seconds
:param check: when False it doesn't raises ShellCommandFailed when :param check: when False it doesn't raises ShellCommandFailed when
exit status is not zero. True by default exit status is not zero. True by default
:returns: STDOUT text when command execution terminates with zero exit :returns: STDOUT text when command execution terminates with zero exit
status. status.
:raises ShellTimeoutExpired: when timeout expires before command execution :raises ShellTimeoutExpired: when timeout expires before command execution
terminates. In such case it kills the process, then it eventually would terminates. In such case it kills the process, then it eventually would
try to read STDOUT and STDERR buffers (not fully implemented) before try to read STDOUT and STDERR buffers (not fully implemented) before
raising the exception. raising the exception.
:raises ShellCommandFailed: when command execution terminates with non-zero :raises ShellCommandFailed: when command execution terminates with non-zero
exit status. exit status.
""" """
ssh_client = ssh_client or SSH_PROXY_CLIENT ssh_client = ssh_client or SSH_PROXY_CLIENT
if timeout: if timeout:

View File

@ -133,7 +133,7 @@ class Client(ssh.Client):
:returns: paramiko.Client connected to remote server. :returns: paramiko.Client connected to remote server.
:raises tempest.lib.exceptions.SSHTimeout: in case it fails to connect :raises tempest.lib.exceptions.SSHTimeout: in case it fails to connect
to remote server. to remote server.
""" """
return super(Client, self)._get_ssh_connection(*args, **kwargs) return super(Client, self)._get_ssh_connection(*args, **kwargs)

View File

@ -73,7 +73,7 @@ def wait_until_true(predicate, timeout=60, sleep=1, exception=None):
"""Wait until callable predicate is evaluated as True """Wait until callable predicate is evaluated as True
:param predicate: Callable deciding whether waiting should continue. :param predicate: Callable deciding whether waiting should continue.
Best practice is to instantiate predicate with functools.partial() Best practice is to instantiate predicate with functools.partial()
:param timeout: Timeout in seconds how long should function wait. :param timeout: Timeout in seconds how long should function wait.
:param sleep: Polling interval for results in seconds. :param sleep: Polling interval for results in seconds.
:param exception: Exception instance to raise on timeout. If None is passed :param exception: Exception instance to raise on timeout. If None is passed

View File

@ -68,24 +68,26 @@ class BgpClientMixin(object):
class Bgp(BgpClientMixin, base.BaseTempestTestCase): class Bgp(BgpClientMixin, base.BaseTempestTestCase):
"""Test the following topology """Test the following topology
+-------------------+ .. code-block:: HTML
| public |
| network | +-------------------+
| | | public |
+-+---------------+-+ | network |
| | | |
| | +-+---------------+-+
+-------+-+ +-+-------+ | |
| LEFT | | RIGHT | | |
| router | <--BGP--> | router | +-------+-+ +-+-------+
| | | | | LEFT | | RIGHT |
+----+----+ +----+----+ | router | <--BGP--> | router |
| | | | | |
+----+----+ +----+----+ +----+----+ +----+----+
| LEFT | | RIGHT | | |
| network | | network | +----+----+ +----+----+
| | | | | LEFT | | RIGHT |
+---------+ +---------+ | network | | network |
| | | |
+---------+ +---------+
""" """
credentials = ['primary', 'admin'] credentials = ['primary', 'admin']

View File

@ -173,18 +173,21 @@ class NetworkConnectivityTest(base.BaseTempestTestCase):
ensures that connectivity from VM to both routers is working. ensures that connectivity from VM to both routers is working.
Test scenario: (NOTE: 10.1.0.0/24 private CIDR is used as an example) Test scenario: (NOTE: 10.1.0.0/24 private CIDR is used as an example)
+----------------+ +------------+
| Non-dvr router | | DVR router | .. code-block:: HTML
| | | |
| 10.1.0.1 | | 10.1.0.x | +----------------+ +------------+
+-------+--------+ +-----+------+ | Non-dvr router | | DVR router |
| | | | | |
| 10.1.0.0/24 | | 10.1.0.1 | | 10.1.0.x |
+----------------+----------------+ +-------+--------+ +-----+------+
| | |
+-+-+ | 10.1.0.0/24 |
|VM | +----------------+----------------+
+---+ |
+-+-+
|VM |
+---+
where: where:
10.1.0.1 - is subnet's gateway IP address, 10.1.0.1 - is subnet's gateway IP address,

View File

@ -607,7 +607,7 @@ class FloatingIpMultipleRoutersTest(base.BaseTempestTestCase):
deleted just before the creation of the new IP to "reserve" the deleted just before the creation of the new IP to "reserve" the
IP address associated (see LP#1880976). IP address associated (see LP#1880976).
10. Create a FIP for the VM3 in the external network with 10. Create a FIP for the VM3 in the external network with
the same IP address that was used for VM2. the same IP address that was used for VM2.
11. Make sure that now VM1 is able to reach VM3 using the FIP. 11. Make sure that now VM1 is able to reach VM3 using the FIP.
Note, the scenario passes only in case corresponding Note, the scenario passes only in case corresponding

View File

@ -89,8 +89,8 @@ class InternalDNSTest(InternalDNSBase):
1) Create two VMs on the same network, giving each a name 1) Create two VMs on the same network, giving each a name
2) SSH in to the first VM: 2) SSH in to the first VM:
2.1) ping the other VM's internal IP - ping the other VM's internal IP
2.2) ping the other VM's hostname - ping the other VM's hostname
""" """
network = self.create_network(dns_domain='starwars.') network = self.create_network(dns_domain='starwars.')
self.setup_network_and_server(network=network, server_name='luke') self.setup_network_and_server(network=network, server_name='luke')

View File

@ -34,9 +34,10 @@ class VPNaaSTestJSON(base.BaseAdminNetworkTest):
Tests the following operations in the Neutron API using the REST client for Tests the following operations in the Neutron API using the REST client for
Neutron: Neutron:
List, Show, Create, Delete, and Update VPN Service
List, Show, Create, Delete, and Update IKE policy * List, Show, Create, Delete, and Update VPN Service
List, Show, Create, Delete, and Update IPSec policy * List, Show, Create, Delete, and Update IKE policy
* List, Show, Create, Delete, and Update IPSec policy
""" """
@classmethod @classmethod

View File

@ -52,24 +52,26 @@ CONF.register_opt(
class Vpnaas(base.BaseTempestTestCase): class Vpnaas(base.BaseTempestTestCase):
"""Test the following topology """Test the following topology
+-------------------+ .. code-block:: HTML
| public |
| network | +-------------------+
| | | public |
+-+---------------+-+ | network |
| | | |
| | +-+---------------+-+
+-------+-+ +-+-------+ | |
| LEFT | | RIGHT | | |
| router | <--VPN--> | router | +-------+-+ +-+-------+
| | | | | LEFT | | RIGHT |
+----+----+ +----+----+ | router | <--VPN--> | router |
| | | | | |
+----+----+ +----+----+ +----+----+ +----+----+
| LEFT | | RIGHT | | |
| network | | network | +----+----+ +----+----+
| | | | | LEFT | | RIGHT |
+---------+ +---------+ | network | | network |
| | | |
+---------+ +---------+
""" """
credentials = ['primary', 'admin'] credentials = ['primary', 'admin']

View File

@ -40,8 +40,15 @@ commands =
[testenv:docs] [testenv:docs]
deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/requirements.txt
-r{toxinidir}/doc/requirements.txt -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -W -b html doc/source doc/build/html commands =
rm -rf doc/source/tests
sphinx-apidoc -f -o doc/source/tests neutron_tempest_plugin
rm -rf doc/build
sphinx-build -W -b html doc/source doc/build/html
allowlist_externals =
rm
[testenv:releasenotes] [testenv:releasenotes]
deps = {[testenv:docs]deps} deps = {[testenv:docs]deps}