Fix H404/405 violations for thirdparty and stress
There is a lot of H404/405 violations in Tempest now, and that leads difficult to migrate the code to tempest-lib or the other projects' repos. This patch fixes these violations for thirdparty and stress. Change-Id: I467b2c4f12459d80b532d34c56731996603d4aeb
This commit is contained in:
parent
c864f59913
commit
0afa8819e4
@ -35,6 +35,7 @@ class SetUpClassRunTime(object):
|
||||
|
||||
class UnitTest(stressaction.StressAction):
|
||||
"""This is a special action for running existing unittests as stress test.
|
||||
|
||||
You need to pass ``test_method`` and ``class_setup_per``
|
||||
using ``kwargs`` in the JSON descriptor;
|
||||
``test_method`` should be the fully qualified name of a unittest,
|
||||
|
@ -121,6 +121,7 @@ class VolumeVerifyStress(stressaction.StressAction):
|
||||
|
||||
def setUp(self, **kwargs):
|
||||
"""Note able configuration combinations:
|
||||
|
||||
Closest options to the test_stamp_pattern:
|
||||
new_server = True
|
||||
new_volume = True
|
||||
|
@ -49,9 +49,9 @@ def do_ssh(command, host, ssh_user, ssh_key=None):
|
||||
|
||||
|
||||
def _get_compute_nodes(controller, ssh_user, ssh_key=None):
|
||||
"""
|
||||
Returns a list of active compute nodes. List is generated by running
|
||||
nova-manage on the controller.
|
||||
"""Returns a list of active compute nodes.
|
||||
|
||||
List is generated by running nova-manage on the controller.
|
||||
"""
|
||||
nodes = []
|
||||
cmd = "nova-manage service list | grep ^nova-compute"
|
||||
@ -69,9 +69,7 @@ def _get_compute_nodes(controller, ssh_user, ssh_key=None):
|
||||
|
||||
def _has_error_in_logs(logfiles, nodes, ssh_user, ssh_key=None,
|
||||
stop_on_error=False):
|
||||
"""
|
||||
Detect errors in the nova log files on the controller and compute nodes.
|
||||
"""
|
||||
"""Detect errors in nova log files on the controller and compute nodes."""
|
||||
grep = 'egrep "ERROR|TRACE" %s' % logfiles
|
||||
ret = False
|
||||
for node in nodes:
|
||||
@ -85,9 +83,7 @@ def _has_error_in_logs(logfiles, nodes, ssh_user, ssh_key=None,
|
||||
|
||||
|
||||
def sigchld_handler(signalnum, frame):
|
||||
"""
|
||||
Signal handler (only active if stop_on_error is True).
|
||||
"""
|
||||
"""Signal handler (only active if stop_on_error is True)."""
|
||||
for process in processes:
|
||||
if (not process['process'].is_alive() and
|
||||
process['process'].exitcode != 0):
|
||||
@ -97,9 +93,7 @@ def sigchld_handler(signalnum, frame):
|
||||
|
||||
|
||||
def terminate_all_processes(check_interval=20):
|
||||
"""
|
||||
Goes through the process list and terminates all child processes.
|
||||
"""
|
||||
"""Goes through the process list and terminates all child processes."""
|
||||
LOG.info("Stopping all processes.")
|
||||
for process in processes:
|
||||
if process['process'].is_alive():
|
||||
@ -120,9 +114,7 @@ def terminate_all_processes(check_interval=20):
|
||||
|
||||
|
||||
def stress_openstack(tests, duration, max_runs=None, stop_on_error=False):
|
||||
"""
|
||||
Workload driver. Executes an action function against a nova-cluster.
|
||||
"""
|
||||
"""Workload driver. Executes an action function against a nova-cluster."""
|
||||
admin_manager = credentials.AdminManager()
|
||||
|
||||
ssh_user = CONF.stress.target_ssh_user
|
||||
|
@ -40,32 +40,35 @@ class StressAction(object):
|
||||
|
||||
@property
|
||||
def action(self):
|
||||
"""This methods returns the action. Overload this if you
|
||||
create a stress test wrapper.
|
||||
"""This methods returns the action.
|
||||
|
||||
Overload this if you create a stress test wrapper.
|
||||
"""
|
||||
return self.__class__.__name__
|
||||
|
||||
def setUp(self, **kwargs):
|
||||
"""This method is called before the run method
|
||||
to help the test initialize any structures.
|
||||
kwargs contains arguments passed in from the
|
||||
configuration json file.
|
||||
"""Initialize test structures/resources
|
||||
|
||||
This method is called before "run" method to help the test
|
||||
initialize any structures. kwargs contains arguments passed
|
||||
in from the configuration json file.
|
||||
|
||||
setUp doesn't count against the time duration.
|
||||
"""
|
||||
self.logger.debug("setUp")
|
||||
|
||||
def tearDown(self):
|
||||
"""This method is called to do any cleanup
|
||||
after the test is complete.
|
||||
"""Cleanup test structures/resources
|
||||
|
||||
This method is called to do any cleanup after the test is complete.
|
||||
"""
|
||||
self.logger.debug("tearDown")
|
||||
|
||||
def execute(self, shared_statistic):
|
||||
"""This is the main execution entry point called
|
||||
by the driver. We register a signal handler to
|
||||
allow us to tearDown gracefully, and then exit.
|
||||
We also keep track of how many runs we do.
|
||||
"""This is the main execution entry point called by the driver.
|
||||
|
||||
We register a signal handler to allow us to tearDown gracefully,
|
||||
and then exit. We also keep track of how many runs we do.
|
||||
"""
|
||||
signal.signal(signal.SIGHUP, self._shutdown_handler)
|
||||
signal.signal(signal.SIGTERM, self._shutdown_handler)
|
||||
|
26
tempest/thirdparty/boto/test.py
vendored
26
tempest/thirdparty/boto/test.py
vendored
@ -110,8 +110,10 @@ class BotoExceptionMatcher(object):
|
||||
CODE_RE = '.*' # regexp makes sense in group match
|
||||
|
||||
def match(self, exc):
|
||||
""":returns: Returns with an error string if it does not match,
|
||||
returns with None when it matches.
|
||||
"""Check boto exception
|
||||
|
||||
:returns: Returns with an error string if it does not match,
|
||||
returns with None when it matches.
|
||||
"""
|
||||
if not isinstance(exc, exception.BotoServerError):
|
||||
return "%r not an BotoServerError instance" % exc
|
||||
@ -136,9 +138,9 @@ class ServerError(BotoExceptionMatcher):
|
||||
|
||||
|
||||
def _add_matcher_class(error_cls, error_data, base=BotoExceptionMatcher):
|
||||
"""
|
||||
Usable for adding an ExceptionMatcher(s) into the exception tree.
|
||||
The not leaf elements does wildcard match
|
||||
"""Usable for adding an ExceptionMatcher(s) into the exception tree.
|
||||
|
||||
The not leaf elements does wildcard match
|
||||
"""
|
||||
# in error_code just literal and '.' characters expected
|
||||
if not isinstance(error_data, six.string_types):
|
||||
@ -227,6 +229,7 @@ class BotoTestCase(tempest.test.BaseTestCase):
|
||||
@classmethod
|
||||
def addResourceCleanUp(cls, function, *args, **kwargs):
|
||||
"""Adds CleanUp callable, used by tearDownClass.
|
||||
|
||||
Recommended to a use (deep)copy on the mutable args.
|
||||
"""
|
||||
cls._sequence = cls._sequence + 1
|
||||
@ -242,6 +245,7 @@ class BotoTestCase(tempest.test.BaseTestCase):
|
||||
def assertBotoError(self, excMatcher, callableObj,
|
||||
*args, **kwargs):
|
||||
"""Example usage:
|
||||
|
||||
self.assertBotoError(self.ec2_error_code.client.
|
||||
InvalidKeyPair.Duplicate,
|
||||
self.client.create_keypair,
|
||||
@ -258,7 +262,8 @@ class BotoTestCase(tempest.test.BaseTestCase):
|
||||
|
||||
@classmethod
|
||||
def resource_cleanup(cls):
|
||||
"""Calls the callables added by addResourceCleanUp,
|
||||
"""Calls the callables added by addResourceCleanUp
|
||||
|
||||
when you overwrite this function don't forget to call this too.
|
||||
"""
|
||||
fail_count = 0
|
||||
@ -302,10 +307,9 @@ class BotoTestCase(tempest.test.BaseTestCase):
|
||||
|
||||
@classmethod
|
||||
def get_lfunction_gone(cls, obj):
|
||||
"""If the object is instance of a well know type returns back with
|
||||
with the corresponding function otherwise it assumes the obj itself
|
||||
is the function.
|
||||
"""
|
||||
# NOTE: If the object is instance of a well know type returns back with
|
||||
# with the corresponding function otherwise it assumes the obj itself
|
||||
# is the function.
|
||||
ec = cls.ec2_error_code
|
||||
if isinstance(obj, ec2.instance.Instance):
|
||||
colusure_matcher = ec.client.InvalidInstanceID.NotFound
|
||||
@ -489,6 +493,7 @@ class BotoTestCase(tempest.test.BaseTestCase):
|
||||
@classmethod
|
||||
def destroy_security_group_wait(cls, group):
|
||||
"""Delete group.
|
||||
|
||||
Use just for teardown!
|
||||
"""
|
||||
# NOTE(afazekas): should wait/try until all related instance terminates
|
||||
@ -497,6 +502,7 @@ class BotoTestCase(tempest.test.BaseTestCase):
|
||||
@classmethod
|
||||
def destroy_volume_wait(cls, volume):
|
||||
"""Delete volume, tries to detach first.
|
||||
|
||||
Use just for teardown!
|
||||
"""
|
||||
exc_num = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user