[docs] fix invalid "rst" usage
* Fix an issue while splitting docstring to description of parameters and the description of the plugins itself. Method 'trip' uses the second line of docstring to identify the intend to cut. This logic bases on the fact that the first line of docstring doesn't have intend at all. Unfortunately, python docstring objects start with empty line which moves the actual first line to the second position. * We do not use definitions in any existing plugins docstrings. Existance of such nodes while parsing text means that there is an issue with intend (redundant spaces) or missed new line between list title/description and actual list items. (the proper test is added) * rst parser adds "system_message" nodes for any kind of warnings and errors. This behaviour can be used in our test to find all "invalid" things. Change-Id: I348ccf140458b604a8cc29053d166c1610ad807d
This commit is contained in:
parent
5eb6ea487a
commit
b9a90fafa0
@ -39,16 +39,19 @@ class HeatDataplane(context.Context):
|
|||||||
|
|
||||||
This context will create stacks by given template for each tenant and
|
This context will create stacks by given template for each tenant and
|
||||||
add details to context. Following details will be added:
|
add details to context. Following details will be added:
|
||||||
id of stack;
|
|
||||||
template file contents;
|
* id of stack;
|
||||||
files dictionary;
|
* template file contents;
|
||||||
stack parameters;
|
* files dictionary;
|
||||||
|
* stack parameters;
|
||||||
|
|
||||||
Heat template should define a "gate" node which will interact with Rally
|
Heat template should define a "gate" node which will interact with Rally
|
||||||
by ssh and workload nodes by any protocol. To make this possible heat
|
by ssh and workload nodes by any protocol. To make this possible heat
|
||||||
template should accept the following parameters:
|
template should accept the following parameters:
|
||||||
network_id: id of public network
|
|
||||||
router_id: id of external router to connect "gate" node
|
* network_id: id of public network
|
||||||
key_name: name of nova ssh keypair to use for "gate" node
|
* router_id: id of external router to connect "gate" node
|
||||||
|
* key_name: name of nova ssh keypair to use for "gate" node
|
||||||
"""
|
"""
|
||||||
FILE_SCHEMA = {
|
FILE_SCHEMA = {
|
||||||
"description": "",
|
"description": "",
|
||||||
|
@ -27,8 +27,9 @@ class FaultInjectionHook(hook.Hook):
|
|||||||
"""Performs fault injection using os-faults library.
|
"""Performs fault injection using os-faults library.
|
||||||
|
|
||||||
Configuration:
|
Configuration:
|
||||||
action - string that represents an action (more info in [1])
|
|
||||||
verify - whether to verify connection to cloud nodes or not
|
* action - string that represents an action (more info in [1])
|
||||||
|
* verify - whether to verify connection to cloud nodes or not
|
||||||
|
|
||||||
This plugin discovers extra config of ExistingCloud
|
This plugin discovers extra config of ExistingCloud
|
||||||
and looks for "cloud_config" field. If cloud_config is present then
|
and looks for "cloud_config" field. If cloud_config is present then
|
||||||
|
@ -171,10 +171,12 @@ class CreateAlarmAndGetHistory(ceiloutils.CeilometerScenario):
|
|||||||
def run(self, meter_name, threshold, state, timeout=60, **kwargs):
|
def run(self, meter_name, threshold, state, timeout=60, **kwargs):
|
||||||
"""Create an alarm, get and set the state and get the alarm history.
|
"""Create an alarm, get and set the state and get the alarm history.
|
||||||
|
|
||||||
This scenario makes following queries:
|
This scenario makes following queries:
|
||||||
GET /v2/alarms/{alarm_id}/history
|
|
||||||
GET /v2/alarms/{alarm_id}/state
|
* GET /v2/alarms/{alarm_id}/history
|
||||||
PUT /v2/alarms/{alarm_id}/state
|
* GET /v2/alarms/{alarm_id}/state
|
||||||
|
* PUT /v2/alarms/{alarm_id}/state
|
||||||
|
|
||||||
Initially alarm is created and then get the state of the created alarm
|
Initially alarm is created and then get the state of the created alarm
|
||||||
using its alarm_id. Then get the history of the alarm. And finally the
|
using its alarm_id. Then get the history of the alarm. And finally the
|
||||||
state of the alarm is updated using given state. meter_name and
|
state of the alarm is updated using given state. meter_name and
|
||||||
|
@ -139,8 +139,8 @@ class CreateVolumeTypeAndEncryptionType(cinder_utils.CinderBasic):
|
|||||||
is_public=True):
|
is_public=True):
|
||||||
"""Create encryption type
|
"""Create encryption type
|
||||||
|
|
||||||
This scenario first creates a volume type, then creates an encryption
|
This scenario first creates a volume type, then creates an encryption
|
||||||
type for the volume type.
|
type for the volume type.
|
||||||
|
|
||||||
:param create_specs: The encryption type specifications to add.
|
:param create_specs: The encryption type specifications to add.
|
||||||
DEPRECATED, specify arguments explicitly.
|
DEPRECATED, specify arguments explicitly.
|
||||||
@ -186,9 +186,9 @@ class CreateAndListEncryptionType(cinder_utils.CinderBasic):
|
|||||||
key_size=None, control_location="front-end", search_opts=None):
|
key_size=None, control_location="front-end", search_opts=None):
|
||||||
"""Create and list encryption type
|
"""Create and list encryption type
|
||||||
|
|
||||||
This scenario firstly creates a volume type, secondly creates an
|
This scenario firstly creates a volume type, secondly creates an
|
||||||
encryption type for the volume type, thirdly lists all encryption
|
encryption type for the volume type, thirdly lists all encryption
|
||||||
types.
|
types.
|
||||||
|
|
||||||
:param create_specs: The encryption type specifications to add.
|
:param create_specs: The encryption type specifications to add.
|
||||||
DEPRECATED, specify arguments explicitly.
|
DEPRECATED, specify arguments explicitly.
|
||||||
@ -254,10 +254,10 @@ class CreateGetAndDeleteEncryptionType(cinder_utils.CinderBasic):
|
|||||||
key_size=None, control_location="front-end"):
|
key_size=None, control_location="front-end"):
|
||||||
"""Create get and delete an encryption type
|
"""Create get and delete an encryption type
|
||||||
|
|
||||||
This scenario firstly creates an encryption type for a volome
|
This scenario firstly creates an encryption type for a volome
|
||||||
type created in the context, then gets detailed information of
|
type created in the context, then gets detailed information of
|
||||||
the created encryption type, finally deletes the created
|
the created encryption type, finally deletes the created
|
||||||
encryption type.
|
encryption type.
|
||||||
|
|
||||||
:param provider: The class that provides encryption support. For
|
:param provider: The class that provides encryption support. For
|
||||||
example, LuksEncryptor.
|
example, LuksEncryptor.
|
||||||
@ -295,8 +295,8 @@ class CreateAndDeleteEncryptionType(cinder_utils.CinderBasic):
|
|||||||
key_size=None, control_location="front-end"):
|
key_size=None, control_location="front-end"):
|
||||||
"""Create and delete encryption type
|
"""Create and delete encryption type
|
||||||
|
|
||||||
This scenario firstly creates an encryption type for a given
|
This scenario firstly creates an encryption type for a given
|
||||||
volume type, then deletes the created encryption type.
|
volume type, then deletes the created encryption type.
|
||||||
|
|
||||||
:param create_specs: the encryption type specifications to add
|
:param create_specs: the encryption type specifications to add
|
||||||
:param provider: The class that provides encryption support. For
|
:param provider: The class that provides encryption support. For
|
||||||
@ -340,9 +340,9 @@ class CreateAndUpdateEncryptionType(cinder_utils.CinderBasic):
|
|||||||
update_key_size=None, update_control_location=None):
|
update_key_size=None, update_control_location=None):
|
||||||
"""Create and update encryption type
|
"""Create and update encryption type
|
||||||
|
|
||||||
This scenario firstly creates a volume type, secondly creates an
|
This scenario firstly creates a volume type, secondly creates an
|
||||||
encryption type for the volume type, thirdly updates the encryption
|
encryption type for the volume type, thirdly updates the encryption
|
||||||
type.
|
type.
|
||||||
|
|
||||||
:param create_provider: The class that provides encryption support. For
|
:param create_provider: The class that provides encryption support. For
|
||||||
example, LuksEncryptor.
|
example, LuksEncryptor.
|
||||||
@ -391,8 +391,8 @@ class CreateVolumeTypeAddAndListTypeAccess(scenario.OpenStackScenario):
|
|||||||
def run(self, description=None, is_public=False):
|
def run(self, description=None, is_public=False):
|
||||||
"""Add and list volume type access for the given project.
|
"""Add and list volume type access for the given project.
|
||||||
|
|
||||||
This scenario first creates a private volume type, then add project
|
This scenario first creates a private volume type, then add project
|
||||||
access and list project access to it.
|
access and list project access to it.
|
||||||
|
|
||||||
:param description: Description of the volume type
|
:param description: Description of the volume type
|
||||||
:param is_public: Volume type visibility
|
:param is_public: Volume type visibility
|
||||||
|
@ -757,8 +757,9 @@ class CreateVolumeAndClone(cinder_utils.CinderBasic):
|
|||||||
def run(self, size, image=None, nested_level=1, **kwargs):
|
def run(self, size, image=None, nested_level=1, **kwargs):
|
||||||
"""Create a volume, then clone it to another volume.
|
"""Create a volume, then clone it to another volume.
|
||||||
|
|
||||||
This creates a volume, then clone it to anothor volume,
|
This creates a volume, then clone it to anothor volume,
|
||||||
and then clone the new volume to next volume...
|
and then clone the new volume to next volume...
|
||||||
|
|
||||||
1. create source volume (from image)
|
1. create source volume (from image)
|
||||||
2. clone source volume to volume1
|
2. clone source volume to volume1
|
||||||
3. clone volume1 to volume2
|
3. clone volume1 to volume2
|
||||||
|
@ -85,10 +85,11 @@ class BootAndDeleteServerWithKeypair(utils.NovaScenario):
|
|||||||
"""Boot and delete server with keypair.
|
"""Boot and delete server with keypair.
|
||||||
|
|
||||||
Plan of this scenario:
|
Plan of this scenario:
|
||||||
- create a keypair
|
|
||||||
- boot a VM with created keypair
|
- create a keypair
|
||||||
- delete server
|
- boot a VM with created keypair
|
||||||
- delete keypair
|
- delete server
|
||||||
|
- delete keypair
|
||||||
|
|
||||||
:param image: ID of the image to be used for server creation
|
:param image: ID of the image to be used for server creation
|
||||||
:param flavor: ID of the flavor to be used for server creation
|
:param flavor: ID of the flavor to be used for server creation
|
||||||
|
@ -46,7 +46,7 @@ class ValidCommandValidator(validators.FileExistsValidator):
|
|||||||
"""Checks that parameter is a proper command-specifying dictionary.
|
"""Checks that parameter is a proper command-specifying dictionary.
|
||||||
|
|
||||||
Ensure that the command dictionary is a proper command-specifying
|
Ensure that the command dictionary is a proper command-specifying
|
||||||
dictionary described in `vmtasks.VMTasks.boot_runcommand_delete'
|
dictionary described in 'vmtasks.VMTasks.boot_runcommand_delete'
|
||||||
docstring.
|
docstring.
|
||||||
|
|
||||||
:param param_name: Name of parameter to validate
|
:param param_name: Name of parameter to validate
|
||||||
@ -500,7 +500,7 @@ class DDLoadTest(BootRuncommandDelete):
|
|||||||
max_log_length=None, **kwargs):
|
max_log_length=None, **kwargs):
|
||||||
"""Boot a server from a custom image and performs dd load test.
|
"""Boot a server from a custom image and performs dd load test.
|
||||||
|
|
||||||
NOTE: dd load test is prepared script by Rally team. It checks
|
.. note:: dd load test is prepared script by Rally team. It checks
|
||||||
writing and reading metrics from the VM.
|
writing and reading metrics from the VM.
|
||||||
|
|
||||||
:param image: glance image name to use for the vm. Optional
|
:param image: glance image name to use for the vm. Optional
|
||||||
|
@ -49,15 +49,15 @@ class TempestManager(testr.TestrLauncher):
|
|||||||
|
|
||||||
Rally supports features listed below:
|
Rally supports features listed below:
|
||||||
|
|
||||||
* *cloning Tempest*: repository and version can be specified
|
* *cloning Tempest*: repository and version can be specified
|
||||||
* *installation*: system-wide with checking existence of required
|
* *installation*: system-wide with checking existence of required
|
||||||
packages or in virtual environment
|
packages or in virtual environment
|
||||||
* *configuration*: options are discovered via OpenStack API, but you can
|
* *configuration*: options are discovered via OpenStack API, but you can
|
||||||
override them if you need
|
override them if you need
|
||||||
* *running*: pre-creating all required resources(i.e images, tenants,
|
* *running*: pre-creating all required resources(i.e images, tenants,
|
||||||
etc), prepare arguments, launching Tempest, live-progress output
|
etc), prepare arguments, launching Tempest, live-progress output
|
||||||
* *results*: all verifications are stored in db, you can built reports,
|
* *results*: all verifications are stored in db, you can built reports,
|
||||||
compare verification at whatever you want time.
|
compare verification at whatever you want time.
|
||||||
|
|
||||||
Appeared in Rally 0.8.0 *(actually, it appeared long time ago with first
|
Appeared in Rally 0.8.0 *(actually, it appeared long time ago with first
|
||||||
revision of Verification Component, but 0.8.0 is mentioned since it is
|
revision of Verification Component, but 0.8.0 is mentioned since it is
|
||||||
|
@ -13,7 +13,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common.plugin import info
|
from docutils import frontend
|
||||||
|
from docutils import nodes
|
||||||
|
from docutils.parsers import rst
|
||||||
|
from docutils import utils
|
||||||
|
|
||||||
from rally.common.plugin import plugin
|
from rally.common.plugin import plugin
|
||||||
from rally.common import validation
|
from rally.common import validation
|
||||||
from rally import plugins
|
from rally import plugins
|
||||||
@ -21,6 +25,15 @@ from rally.task import scenario
|
|||||||
from tests.unit import test
|
from tests.unit import test
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_rst(text):
|
||||||
|
parser = rst.Parser()
|
||||||
|
settings = frontend.OptionParser(
|
||||||
|
components=(rst.Parser,)).get_default_values()
|
||||||
|
document = utils.new_document(text, settings)
|
||||||
|
parser.parse(text, document)
|
||||||
|
return document.children
|
||||||
|
|
||||||
|
|
||||||
class DocstringsTestCase(test.TestCase):
|
class DocstringsTestCase(test.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -47,20 +60,50 @@ class DocstringsTestCase(test.TestCase):
|
|||||||
result.append(msg)
|
result.append(msg)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
# the list with plugins names which use rst definitions in their docstrings
|
||||||
|
_HAS_VALID_DEFINITIONS = []
|
||||||
|
|
||||||
|
def _validate_rst(self, plugin_name, text, msg_buffer):
|
||||||
|
# need to wait till the next release of rally
|
||||||
|
return
|
||||||
|
parsed_docstring = _parse_rst(text)
|
||||||
|
for item in parsed_docstring:
|
||||||
|
if (isinstance(item, nodes.definition_list)
|
||||||
|
and plugin_name not in self._HAS_VALID_DEFINITIONS):
|
||||||
|
msg_buffer.append("Plugin %s has a docstring with invalid "
|
||||||
|
"format. Re-check intend and required empty "
|
||||||
|
"lines between the list title and list "
|
||||||
|
"items." % plugin_name)
|
||||||
|
elif isinstance(item, nodes.system_message):
|
||||||
|
msg_buffer.append(
|
||||||
|
"A warning is caught while parsing docstring of '%s' "
|
||||||
|
"plugin: %s" % (plugin_name, item.astext()))
|
||||||
|
|
||||||
def _check_docstrings(self, msg_buffer):
|
def _check_docstrings(self, msg_buffer):
|
||||||
for plg_cls in plugin.Plugin.get_all():
|
for plg_cls in plugin.Plugin.get_all():
|
||||||
if plg_cls.__module__.startswith("rally."):
|
if not plg_cls.__module__.startswith("rally_openstack."):
|
||||||
doc = info.parse_docstring(plg_cls.__doc__)
|
continue
|
||||||
short_description = doc["short_description"]
|
name = "%s (%s.%s)" % (plg_cls.get_name(),
|
||||||
if short_description.startswith("Test"):
|
plg_cls.__module__,
|
||||||
msg_buffer.append("One-line description for %s"
|
plg_cls.__name__)
|
||||||
" should be declarative and not"
|
doc_info = plg_cls.get_info()
|
||||||
" start with 'Test(s) ...'"
|
if not doc_info["title"]:
|
||||||
% plg_cls.__name__)
|
msg_buffer.append("Plugin '%s' should have a docstring."
|
||||||
if not plg_cls.get_info()["title"]:
|
% name)
|
||||||
msg = "Class '{}.{}' should have a docstring."
|
if doc_info["title"].startswith("Test"):
|
||||||
msg_buffer.append(msg.format(plg_cls.__module__,
|
msg_buffer.append("One-line description for %s"
|
||||||
plg_cls.__name__))
|
" should be declarative and not"
|
||||||
|
" start with 'Test(s) ...'"
|
||||||
|
% name)
|
||||||
|
|
||||||
|
# NOTE(andreykurilin): I never saw any real usage of
|
||||||
|
# reStructuredText definitions in our docstrings. In most cases,
|
||||||
|
# "definitions" means that there is an issue with intends or
|
||||||
|
# missed empty line before the list title and list items.
|
||||||
|
if doc_info["description"]:
|
||||||
|
self._validate_rst(plg_cls.get_name(),
|
||||||
|
doc_info["description"],
|
||||||
|
msg_buffer)
|
||||||
|
|
||||||
def _check_described_params(self, msg_buffer):
|
def _check_described_params(self, msg_buffer):
|
||||||
for plg_cls in plugin.Plugin.get_all():
|
for plg_cls in plugin.Plugin.get_all():
|
||||||
@ -81,4 +124,4 @@ class DocstringsTestCase(test.TestCase):
|
|||||||
|
|
||||||
self._check_described_params(msg_buffer)
|
self._check_described_params(msg_buffer)
|
||||||
if msg_buffer:
|
if msg_buffer:
|
||||||
self.fail("\n%s" % "\n".join(msg_buffer))
|
self.fail("\n%s" % "\n===============\n".join(msg_buffer))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user