Fix lint errors found in docstrings
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""RabbitMQ Testing."""
|
||||
|
||||
import json
|
||||
import logging
|
||||
import time
|
||||
@@ -31,8 +33,7 @@ from . import utils as rmq_utils
|
||||
|
||||
|
||||
class RmqTests(test_utils.OpenStackBaseTest):
|
||||
"""Zaza tests on a basic rabbitmq cluster deployment. Verify
|
||||
relations, service status, users and endpoint service catalog."""
|
||||
"""Zaza tests on a basic rabbitmq cluster deployment."""
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
@@ -40,19 +41,22 @@ class RmqTests(test_utils.OpenStackBaseTest):
|
||||
super(RmqTests, cls).setUpClass()
|
||||
|
||||
def _get_uuid_epoch_stamp(self):
|
||||
"""Returns a stamp string based on uuid4 and epoch time. Useful in
|
||||
generating test messages which need to be unique-ish."""
|
||||
"""Return a string based on uuid4 and epoch time.
|
||||
|
||||
Useful in generating test messages which need to be unique-ish.
|
||||
"""
|
||||
return '[{}-{}]'.format(uuid.uuid4(), time.time())
|
||||
|
||||
def _test_rmq_amqp_messages_all_units(self, units,
|
||||
ssl=False, port=None):
|
||||
"""Reusable test to send amqp messages to every listed rmq unit
|
||||
and check every listed rmq unit for messages.
|
||||
"""Reusable test to send/check amqp messages to every listed rmq unit.
|
||||
|
||||
Reusable test to send amqp messages to every listed rmq
|
||||
unit. Checks every listed rmq unit for messages.
|
||||
:param units: list of units
|
||||
:returns: None if successful. Raise on error.
|
||||
"""
|
||||
|
||||
"""
|
||||
# Add test user if it does not already exist
|
||||
rmq_utils.add_user(units)
|
||||
|
||||
@@ -120,8 +124,7 @@ class RmqTests(test_utils.OpenStackBaseTest):
|
||||
rmq_utils.delete_user(units)
|
||||
|
||||
def test_400_rmq_cluster_running_nodes(self):
|
||||
"""Verify that cluster status from each rmq juju unit shows
|
||||
every cluster node as a running member in that cluster."""
|
||||
"""Verify cluster status shows every cluster node as running member."""
|
||||
logging.debug('Checking that all units are in cluster_status '
|
||||
'running nodes...')
|
||||
|
||||
@@ -133,8 +136,12 @@ class RmqTests(test_utils.OpenStackBaseTest):
|
||||
logging.info('OK\n')
|
||||
|
||||
def test_406_rmq_amqp_messages_all_units_ssl_off(self):
|
||||
"""Send amqp messages to every rmq unit and check every rmq unit
|
||||
for messages. Standard amqp tcp port, no ssl."""
|
||||
"""Send (and check) amqp messages to every rmq unit.
|
||||
|
||||
Sends amqp messages to every rmq unit, and check every rmq
|
||||
unit for messages. Uses Standard amqp tcp port, no ssl.
|
||||
|
||||
"""
|
||||
logging.debug('Checking amqp message publish/get on all units '
|
||||
'(ssl off)...')
|
||||
|
||||
@@ -151,8 +158,12 @@ class RmqTests(test_utils.OpenStackBaseTest):
|
||||
return lsb_release()['DISTRIB_CODENAME']
|
||||
|
||||
def test_408_rmq_amqp_messages_all_units_ssl_on(self):
|
||||
"""Send amqp messages with ssl enabled, to every rmq unit and
|
||||
check every rmq unit for messages. Standard ssl tcp port."""
|
||||
"""Send (and check) amqp messages to every rmq unit (ssl enabled).
|
||||
|
||||
Sends amqp messages to every rmq unit, and check every rmq
|
||||
unit for messages. Uses Standard ssl tcp port.
|
||||
|
||||
"""
|
||||
units = zaza.model.get_units(self.application_name)
|
||||
|
||||
# http://pad.lv/1625044
|
||||
@@ -160,7 +171,7 @@ class RmqTests(test_utils.OpenStackBaseTest):
|
||||
CompareHostReleases(self._series(units[0])) <= 'trusty'):
|
||||
logging.info('SKIP')
|
||||
logging.info('Skipping SSL tests due to client'
|
||||
' compatibility issues')
|
||||
' compatibility issues')
|
||||
return
|
||||
logging.debug('Checking amqp message publish/get on all units '
|
||||
'(ssl on)...')
|
||||
@@ -171,8 +182,12 @@ class RmqTests(test_utils.OpenStackBaseTest):
|
||||
logging.info('OK\n')
|
||||
|
||||
def test_410_rmq_amqp_messages_all_units_ssl_alt_port(self):
|
||||
"""Send amqp messages with ssl on, to every rmq unit and check
|
||||
every rmq unit for messages. Custom ssl tcp port."""
|
||||
"""Send (and check) amqp messages to every rmq unit (alt ssl port).
|
||||
|
||||
Send amqp messages with ssl on, to every rmq unit and check
|
||||
every rmq unit for messages. Custom ssl tcp port.
|
||||
|
||||
"""
|
||||
units = zaza.model.get_units(self.application_name)
|
||||
|
||||
# http://pad.lv/1625044
|
||||
@@ -180,7 +195,7 @@ class RmqTests(test_utils.OpenStackBaseTest):
|
||||
CompareHostReleases(self._series(units[0])) <= 'trusty'):
|
||||
logging.info('SKIP')
|
||||
logging.info('Skipping SSL tests due to client'
|
||||
' compatibility issues')
|
||||
' compatibility issues')
|
||||
return
|
||||
logging.debug('Checking amqp message publish/get on all units '
|
||||
'(ssl on)...')
|
||||
@@ -281,8 +296,7 @@ class RmqTests(test_utils.OpenStackBaseTest):
|
||||
logging.info('OK\n')
|
||||
|
||||
def test_910_pause_and_resume(self):
|
||||
"""The services can be paused and resumed. """
|
||||
|
||||
"""The services can be paused and resumed."""
|
||||
logging.debug('Checking pause and resume actions...')
|
||||
|
||||
unit = zaza.model.get_units(self.application_name)[0]
|
||||
@@ -305,7 +319,7 @@ class RmqTests(test_utils.OpenStackBaseTest):
|
||||
logging.debug('OK')
|
||||
|
||||
def test_911_cluster_status(self):
|
||||
""" rabbitmqctl cluster_status action can be returned. """
|
||||
"""Test rabbitmqctl cluster_status action can be returned."""
|
||||
logging.debug('Checking cluster status action...')
|
||||
|
||||
unit = zaza.model.get_units(self.application_name)[0]
|
||||
@@ -315,7 +329,7 @@ class RmqTests(test_utils.OpenStackBaseTest):
|
||||
logging.debug('OK')
|
||||
|
||||
def test_912_check_queues(self):
|
||||
""" rabbitmqctl check_queues action can be returned. """
|
||||
"""Test rabbitmqctl check_queues action can be returned."""
|
||||
logging.debug('Checking cluster status action...')
|
||||
|
||||
unit = zaza.model.get_units(self.application_name)[0]
|
||||
@@ -323,7 +337,7 @@ class RmqTests(test_utils.OpenStackBaseTest):
|
||||
self.assertIsInstance(action, juju.action.Action)
|
||||
|
||||
def test_913_list_unconsumed_queues(self):
|
||||
""" rabbitmqctl list-unconsumed-queues action can be returned. """
|
||||
"""Test rabbitmqctl list-unconsumed-queues action can be returned."""
|
||||
logging.debug('Checking list-unconsumed-queues action...')
|
||||
|
||||
unit = zaza.model.get_units(self.application_name)[0]
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""RabbitMQ Testing utility functions."""
|
||||
|
||||
import json
|
||||
import logging
|
||||
import time
|
||||
@@ -24,10 +26,13 @@ import zaza.openstack.utilities.generic as generic_utils
|
||||
|
||||
|
||||
def wait_for_cluster(model_name=None, timeout=1200):
|
||||
"""Wait for rmq units extended status to show cluster readiness,
|
||||
"""Wait for Rmq cluster status to show cluster readiness.
|
||||
|
||||
Wait for rmq units extended status to show cluster readiness,
|
||||
after an optional initial sleep period. Initial sleep is likely
|
||||
necessary to be effective following a config change, as status
|
||||
message may not instantly update to non-ready."""
|
||||
message may not instantly update to non-ready.
|
||||
"""
|
||||
states = {
|
||||
'rabbitmq-server': {
|
||||
'workload-status-messages': 'Unit is ready and clustered'
|
||||
@@ -40,7 +45,9 @@ def wait_for_cluster(model_name=None, timeout=1200):
|
||||
|
||||
|
||||
def add_user(units, username="testuser1", password="changeme"):
|
||||
"""Add a user via the first rmq juju unit, check connection as
|
||||
"""Add a user to a RabbitMQ cluster.
|
||||
|
||||
Add a user via the first rmq juju unit, check connection as
|
||||
the new user against all units.
|
||||
:param units: list of unit pointers
|
||||
:param username: amqp user name, default to testuser1
|
||||
@@ -77,7 +84,9 @@ def add_user(units, username="testuser1", password="changeme"):
|
||||
|
||||
|
||||
def delete_user(units, username="testuser1"):
|
||||
"""Delete a rabbitmq user via the first rmq juju unit.
|
||||
"""Delete a user from a RabbitMQ cluster.
|
||||
|
||||
Delete a rabbitmq user via the first rmq juju unit.
|
||||
:param units: list of unit pointers
|
||||
:param username: amqp user name, default to testuser1
|
||||
:param password: amqp user password
|
||||
@@ -101,7 +110,9 @@ def delete_user(units, username="testuser1"):
|
||||
|
||||
|
||||
def get_cluster_status(unit):
|
||||
"""Execute rabbitmq cluster status command on a unit and return
|
||||
"""Get RabbitMQ cluster status output.
|
||||
|
||||
Execute rabbitmq cluster status command on a unit and return
|
||||
the full output.
|
||||
:param unit: unit
|
||||
:returns: String containing console output of cluster status command
|
||||
@@ -114,7 +125,9 @@ def get_cluster_status(unit):
|
||||
|
||||
|
||||
def get_cluster_running_nodes(unit):
|
||||
"""Parse rabbitmqctl cluster_status output string, return list of
|
||||
"""Get a list of RabbitMQ cluster's running nodes.
|
||||
|
||||
Parse rabbitmqctl cluster_status output string, return list of
|
||||
running rabbitmq cluster nodes.
|
||||
:param unit: unit pointer
|
||||
:returns: List containing node names of running nodes
|
||||
@@ -133,7 +146,9 @@ def get_cluster_running_nodes(unit):
|
||||
|
||||
|
||||
def validate_cluster_running_nodes(units):
|
||||
"""Check that all rmq unit hostnames are represented in the
|
||||
"""Check all rmq unit hostnames are represented in cluster_status.
|
||||
|
||||
Check that all rmq unit hostnames are represented in the
|
||||
cluster_status output of all units.
|
||||
:param host_names: dict of juju unit names to host names
|
||||
:param units: list of unit pointers (all rmq units)
|
||||
@@ -164,6 +179,7 @@ def validate_cluster_running_nodes(units):
|
||||
|
||||
def validate_ssl_enabled_units(units, port=None):
|
||||
"""Check that ssl is enabled on rmq juju units.
|
||||
|
||||
:param units: list of all rmq units
|
||||
:param port: optional ssl port override to validate
|
||||
:returns: None if successful, otherwise return error message
|
||||
@@ -177,6 +193,7 @@ def validate_ssl_enabled_units(units, port=None):
|
||||
|
||||
def validate_ssl_disabled_units(units):
|
||||
"""Check that ssl is enabled on listed rmq juju units.
|
||||
|
||||
:param units: list of all rmq units
|
||||
:returns: True if successful. Raise on error.
|
||||
"""
|
||||
@@ -189,7 +206,9 @@ def validate_ssl_disabled_units(units):
|
||||
|
||||
def configure_ssl_on(units, model_name=None,
|
||||
port=None, max_wait=60):
|
||||
"""Turn ssl charm config option on, with optional non-default
|
||||
"""Turn RabbitMQ charm SSL config option on.
|
||||
|
||||
Turn ssl charm config option on, with optional non-default
|
||||
ssl port specification. Confirm that it is enabled on every
|
||||
unit.
|
||||
:param units: list of units
|
||||
@@ -225,7 +244,9 @@ def configure_ssl_on(units, model_name=None,
|
||||
|
||||
|
||||
def configure_ssl_off(units, model_name=None, max_wait=60):
|
||||
"""Turn ssl charm config option off, confirm that it is disabled
|
||||
"""Turn RabbitMQ charm SSL config option off.
|
||||
|
||||
Turn ssl charm config option off, confirm that it is disabled
|
||||
on every unit.
|
||||
:param units: list of units
|
||||
:param max_wait: maximum time to wait in seconds to confirm
|
||||
@@ -294,7 +315,9 @@ def is_ssl_enabled_on_unit(unit, port=None):
|
||||
def connect_amqp_by_unit(unit, ssl=False,
|
||||
port=None, fatal=True,
|
||||
username="testuser1", password="changeme"):
|
||||
"""Establish and return a pika amqp connection to the rabbitmq service
|
||||
"""Establish and return a pika amqp connection to the rabbitmq service.
|
||||
|
||||
Establish and return a pika amqp connection to the rabbitmq service
|
||||
running on a rmq juju unit.
|
||||
:param unit: unit pointer
|
||||
:param ssl: boolean, default to False
|
||||
@@ -352,6 +375,7 @@ def publish_amqp_message_by_unit(unit, message,
|
||||
password="changeme",
|
||||
port=None):
|
||||
"""Publish an amqp message to a rmq juju unit.
|
||||
|
||||
:param unit: unit pointer
|
||||
:param message: amqp message string
|
||||
:param queue: message queue, default to test
|
||||
@@ -388,6 +412,7 @@ def get_amqp_message_by_unit(unit, queue="test",
|
||||
password="changeme",
|
||||
ssl=False, port=None):
|
||||
"""Get an amqp message from a rmq juju unit.
|
||||
|
||||
:param unit: unit pointer
|
||||
:param queue: message queue, default to test
|
||||
:param username: amqp user name, default to testuser1
|
||||
|
||||
@@ -514,8 +514,8 @@ def dist_upgrade(unit_name):
|
||||
|
||||
|
||||
def check_commands_on_units(commands, units):
|
||||
"""Check that all commands in a list exit zero on all
|
||||
units in a list.
|
||||
"""Check that all commands in a list exit zero on all units in a list.
|
||||
|
||||
:param commands: list of bash commands
|
||||
:param units: list of unit pointers
|
||||
:returns: None if successful; Failure message otherwise
|
||||
@@ -742,6 +742,7 @@ def get_ubuntu_release(ubuntu_name):
|
||||
|
||||
|
||||
def get_file_contents(unit, f):
|
||||
"""Get contents of a file on a remote unit."""
|
||||
return model.run_on_unit(unit.entity_id,
|
||||
"cat {}".format(f))['Stdout']
|
||||
|
||||
@@ -772,8 +773,9 @@ def is_port_open(port, address):
|
||||
|
||||
|
||||
def port_knock_units(units, port=22, expect_success=True):
|
||||
"""Open a TCP socket to check for a listening sevice on each
|
||||
listed juju unit.
|
||||
"""Check if specific port is open on units.
|
||||
|
||||
Open a TCP socket to check for a listening sevice on each listed juju unit.
|
||||
:param units: list of unit pointers
|
||||
:param port: TCP port number, default to 22
|
||||
:param timeout: Connect timeout, default to 15 seconds
|
||||
|
||||
Reference in New Issue
Block a user