diff --git a/tempest/stress/actions/unit_test.py b/tempest/stress/actions/unit_test.py index c3766932fb..3b27885718 100644 --- a/tempest/stress/actions/unit_test.py +++ b/tempest/stress/actions/unit_test.py @@ -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, diff --git a/tempest/stress/actions/volume_attach_verify.py b/tempest/stress/actions/volume_attach_verify.py index 4840383b88..fa0bb8b018 100644 --- a/tempest/stress/actions/volume_attach_verify.py +++ b/tempest/stress/actions/volume_attach_verify.py @@ -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 diff --git a/tempest/stress/driver.py b/tempest/stress/driver.py index eec52cb9c4..8359efd92b 100644 --- a/tempest/stress/driver.py +++ b/tempest/stress/driver.py @@ -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 diff --git a/tempest/stress/stressaction.py b/tempest/stress/stressaction.py index a3d0d17446..c8bd652a81 100644 --- a/tempest/stress/stressaction.py +++ b/tempest/stress/stressaction.py @@ -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) diff --git a/tempest/thirdparty/boto/test.py b/tempest/thirdparty/boto/test.py index 05c47bb4cd..cfd3747678 100644 --- a/tempest/thirdparty/boto/test.py +++ b/tempest/thirdparty/boto/test.py @@ -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