[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
|
||||
add details to context. Following details will be added:
|
||||
id of stack;
|
||||
template file contents;
|
||||
files dictionary;
|
||||
stack parameters;
|
||||
|
||||
* id of stack;
|
||||
* template file contents;
|
||||
* files dictionary;
|
||||
* stack parameters;
|
||||
|
||||
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
|
||||
template should accept the following parameters:
|
||||
network_id: id of public network
|
||||
router_id: id of external router to connect "gate" node
|
||||
key_name: name of nova ssh keypair to use for "gate" node
|
||||
|
||||
* network_id: id of public network
|
||||
* router_id: id of external router to connect "gate" node
|
||||
* key_name: name of nova ssh keypair to use for "gate" node
|
||||
"""
|
||||
FILE_SCHEMA = {
|
||||
"description": "",
|
||||
|
@ -27,8 +27,9 @@ class FaultInjectionHook(hook.Hook):
|
||||
"""Performs fault injection using os-faults library.
|
||||
|
||||
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
|
||||
and looks for "cloud_config" field. If cloud_config is present then
|
||||
|
@ -172,9 +172,11 @@ class CreateAlarmAndGetHistory(ceiloutils.CeilometerScenario):
|
||||
"""Create an alarm, get and set the state and get the alarm history.
|
||||
|
||||
This scenario makes following queries:
|
||||
GET /v2/alarms/{alarm_id}/history
|
||||
GET /v2/alarms/{alarm_id}/state
|
||||
PUT /v2/alarms/{alarm_id}/state
|
||||
|
||||
* GET /v2/alarms/{alarm_id}/history
|
||||
* 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
|
||||
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
|
||||
|
@ -759,6 +759,7 @@ class CreateVolumeAndClone(cinder_utils.CinderBasic):
|
||||
|
||||
This creates a volume, then clone it to anothor volume,
|
||||
and then clone the new volume to next volume...
|
||||
|
||||
1. create source volume (from image)
|
||||
2. clone source volume to volume1
|
||||
3. clone volume1 to volume2
|
||||
|
@ -85,6 +85,7 @@ class BootAndDeleteServerWithKeypair(utils.NovaScenario):
|
||||
"""Boot and delete server with keypair.
|
||||
|
||||
Plan of this scenario:
|
||||
|
||||
- create a keypair
|
||||
- boot a VM with created keypair
|
||||
- delete server
|
||||
|
@ -46,7 +46,7 @@ class ValidCommandValidator(validators.FileExistsValidator):
|
||||
"""Checks that parameter is a proper command-specifying dictionary.
|
||||
|
||||
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.
|
||||
|
||||
:param param_name: Name of parameter to validate
|
||||
@ -500,7 +500,7 @@ class DDLoadTest(BootRuncommandDelete):
|
||||
max_log_length=None, **kwargs):
|
||||
"""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.
|
||||
|
||||
:param image: glance image name to use for the vm. Optional
|
||||
|
@ -13,7 +13,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# 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 import validation
|
||||
from rally import plugins
|
||||
@ -21,6 +25,15 @@ from rally.task import scenario
|
||||
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):
|
||||
|
||||
def setUp(self):
|
||||
@ -47,20 +60,50 @@ class DocstringsTestCase(test.TestCase):
|
||||
result.append(msg)
|
||||
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):
|
||||
for plg_cls in plugin.Plugin.get_all():
|
||||
if plg_cls.__module__.startswith("rally."):
|
||||
doc = info.parse_docstring(plg_cls.__doc__)
|
||||
short_description = doc["short_description"]
|
||||
if short_description.startswith("Test"):
|
||||
if not plg_cls.__module__.startswith("rally_openstack."):
|
||||
continue
|
||||
name = "%s (%s.%s)" % (plg_cls.get_name(),
|
||||
plg_cls.__module__,
|
||||
plg_cls.__name__)
|
||||
doc_info = plg_cls.get_info()
|
||||
if not doc_info["title"]:
|
||||
msg_buffer.append("Plugin '%s' should have a docstring."
|
||||
% name)
|
||||
if doc_info["title"].startswith("Test"):
|
||||
msg_buffer.append("One-line description for %s"
|
||||
" should be declarative and not"
|
||||
" start with 'Test(s) ...'"
|
||||
% plg_cls.__name__)
|
||||
if not plg_cls.get_info()["title"]:
|
||||
msg = "Class '{}.{}' should have a docstring."
|
||||
msg_buffer.append(msg.format(plg_cls.__module__,
|
||||
plg_cls.__name__))
|
||||
% 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):
|
||||
for plg_cls in plugin.Plugin.get_all():
|
||||
@ -81,4 +124,4 @@ class DocstringsTestCase(test.TestCase):
|
||||
|
||||
self._check_described_params(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