From ab40f01982a27d3e3895949a7b2d70b3b2001b2e Mon Sep 17 00:00:00 2001 From: Peter Razumovsky Date: Thu, 24 Sep 2015 16:49:03 +0300 Subject: [PATCH] Fix [H405] pep rule in heat_integrationtests Implements bp docstring-improvements Change-Id: I7aebbdafef121c3414e6a0260452c1353af62e88 --- heat_integrationtests/common/clients.py | 3 +- heat_integrationtests/common/exceptions.py | 3 +- heat_integrationtests/common/remote_client.py | 8 ++-- heat_integrationtests/common/test.py | 6 +-- .../functional/test_autoscaling.py | 40 +++++++++++-------- .../functional/test_conditional_exposure.py | 2 +- .../functional/test_create_update.py | 11 +++-- .../functional/test_instance_group.py | 35 +++++++++------- .../functional/test_resource_group.py | 12 +++--- .../functional/test_template_resource.py | 10 ++++- .../scenario/scenario_base.py | 2 +- .../scenario/test_autoscaling_lb.py | 6 +-- .../scenario/test_server_cfn_init.py | 7 +--- .../scenario/test_server_software_config.py | 3 +- .../scenario/test_volumes.py | 7 +--- 15 files changed, 85 insertions(+), 70 deletions(-) diff --git a/heat_integrationtests/common/clients.py b/heat_integrationtests/common/clients.py index daba708835..9718d036d0 100644 --- a/heat_integrationtests/common/clients.py +++ b/heat_integrationtests/common/clients.py @@ -23,7 +23,8 @@ import swiftclient class ClientManager(object): - """ + """Provides access to the official python clients for calling various APIs. + Manager that provides access to the official python clients for calling various OpenStack APIs. """ diff --git a/heat_integrationtests/common/exceptions.py b/heat_integrationtests/common/exceptions.py index 5132850d74..b092fd062f 100644 --- a/heat_integrationtests/common/exceptions.py +++ b/heat_integrationtests/common/exceptions.py @@ -12,8 +12,7 @@ class IntegrationException(Exception): - """ - Base Tempest Exception + """Base Tempest Exception. To correctly use this class, inherit from it and define a 'message' property. That message will get printf'd diff --git a/heat_integrationtests/common/remote_client.py b/heat_integrationtests/common/remote_client.py index c8c4f95230..201b10f4ee 100644 --- a/heat_integrationtests/common/remote_client.py +++ b/heat_integrationtests/common/remote_client.py @@ -88,8 +88,7 @@ class Client(object): return (time.time() - self.timeout) > start_time def exec_command(self, cmd): - """ - Execute the specified command on the server. + """Execute the specified command on the server. Note that this method is reading whole command outputs to memory, thus shouldn't be used for large outputs. @@ -170,8 +169,9 @@ class RemoteClient(object): return self.ssh_client.exec_command(cmd) def validate_authentication(self): - """Validate ssh connection and authentication - This method raises an Exception when the validation fails. + """Validate ssh connection and authentication. + + This method raises an Exception when the validation fails. """ self.ssh_client.test_connection_auth() diff --git a/heat_integrationtests/common/test.py b/heat_integrationtests/common/test.py index 4f3d923ea8..8d8fa15c39 100644 --- a/heat_integrationtests/common/test.py +++ b/heat_integrationtests/common/test.py @@ -35,7 +35,8 @@ _LOG_FORMAT = "%(levelname)8s [%(name)s] %(message)s" def call_until_true(duration, sleep_for, func, *args, **kwargs): - """ + """Call the function until it returns True or the duration elapsed. + Call the given function until it returns True (and return True) or until the specified duration (in seconds) elapses (and return False). @@ -281,8 +282,7 @@ class HeatIntegrationTest(testscenarios.WithScenarios, def _wait_for_stack_status(self, stack_identifier, status, failure_pattern=None, success_on_not_found=False): - """ - Waits for a Stack to reach a given status. + """Waits for a Stack to reach a given status. Note this compares the full $action_$status, e.g CREATE_COMPLETE, not just COMPLETE which is exposed diff --git a/heat_integrationtests/functional/test_autoscaling.py b/heat_integrationtests/functional/test_autoscaling.py index 90414051d1..5c2d1aff6b 100644 --- a/heat_integrationtests/functional/test_autoscaling.py +++ b/heat_integrationtests/functional/test_autoscaling.py @@ -189,7 +189,9 @@ class AutoscalingGroupBasicTest(AutoscalingGroupTest): self.assert_instance_count(stack, 5) def test_update_group_replace(self): - """Make sure that during a group update the non updatable + """Test case for ensuring non-updatable props case a replacement. + + Make sure that during a group update the non-updatable properties cause a replacement. """ files = {'provider.yaml': self.instance_template} @@ -219,7 +221,9 @@ class AutoscalingGroupBasicTest(AutoscalingGroupTest): self.assertNotEqual(orig_asg_id, rsrc.physical_resource_id) def test_create_instance_error_causes_group_error(self): - """If a resource in an instance group fails to be created, the instance + """Test create failing a resource in the instance group. + + If a resource in an instance group fails to be created, the instance group itself will fail and the broken inner resource will remain. """ stack_name = self._stack_rand_name() @@ -252,7 +256,9 @@ class AutoscalingGroupBasicTest(AutoscalingGroupTest): self._assert_instance_state(nested_ident, 0, 2) def test_update_instance_error_causes_group_error(self): - """If a resource in an instance group fails to be created during an + """Test update failing a resource in the instance group. + + If a resource in an instance group fails to be created during an update, the instance group itself will fail and the broken inner resource will remain. """ @@ -408,9 +414,10 @@ class AutoscalingGroupUpdatePolicyTest(AutoscalingGroupTest): self.assertNotIn(deletes_expected, updt_names) def test_instance_group_update_replace(self): - """ - Test simple update replace with no conflict in batch size and - minimum instances in service. + """Test simple update replace. + + Test update replace with no conflict in batch size and minimum + instances in service. """ updt_template = self.ig_tmpl_with_updt_policy() grp = updt_template['Resources']['JobServerGroup'] @@ -427,9 +434,10 @@ class AutoscalingGroupUpdatePolicyTest(AutoscalingGroupTest): update_replace=True) def test_instance_group_update_replace_with_adjusted_capacity(self): - """ - Test update replace with capacity adjustment due to conflict in - batch size and minimum instances in service. + """Test update replace with capacity adjustment. + + Test update replace with capacity adjustment due to conflict in batch + size and minimum instances in service. """ updt_template = self.ig_tmpl_with_updt_policy() grp = updt_template['Resources']['JobServerGroup'] @@ -446,9 +454,7 @@ class AutoscalingGroupUpdatePolicyTest(AutoscalingGroupTest): update_replace=True) def test_instance_group_update_replace_huge_batch_size(self): - """ - Test update replace with a huge batch size. - """ + """Test update replace with a huge batch size.""" updt_template = self.ig_tmpl_with_updt_policy() group = updt_template['Resources']['JobServerGroup'] policy = group['UpdatePolicy']['AutoScalingRollingUpdate'] @@ -464,9 +470,7 @@ class AutoscalingGroupUpdatePolicyTest(AutoscalingGroupTest): update_replace=True) def test_instance_group_update_replace_huge_min_in_service(self): - """ - Test update replace with a huge number of minimum instances in service. - """ + """Update replace with huge number of minimum instances in service.""" updt_template = self.ig_tmpl_with_updt_policy() group = updt_template['Resources']['JobServerGroup'] policy = group['UpdatePolicy']['AutoScalingRollingUpdate'] @@ -483,7 +487,8 @@ class AutoscalingGroupUpdatePolicyTest(AutoscalingGroupTest): update_replace=True) def test_instance_group_update_no_replace(self): - """ + """Test simple update only and no replace. + Test simple update only and no replace (i.e. updated instance flavor in Launch Configuration) with no conflict in batch size and minimum instances in service. @@ -504,7 +509,8 @@ class AutoscalingGroupUpdatePolicyTest(AutoscalingGroupTest): update_replace=False) def test_instance_group_update_no_replace_with_adjusted_capacity(self): - """ + """Test update only and no replace with capacity adjustment. + Test update only and no replace (i.e. updated instance flavor in Launch Configuration) with capacity adjustment due to conflict in batch size and minimum instances in service. diff --git a/heat_integrationtests/functional/test_conditional_exposure.py b/heat_integrationtests/functional/test_conditional_exposure.py index d03771235f..90f7d7aa49 100644 --- a/heat_integrationtests/functional/test_conditional_exposure.py +++ b/heat_integrationtests/functional/test_conditional_exposure.py @@ -82,7 +82,7 @@ resources: """ def test_non_admin_forbidden_create_flavors(self): - """Fail to create Flavor resource w/o admin role + """Fail to create Flavor resource w/o admin role. Integration tests job runs as normal OpenStack user, and OS::Nova:Flavor is configured to require diff --git a/heat_integrationtests/functional/test_create_update.py b/heat_integrationtests/functional/test_create_update.py index 4597d4ccb7..153eb9fc0e 100644 --- a/heat_integrationtests/functional/test_create_update.py +++ b/heat_integrationtests/functional/test_create_update.py @@ -332,7 +332,8 @@ resources: self.list_resources(nested_identifier)) def test_stack_update_provider_group(self): - '''Test two-level nested update.''' + """Test two-level nested update.""" + # Create a ResourceGroup (which creates a nested stack), # containing provider resources (which create a nested # stack), thus exercising an update which traverses @@ -403,10 +404,12 @@ resources: self.list_resources(provider_identifier)) def test_stack_update_with_replacing_userdata(self): - """Confirm that we can update userdata of instance during updating - stack by the user of member role. + """Test case for updating userdata of instance. - Make sure that a resource that inherites from StackUser can be deleted + Confirm that we can update userdata of instance during updating stack + by the user of member role. + + Make sure that a resource that inherits from StackUser can be deleted during updating stack. """ if not self.conf.minimal_image_ref: diff --git a/heat_integrationtests/functional/test_instance_group.py b/heat_integrationtests/functional/test_instance_group.py index b8bcc3d985..02a2858440 100644 --- a/heat_integrationtests/functional/test_instance_group.py +++ b/heat_integrationtests/functional/test_instance_group.py @@ -131,6 +131,7 @@ class InstanceGroupBasicTest(InstanceGroupTest): def test_basic_create_works(self): """Make sure the working case is good. + Note this combines test_override_aws_ec2_instance into this test as well, which is: If AWS::EC2::Instance is overridden, InstanceGroup will automatically @@ -177,8 +178,10 @@ class InstanceGroupBasicTest(InstanceGroupTest): self.assert_instance_count(stack, 5) def test_update_group_replace(self): - """Make sure that during a group update the non updatable - properties cause a replacement. + """Test case for ensuring non-updatable props case a replacement. + + Make sure that during a group update the non-updatable properties cause + a replacement. """ files = {'provider.yaml': self.instance_template} env = {'resource_registry': @@ -207,7 +210,9 @@ class InstanceGroupBasicTest(InstanceGroupTest): self.assertNotEqual(orig_asg_id, rsrc.physical_resource_id) def test_create_instance_error_causes_group_error(self): - """If a resource in an instance group fails to be created, the instance + """Test create failing a resource in the instance group. + + If a resource in an instance group fails to be created, the instance group itself will fail and the broken inner resource will remain. """ stack_name = self._stack_rand_name() @@ -240,7 +245,9 @@ class InstanceGroupBasicTest(InstanceGroupTest): self._assert_instance_state(nested_ident, 0, 2) def test_update_instance_error_causes_group_error(self): - """If a resource in an instance group fails to be created during an + """Test update failing a resource in the instance group. + + If a resource in an instance group fails to be created during an update, the instance group itself will fail and the broken inner resource will remain. """ @@ -376,7 +383,8 @@ class InstanceGroupUpdatePolicyTest(InstanceGroupTest): self.assertNotIn(deletes_expected, updt_names) def test_instance_group_update_replace(self): - """ + """Test simple update replace with no conflict. + Test simple update replace with no conflict in batch size and minimum instances in service. """ @@ -395,7 +403,8 @@ class InstanceGroupUpdatePolicyTest(InstanceGroupTest): update_replace=True) def test_instance_group_update_replace_with_adjusted_capacity(self): - """ + """Test update replace with capacity adjustment. + Test update replace with capacity adjustment due to conflict in batch size and minimum instances in service. """ @@ -414,9 +423,7 @@ class InstanceGroupUpdatePolicyTest(InstanceGroupTest): update_replace=True) def test_instance_group_update_replace_huge_batch_size(self): - """ - Test update replace with a huge batch size. - """ + """Test update replace with a huge batch size.""" updt_template = self.ig_tmpl_with_updt_policy() group = updt_template['Resources']['JobServerGroup'] policy = group['UpdatePolicy']['RollingUpdate'] @@ -432,9 +439,7 @@ class InstanceGroupUpdatePolicyTest(InstanceGroupTest): update_replace=True) def test_instance_group_update_replace_huge_min_in_service(self): - """ - Test update replace with a huge number of minimum instances in service. - """ + """Update replace with huge number of minimum instances in service.""" updt_template = self.ig_tmpl_with_updt_policy() group = updt_template['Resources']['JobServerGroup'] policy = group['UpdatePolicy']['RollingUpdate'] @@ -451,7 +456,8 @@ class InstanceGroupUpdatePolicyTest(InstanceGroupTest): update_replace=True) def test_instance_group_update_no_replace(self): - """ + """Test simple update only and no replace with no conflict. + Test simple update only and no replace (i.e. updated instance flavor in Launch Configuration) with no conflict in batch size and minimum instances in service. @@ -472,7 +478,8 @@ class InstanceGroupUpdatePolicyTest(InstanceGroupTest): update_replace=False) def test_instance_group_update_no_replace_with_adjusted_capacity(self): - """ + """Test update only and no replace with capacity adjustment. + Test update only and no replace (i.e. updated instance flavor in Launch Configuration) with capacity adjustment due to conflict in batch size and minimum instances in service. diff --git a/heat_integrationtests/functional/test_resource_group.py b/heat_integrationtests/functional/test_resource_group.py index 53352451b7..4fd70af614 100644 --- a/heat_integrationtests/functional/test_resource_group.py +++ b/heat_integrationtests/functional/test_resource_group.py @@ -267,11 +267,13 @@ resources: self.assertEqual(initial_rand, updated_rand) def test_update_nochange_resource_needs_update(self): - """Test update when the resource definition has changed.""" - # Test the scenario when the ResourceGroup update happens without - # any changed properties, this can happen if the definition of - # a contained provider resource changes (files map changes), then - # the group and underlying nested stack should end up updated. + """Test update when the resource definition has changed. + + Test the scenario when the ResourceGroup update happens without + any changed properties, this can happen if the definition of + a contained provider resource changes (files map changes), then + the group and underlying nested stack should end up updated. + """ random_templ1 = ''' heat_template_version: 2013-05-23 diff --git a/heat_integrationtests/functional/test_template_resource.py b/heat_integrationtests/functional/test_template_resource.py index 9609664a44..dabc9243af 100644 --- a/heat_integrationtests/functional/test_template_resource.py +++ b/heat_integrationtests/functional/test_template_resource.py @@ -195,9 +195,12 @@ outputs: self.assertIn('arn:openstack:heat:', test_ref) def test_transparent_ref(self): - """With the addition of OS::stack_id we can now use the nested resource + """Test using nested resource more transparently. + + With the addition of OS::stack_id we can now use the nested resource more transparently. """ + nested_templ = ''' heat_template_version: 2014-10-16 resources: @@ -520,6 +523,7 @@ Outputs: class TemplateResourceUpdateFailedTest(functional_base.FunctionalTestsBase): """Prove that we can do updates on a nested stack to fix a stack.""" + main_template = ''' HeatTemplateFormatVersion: '2012-12-12' Resources: @@ -688,6 +692,7 @@ Outputs: class TemplateResourceErrorMessageTest(functional_base.FunctionalTestsBase): """Prove that nested stack errors don't suck.""" + template = ''' HeatTemplateFormatVersion: '2012-12-12' Resources: @@ -743,7 +748,7 @@ resources: super(TemplateResourceSuspendResumeTest, self).setUp() def test_suspend_resume(self): - """Basic test for template resource suspend resume""" + """Basic test for template resource suspend resume.""" stack_identifier = self.stack_create( template=self.main_template, files={'the.yaml': self.nested_templ} @@ -755,6 +760,7 @@ resources: class ValidateFacadeTest(test.HeatIntegrationTest): """Prove that nested stack errors don't suck.""" + template = ''' heat_template_version: 2015-10-15 resources: diff --git a/heat_integrationtests/scenario/scenario_base.py b/heat_integrationtests/scenario/scenario_base.py index 84e14a9195..14b8cec4b4 100644 --- a/heat_integrationtests/scenario/scenario_base.py +++ b/heat_integrationtests/scenario/scenario_base.py @@ -14,7 +14,7 @@ from heat_integrationtests.common import test class ScenarioTestsBase(test.HeatIntegrationTest): - "This class define common parameters for scenario tests" + """This class defines common parameters for scenario tests.""" def setUp(self): super(ScenarioTestsBase, self).setUp() diff --git a/heat_integrationtests/scenario/test_autoscaling_lb.py b/heat_integrationtests/scenario/test_autoscaling_lb.py index 21b27dd526..1d4d41d7f7 100644 --- a/heat_integrationtests/scenario/test_autoscaling_lb.py +++ b/heat_integrationtests/scenario/test_autoscaling_lb.py @@ -20,8 +20,7 @@ from heat_integrationtests.scenario import scenario_base class AutoscalingLoadBalancerTest(scenario_base.ScenarioTestsBase): - """ - The class is responsible for testing ASG + LB scenario. + """The class is responsible for testing ASG + LB scenario. The very common use case tested is an autoscaling group of some web application servers behind a loadbalancer. @@ -52,8 +51,7 @@ class AutoscalingLoadBalancerTest(scenario_base.ScenarioTestsBase): return all_res and all_res_complete def test_autoscaling_loadbalancer_neutron(self): - """ - Check work of AutoScaing and Neutron LBaaS resource in Heat. + """Check work of AutoScaing and Neutron LBaaS resource in Heat. The scenario is the following: 1. Launch a stack with a load balancer and autoscaling group diff --git a/heat_integrationtests/scenario/test_server_cfn_init.py b/heat_integrationtests/scenario/test_server_cfn_init.py index 267b44b8ea..d3ee7ee9bb 100644 --- a/heat_integrationtests/scenario/test_server_cfn_init.py +++ b/heat_integrationtests/scenario/test_server_cfn_init.py @@ -17,9 +17,7 @@ from heat_integrationtests.scenario import scenario_base class CfnInitIntegrationTest(scenario_base.ScenarioTestsBase): - """ - The class is responsible for testing cfn-init and cfn-signal workability - """ + """Testing cfn-init and cfn-signal workability.""" def setUp(self): super(CfnInitIntegrationTest, self).setUp() @@ -94,8 +92,7 @@ class CfnInitIntegrationTest(scenario_base.ScenarioTestsBase): raise e def test_server_cfn_init(self): - """ - Check cfn-init and cfn-signal availability on the created server. + """Check cfn-init and cfn-signal availability on the created server. The alternative scenario is the following: 1. Create a stack with a server and configured security group. diff --git a/heat_integrationtests/scenario/test_server_software_config.py b/heat_integrationtests/scenario/test_server_software_config.py index 8739a994c2..ad767633ed 100644 --- a/heat_integrationtests/scenario/test_server_software_config.py +++ b/heat_integrationtests/scenario/test_server_software_config.py @@ -133,8 +133,7 @@ class SoftwareConfigIntegrationTest(scenario_base.ScenarioTestsBase): dep1_dep.creation_time) def test_server_software_config(self): - """ - Check that passed files with scripts are executed on created server. + """Check that passed files with scripts are executed on created server. The alternative scenario is the following: 1. Create a stack and pass files with scripts. diff --git a/heat_integrationtests/scenario/test_volumes.py b/heat_integrationtests/scenario/test_volumes.py index d4b1aa864a..7980d81db3 100644 --- a/heat_integrationtests/scenario/test_volumes.py +++ b/heat_integrationtests/scenario/test_volumes.py @@ -22,9 +22,7 @@ LOG = logging.getLogger(__name__) class VolumeBackupRestoreIntegrationTest(scenario_base.ScenarioTestsBase): - """ - Class is responsible for testing of volume backup. - """ + """Class is responsible for testing of volume backup.""" def setUp(self): super(VolumeBackupRestoreIntegrationTest, self).setUp() @@ -101,8 +99,7 @@ class VolumeBackupRestoreIntegrationTest(scenario_base.ScenarioTestsBase): volume_id2) def test_cinder_volume_create_backup_restore(self): - """ - Ensure the 'Snapshot' deletion policy works. + """Ensure the 'Snapshot' deletion policy works. This requires a more complex test, but it tests several aspects of the heat cinder resources: