From 1a4decc02fc2a45e6fdff2c9ce01b9a298b12ed5 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Wed, 19 Dec 2012 13:45:21 +0000 Subject: [PATCH] heat cleanups to align functional tests with pep8 1.3.4 Lots of (mostly whitespace) cleanups to align all the functional test code with pep8 v1.3.4 ref bug 1092057 Change-Id: Ifd6ef02bf3abd0b2f351f63423ab8aa7ff0cbd7c Signed-off-by: Steven Hardy --- .../test_AutoScalingMultiAZSample.py | 2 +- heat/tests/functional/test_CFN_API_Actions.py | 116 +++++++++--------- .../functional/test_CFN_API_Actions_Boto.py | 62 +++++----- .../functional/test_CFN_API_UpdateStack.py | 12 +- .../test_HAProxy_Single_Instance.py | 4 +- .../test_OpenShift_Prebuilt_JEOS.py | 2 +- .../functional/test_WordPress_2_Instances.py | 6 +- .../test_WordPress_2_Instances_With_EBS.py | 8 +- ...test_WordPress_2_Instances_With_EBS_EIP.py | 15 ++- .../test_WordPress_Composed_Instances.py | 11 +- .../test_WordPress_Single_Instance.py | 2 +- .../test_WordPress_Single_Instance_Boto.py | 4 +- ...test_WordPress_Single_Instance_With_EBS.py | 8 +- ..._WordPress_Single_Instance_With_EBS_EIP.py | 8 +- ...test_WordPress_Single_Instance_With_EIP.py | 6 +- .../test_WordPress_Single_Instance_With_HA.py | 6 +- ...test_WordPress_Single_Instance_With_IHA.py | 6 +- .../functional/test_WordPress_With_LB.py | 11 +- .../functional/test_WordPress_With_RDS.py | 6 +- heat/tests/functional/util.py | 82 ++++++++----- 20 files changed, 200 insertions(+), 177 deletions(-) diff --git a/heat/tests/functional/test_AutoScalingMultiAZSample.py b/heat/tests/functional/test_AutoScalingMultiAZSample.py index 151a1cf5..ff7de037 100644 --- a/heat/tests/functional/test_AutoScalingMultiAZSample.py +++ b/heat/tests/functional/test_AutoScalingMultiAZSample.py @@ -31,7 +31,7 @@ class AutoScalingMultiAZSampleFunctionalTest(unittest.TestCase): 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.Stack(self, template, 'F17', 'x86_64', 'cfntools', - stack_paramstr) + stack_paramstr) self.WebServerGroup0 = util.Instance(self, 'WebServerGroup-0') def tearDown(self): diff --git a/heat/tests/functional/test_CFN_API_Actions.py b/heat/tests/functional/test_CFN_API_Actions.py index fda59e01..75ce1802 100644 --- a/heat/tests/functional/test_CFN_API_Actions.py +++ b/heat/tests/functional/test_CFN_API_Actions.py @@ -62,7 +62,7 @@ class CfnApiFunctionalTest(unittest.TestCase): inst = CfnApiFunctions() cls.stack = util.Stack(inst, template, 'F17', 'x86_64', 'cfntools', - stack_paramstr) + stack_paramstr) cls.WikiDatabase = util.Instance(inst, cls.logical_resource_name) try: @@ -119,15 +119,15 @@ class CfnApiFunctionalTest(unittest.TestCase): update_time = self.stack.response_xml_item(response, prefix, "LastUpdatedTime") - self.assertTrue(self.time_re.match(update_time) != None) + self.assertTrue(self.time_re.match(update_time) is not None) create_time = self.stack.response_xml_item(response, prefix, "CreationTime") - self.assertTrue(self.time_re.match(create_time) != None) + self.assertTrue(self.time_re.match(create_time) is not None) description = self.stack.response_xml_item(response, prefix, "TemplateDescription") - self.assertTrue(self.description_re.match(description) != None) + self.assertTrue(self.description_re.match(description) is not None) status_reason = self.stack.response_xml_item(response, prefix, "StackStatusReason") @@ -154,15 +154,15 @@ class CfnApiFunctionalTest(unittest.TestCase): update_time = self.stack.response_xml_item(response, prefix, "LastUpdatedTime") - self.assertTrue(self.time_re.match(update_time) != None) + self.assertTrue(self.time_re.match(update_time) is not None) create_time = self.stack.response_xml_item(response, prefix, "CreationTime") - self.assertTrue(self.time_re.match(create_time) != None) + self.assertTrue(self.time_re.match(create_time) is not None) description = self.stack.response_xml_item(response, prefix, "Description") - self.assertTrue(self.description_re.match(description) != None) + self.assertTrue(self.description_re.match(description) is not None) status_reason = self.stack.response_xml_item(response, prefix, "StackStatusReason") @@ -181,18 +181,18 @@ class CfnApiFunctionalTest(unittest.TestCase): self.assertEqual(stack_timeout, self.stack_timeout) disable_rollback = self.stack.response_xml_item(response, prefix, - "DisableRollback") + "DisableRollback") self.assertEqual(disable_rollback, self.stack_disable_rollback) # Create a dict to lookup the expected template parameters template_parameters = {'DBUsername': 'dbuser', - 'LinuxDistribution': 'F17', - 'InstanceType': 'm1.xlarge', - 'DBRootPassword': 'admin', - 'KeyName': self.stack.keyname, - 'DBPassword': - os.environ['OS_PASSWORD'], - 'DBName': 'wordpress'} + 'LinuxDistribution': 'F17', + 'InstanceType': 'm1.xlarge', + 'DBRootPassword': 'admin', + 'KeyName': self.stack.keyname, + 'DBPassword': + os.environ['OS_PASSWORD'], + 'DBName': 'wordpress'} # We do a fully qualified xpath lookup to extract the paramter # value for each key, then check the extracted value @@ -201,8 +201,8 @@ class CfnApiFunctionalTest(unittest.TestCase): lookup = '[ParameterKey="' + key + '" and ParameterValue="' +\ value + '"]' lookup_value = self.stack.response_xml_item(response, - param_prefix + lookup, - "ParameterValue") + param_prefix + lookup, + "ParameterValue") self.assertEqual(lookup_value, value) # Then to a similar lookup to verify the Outputs section @@ -212,8 +212,8 @@ class CfnApiFunctionalTest(unittest.TestCase): lookup = '[OutputKey="WebsiteURL" and OutputValue="' + expected_url +\ '" and Description="URL for Wordpress wiki"]' lookup_value = self.stack.response_xml_item(response, - outputs_prefix + lookup, - "OutputValue") + outputs_prefix + lookup, + "OutputValue") self.assertEqual(lookup_value, expected_url) print "DescribeStacks : OK" @@ -223,30 +223,30 @@ class CfnApiFunctionalTest(unittest.TestCase): parameters['StackName'] = self.stack.stackname response = self.stack.heatclient.list_stack_events(**parameters) prefix = '/DescribeStackEventsResponse/DescribeStackEventsResult/' +\ - 'StackEvents/member[LogicalResourceId="' +\ - self.logical_resource_name + '" and ResourceStatus="' +\ - self.logical_resource_status + '"]' + 'StackEvents/member[LogicalResourceId="' +\ + self.logical_resource_name + '" and ResourceStatus="' +\ + self.logical_resource_status + '"]' stack_id = self.stack.response_xml_item(response, prefix, "StackId") self.stack.check_stackid(stack_id) event_id = self.stack.response_xml_item(response, prefix, "EventId") - self.assertTrue(re.match("[0-9]*$", event_id) != None) + self.assertTrue(re.match("[0-9]*$", event_id) is not None) resource_status = self.stack.response_xml_item(response, prefix, - "ResourceStatus") + "ResourceStatus") self.assertEqual(resource_status, self.logical_resource_status) resource_type = self.stack.response_xml_item(response, prefix, - "ResourceType") + "ResourceType") self.assertEqual(resource_type, self.logical_resource_type) update_time = self.stack.response_xml_item(response, prefix, "Timestamp") - self.assertTrue(self.time_re.match(update_time) != None) + self.assertTrue(self.time_re.match(update_time) is not None) status_data = self.stack.response_xml_item(response, prefix, - "ResourceStatusReason") + "ResourceStatusReason") self.assertEqual(status_data, "state changed") stack_name = self.stack.response_xml_item(response, prefix, @@ -258,14 +258,14 @@ class CfnApiFunctionalTest(unittest.TestCase): self.assertEqual(log_res_id, self.logical_resource_name) phys_res_id = self.stack.response_xml_item(response, prefix, - "PhysicalResourceId") - self.assertTrue(self.phys_res_id_re.match(phys_res_id) != None) + "PhysicalResourceId") + self.assertTrue(self.phys_res_id_re.match(phys_res_id) is not None) # ResourceProperties format is defined as a string "blob" by AWS # we return JSON encoded properies, so decode and check one key prop_json = self.stack.response_xml_item(response, prefix, - "ResourceProperties") - self.assertTrue(prop_json != None) + "ResourceProperties") + self.assertTrue(prop_json is not None) prop = json.loads(prop_json) self.assertEqual(prop["InstanceType"], "m1.xlarge") @@ -282,40 +282,40 @@ class CfnApiFunctionalTest(unittest.TestCase): template = self.stack.response_xml_item(response, prefix, "TemplateBody") json_load = template_format.parse(template) - self.assertTrue(json_load != None) + self.assertTrue(json_load is not None) # Then sanity check content - I guess we could diff # with the template file but for now just check the # description looks sane.. description = json_load['Description'] - self.assertTrue(self.description_re.match(description) != None) + self.assertTrue(self.description_re.match(description) is not None) print "GetTemplate : OK" def testDescribeStackResource(self): parameters = {'StackName': self.stack.stackname, - 'LogicalResourceId': self.logical_resource_name} + 'LogicalResourceId': self.logical_resource_name} response = self.stack.heatclient.describe_stack_resource(**parameters) prefix = '/DescribeStackResourceResponse/DescribeStackResourceResult'\ - + '/StackResourceDetail' + + '/StackResourceDetail' stack_id = self.stack.response_xml_item(response, prefix, "StackId") self.stack.check_stackid(stack_id) resource_status = self.stack.response_xml_item(response, prefix, - "ResourceStatus") + "ResourceStatus") self.assertEqual(resource_status, self.logical_resource_status) resource_type = self.stack.response_xml_item(response, prefix, - "ResourceType") + "ResourceType") self.assertEqual(resource_type, self.logical_resource_type) update_time = self.stack.response_xml_item(response, prefix, "LastUpdatedTimestamp") - self.assertTrue(self.time_re.match(update_time) != None) + self.assertTrue(self.time_re.match(update_time) is not None) status_reason = self.stack.response_xml_item(response, prefix, - "ResourceStatusReason") + "ResourceStatusReason") self.assertEqual(status_reason, "state changed") stack_name = self.stack.response_xml_item(response, prefix, @@ -327,40 +327,40 @@ class CfnApiFunctionalTest(unittest.TestCase): self.assertEqual(log_res_id, self.logical_resource_name) phys_res_id = self.stack.response_xml_item(response, prefix, - "PhysicalResourceId") - self.assertTrue(self.phys_res_id_re.match(phys_res_id) != None) + "PhysicalResourceId") + self.assertTrue(self.phys_res_id_re.match(phys_res_id) is not None) metadata = self.stack.response_xml_item(response, prefix, "Metadata") json_load = json.loads(metadata) - self.assertTrue(json_load != None) + self.assertTrue(json_load is not None) self.assertTrue("AWS::CloudFormation::Init" in json_load) print "DescribeStackResource : OK" def testDescribeStackResources(self): parameters = {'NameOrPid': self.stack.stackname, - 'LogicalResourceId': self.logical_resource_name} + 'LogicalResourceId': self.logical_resource_name} response = self.stack.heatclient.describe_stack_resources(**parameters) prefix = '/DescribeStackResourcesResponse/' +\ - 'DescribeStackResourcesResult/StackResources/member' + 'DescribeStackResourcesResult/StackResources/member' stack_id = self.stack.response_xml_item(response, prefix, "StackId") self.stack.check_stackid(stack_id) resource_status = self.stack.response_xml_item(response, prefix, - "ResourceStatus") + "ResourceStatus") self.assertEqual(resource_status, self.logical_resource_status) resource_type = self.stack.response_xml_item(response, prefix, - "ResourceType") + "ResourceType") self.assertEqual(resource_type, self.logical_resource_type) update_time = self.stack.response_xml_item(response, prefix, "Timestamp") - self.assertTrue(self.time_re.match(update_time) != None) + self.assertTrue(self.time_re.match(update_time) is not None) status_reason = self.stack.response_xml_item(response, prefix, - "ResourceStatusReason") + "ResourceStatusReason") self.assertEqual(status_reason, "state changed") stack_name = self.stack.response_xml_item(response, prefix, @@ -372,8 +372,8 @@ class CfnApiFunctionalTest(unittest.TestCase): self.assertEqual(log_res_id, self.logical_resource_name) phys_res_id = self.stack.response_xml_item(response, prefix, - "PhysicalResourceId") - self.assertTrue(self.phys_res_id_re.match(phys_res_id) != None) + "PhysicalResourceId") + self.assertTrue(self.phys_res_id_re.match(phys_res_id) is not None) print "DescribeStackResources : OK" @@ -382,22 +382,22 @@ class CfnApiFunctionalTest(unittest.TestCase): parameters['StackName'] = self.stack.stackname response = self.stack.heatclient.list_stack_resources(**parameters) prefix = '/ListStackResourcesResponse/ListStackResourcesResult' +\ - '/StackResourceSummaries/member' + '/StackResourceSummaries/member' resource_status = self.stack.response_xml_item(response, prefix, - "ResourceStatus") + "ResourceStatus") self.assertEqual(resource_status, self.logical_resource_status) status_reason = self.stack.response_xml_item(response, prefix, - "ResourceStatusReason") + "ResourceStatusReason") self.assertEqual(status_reason, "state changed") update_time = self.stack.response_xml_item(response, prefix, "LastUpdatedTimestamp") - self.assertTrue(self.time_re.match(update_time) != None) + self.assertTrue(self.time_re.match(update_time) is not None) resource_type = self.stack.response_xml_item(response, prefix, - "ResourceType") + "ResourceType") self.assertEqual(resource_type, self.logical_resource_type) log_res_id = self.stack.response_xml_item(response, prefix, @@ -405,8 +405,8 @@ class CfnApiFunctionalTest(unittest.TestCase): self.assertEqual(log_res_id, self.logical_resource_name) phys_res_id = self.stack.response_xml_item(response, prefix, - "PhysicalResourceId") - self.assertTrue(self.phys_res_id_re.match(phys_res_id) != None) + "PhysicalResourceId") + self.assertTrue(self.phys_res_id_re.match(phys_res_id) is not None) print "ListStackResources : OK" @@ -424,6 +424,6 @@ class CfnApiFunctionalTest(unittest.TestCase): for param in templ_params: lookup = '[ParameterKey="' + param + '"]' val = self.stack.response_xml_item(response, prefix + lookup, - 'ParameterKey') + 'ParameterKey') self.assertEqual(param, val) print "ValidateTemplate : OK" diff --git a/heat/tests/functional/test_CFN_API_Actions_Boto.py b/heat/tests/functional/test_CFN_API_Actions_Boto.py index 4a966811..c51906f1 100644 --- a/heat/tests/functional/test_CFN_API_Actions_Boto.py +++ b/heat/tests/functional/test_CFN_API_Actions_Boto.py @@ -64,7 +64,7 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): inst = CfnApiFunctions() cls.stack = util.StackBoto(inst, template, 'F17', 'x86_64', 'cfntools', - stack_paramstr) + stack_paramstr) cls.WikiDatabase = util.Instance(inst, cls.logical_resource_name) try: @@ -118,7 +118,7 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): # Extract the StackSummary for this stack summary = [s for s in response - if s.stack_name == self.stack.stackname] + if s.stack_name == self.stack.stackname] self.assertEqual(len(summary), 1) # Note the boto StackSummary object does not contain every item @@ -129,7 +129,7 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): self.assertEqual(type(summary[0].creation_time), datetime.datetime) self.assertTrue(self.description_re.match( - summary[0].template_description) != None) + summary[0].template_description) is not None) self.assertEqual(summary[0].stack_name, self.stack.stackname) @@ -144,7 +144,7 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): # Extract the Stack object for this stack stacks = [s for s in response - if s.stack_name == self.stack.stackname] + if s.stack_name == self.stack.stackname] self.assertEqual(len(stacks), 1) self.assertEqual(type(stacks[0].creation_time), datetime.datetime) @@ -152,7 +152,7 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): self.stack.check_stackid(stacks[0].stack_id) self.assertTrue(self.description_re.match(stacks[0].description) - != None) + is not None) self.assertEqual(stacks[0].stack_status_reason, self.stack_status_reason) @@ -168,13 +168,13 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): # Create a dict to lookup the expected template parameters template_parameters = {'DBUsername': 'dbuser', - 'LinuxDistribution': 'F17', - 'InstanceType': 'm1.xlarge', - 'DBRootPassword': 'admin', - 'KeyName': self.stack.keyname, - 'DBPassword': - os.environ['OS_PASSWORD'], - 'DBName': 'wordpress'} + 'LinuxDistribution': 'F17', + 'InstanceType': 'm1.xlarge', + 'DBRootPassword': 'admin', + 'KeyName': self.stack.keyname, + 'DBPassword': + os.environ['OS_PASSWORD'], + 'DBName': 'wordpress'} for key, value in template_parameters.iteritems(): # The parameters returned via the API include a couple @@ -199,14 +199,14 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): parameters['StackName'] = self.stack.stackname response = self.stack.heatclient.list_stack_events(**parameters) events = [e for e in response - if e.logical_resource_id == self.logical_resource_name - and e.resource_status == self.logical_resource_status] + if e.logical_resource_id == self.logical_resource_name + and e.resource_status == self.logical_resource_status] self.assertEqual(len(events), 1) self.stack.check_stackid(events[0].stack_id) - self.assertTrue(re.match("[0-9]*$", events[0].event_id) != None) + self.assertTrue(re.match("[0-9]*$", events[0].event_id) is not None) self.assertEqual(events[0].resource_status, self.logical_resource_status) @@ -223,7 +223,7 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): self.logical_resource_name) self.assertTrue(self.phys_res_id_re.match( - events[0].physical_resource_id) != None) + events[0].physical_resource_id) is not None) # Check ResourceProperties, skip pending resolution of #245 properties = json.loads(events[0].resource_properties) @@ -235,35 +235,35 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): parameters = {} parameters['StackName'] = self.stack.stackname response = self.stack.heatclient.get_template(**parameters) - self.assertTrue(response != None) + self.assertTrue(response is not None) result = response['GetTemplateResponse']['GetTemplateResult'] - self.assertTrue(result != None) + self.assertTrue(result is not None) template = result['TemplateBody'] - self.assertTrue(template != None) + self.assertTrue(template is not None) # Then sanity check content - I guess we could diff # with the template file but for now just check the # description looks sane.. description = template['Description'] - self.assertTrue(self.description_re.match(description) != None) + self.assertTrue(self.description_re.match(description) is not None) print "GetTemplate : OK" def testDescribeStackResource(self): parameters = {'StackName': self.stack.stackname, - 'LogicalResourceId': self.logical_resource_name} + 'LogicalResourceId': self.logical_resource_name} response = self.stack.heatclient.describe_stack_resource(**parameters) # Note boto_client response for this is a dict, if upstream # pull request ever gets merged, this will change, see note/ # link in boto_client.py desc_resp = response['DescribeStackResourceResponse'] - self.assertTrue(desc_resp != None) + self.assertTrue(desc_resp is not None) desc_result = desc_resp['DescribeStackResourceResult'] - self.assertTrue(desc_result != None) + self.assertTrue(desc_result is not None) res = desc_result['StackResourceDetail'] - self.assertTrue(res != None) + self.assertTrue(res is not None) self.stack.check_stackid(res['StackId']) @@ -274,7 +274,7 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): # Note due to issue mentioned above timestamp is a string in this case # not a datetime.datetime object self.assertTrue(self.time_re.match(res['LastUpdatedTimestamp']) - != None) + is not None) self.assertEqual(res['ResourceStatusReason'], 'state changed') @@ -283,7 +283,7 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): self.assertEqual(res['LogicalResourceId'], self.logical_resource_name) self.assertTrue(self.phys_res_id_re.match(res['PhysicalResourceId']) - != None) + is not None) self.assertTrue("AWS::CloudFormation::Init" in res['Metadata']) @@ -291,12 +291,12 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): def testDescribeStackResources(self): parameters = {'NameOrPid': self.stack.stackname, - 'LogicalResourceId': self.logical_resource_name} + 'LogicalResourceId': self.logical_resource_name} response = self.stack.heatclient.describe_stack_resources(**parameters) self.assertEqual(len(response), 1) res = response[0] - self.assertTrue(res != None) + self.assertTrue(res is not None) self.stack.check_stackid(res.stack_id) @@ -313,7 +313,7 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): self.assertEqual(res.logical_resource_id, self.logical_resource_name) self.assertTrue(self.phys_res_id_re.match(res.physical_resource_id) - != None) + is not None) print "DescribeStackResources : OK" @@ -324,7 +324,7 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): self.assertEqual(len(response), 1) res = response[0] - self.assertTrue(res != None) + self.assertTrue(res is not None) self.assertEqual(res.resource_status, self.logical_resource_status) @@ -337,7 +337,7 @@ class CfnApiBotoFunctionalTest(unittest.TestCase): self.assertEqual(res.logical_resource_id, self.logical_resource_name) self.assertTrue(self.phys_res_id_re.match(res.physical_resource_id) - != None) + is not None) print "ListStackResources : OK" diff --git a/heat/tests/functional/test_CFN_API_UpdateStack.py b/heat/tests/functional/test_CFN_API_UpdateStack.py index c1bfbf6f..b207fda8 100644 --- a/heat/tests/functional/test_CFN_API_UpdateStack.py +++ b/heat/tests/functional/test_CFN_API_UpdateStack.py @@ -38,8 +38,9 @@ class CfnApiUpdateStackFunctionalTest(unittest.TestCase): cls.instance_type = 'm1.xlarge' cls.db_user = 'dbuser' cls.stack_paramstr = ';'.join(['InstanceType=%s' % cls.instance_type, - 'DBUsername=%s' % cls.db_user, - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=%s' % cls.db_user, + 'DBPassword=' + + os.environ['OS_PASSWORD']]) cls.logical_resource_name = 'WikiDatabase' cls.logical_resource_type = 'AWS::EC2::Instance' @@ -52,7 +53,7 @@ class CfnApiUpdateStackFunctionalTest(unittest.TestCase): cls.inst = CfnApiFunctions() cls.stack = util.Stack(cls.inst, template, 'F17', 'x86_64', 'cfntools', - cls.stack_paramstr) + cls.stack_paramstr) cls.WikiDatabase = util.Instance(cls.inst, cls.logical_resource_name) try: @@ -99,8 +100,9 @@ class CfnApiUpdateStackFunctionalTest(unittest.TestCase): self.db_user = 'anewuser' self.stack_paramstr = ';'.join(['InstanceType=%s' % self.instance_type, - 'DBUsername=%s' % self.db_user, - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=%s' % self.db_user, + 'DBPassword=' + + os.environ['OS_PASSWORD']]) self.stack.stack_paramstr = self.stack_paramstr self.stack.update() tries = 0 diff --git a/heat/tests/functional/test_HAProxy_Single_Instance.py b/heat/tests/functional/test_HAProxy_Single_Instance.py index 0d8fe3d9..d1f49ef6 100644 --- a/heat/tests/functional/test_HAProxy_Single_Instance.py +++ b/heat/tests/functional/test_HAProxy_Single_Instance.py @@ -29,8 +29,8 @@ class HAProxyFunctionalTest(unittest.TestCase): wp_template = 'WordPress_Single_Instance.template' wp_paramstr = ';'.join(['InstanceType=m1.xlarge', - 'DBUsername=dbuser', - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=dbuser', + 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.Stack(self, wp_template, 'F17', 'x86_64', 'cfntools', wp_paramstr) diff --git a/heat/tests/functional/test_OpenShift_Prebuilt_JEOS.py b/heat/tests/functional/test_OpenShift_Prebuilt_JEOS.py index 365ac40a..598ac88c 100644 --- a/heat/tests/functional/test_OpenShift_Prebuilt_JEOS.py +++ b/heat/tests/functional/test_OpenShift_Prebuilt_JEOS.py @@ -31,7 +31,7 @@ class OpenShiftFunctionalTest(unittest.TestCase): stack_paramstr = ';'.join(['InstanceType=m1.xlarge']) self.stack = util.Stack(self, template, 'F16', 'x86_64', - 'cfntools-openshift', stack_paramstr) + 'cfntools-openshift', stack_paramstr) self.Node = util.Instance(self, 'OpenShiftNodeServer') self.Broker = util.Instance(self, 'OpenShiftBrokerServer') diff --git a/heat/tests/functional/test_WordPress_2_Instances.py b/heat/tests/functional/test_WordPress_2_Instances.py index e9e9d81f..802d36a0 100644 --- a/heat/tests/functional/test_WordPress_2_Instances.py +++ b/heat/tests/functional/test_WordPress_2_Instances.py @@ -28,11 +28,11 @@ class WordPress2Instances(unittest.TestCase): template = 'WordPress_2_Instances.template' stack_paramstr = ';'.join(['InstanceType=m1.xlarge', - 'DBUsername=dbuser', - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=dbuser', + 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.Stack(self, template, 'F17', 'x86_64', 'cfntools', - stack_paramstr) + stack_paramstr) self.DatabaseServer = util.Instance(self, 'DatabaseServer') self.WebServer = util.Instance(self, 'WebServer') diff --git a/heat/tests/functional/test_WordPress_2_Instances_With_EBS.py b/heat/tests/functional/test_WordPress_2_Instances_With_EBS.py index 03e88a71..8f2c7215 100644 --- a/heat/tests/functional/test_WordPress_2_Instances_With_EBS.py +++ b/heat/tests/functional/test_WordPress_2_Instances_With_EBS.py @@ -28,11 +28,11 @@ class WordPress2InstancesWithEBS(unittest.TestCase): template = 'WordPress_2_Instances_With_EBS.template' stack_paramstr = ';'.join(['InstanceType=m1.xlarge', - 'DBUsername=dbuser', - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=dbuser', + 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.Stack(self, template, 'F17', 'x86_64', 'cfntools', - stack_paramstr) + stack_paramstr) self.WikiDatabase = util.Instance(self, 'WikiDatabase') self.WebServer = util.Instance(self, 'WebServer') @@ -65,7 +65,7 @@ class WordPress2InstancesWithEBS(unittest.TestCase): # Check EBS volume is present and mounted stdin, stdout, sterr = self.WikiDatabase.exec_command( - 'grep vdc /proc/mounts') + 'grep vdc /proc/mounts') result = stdout.readlines().pop().rstrip() self.assertTrue(len(result)) print "Checking EBS volume is attached : %s" % result diff --git a/heat/tests/functional/test_WordPress_2_Instances_With_EBS_EIP.py b/heat/tests/functional/test_WordPress_2_Instances_With_EBS_EIP.py index 45a6f04a..fd111a3d 100644 --- a/heat/tests/functional/test_WordPress_2_Instances_With_EBS_EIP.py +++ b/heat/tests/functional/test_WordPress_2_Instances_With_EBS_EIP.py @@ -26,8 +26,8 @@ class WordPress2EBSEIPFunctionalTest(unittest.TestCase): self.template = 'WordPress_2_Instances_With_EBS_EIP.template' stack_paramstr = ';'.join(['InstanceType=m1.xlarge', - 'DBUsername=dbuser', - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=dbuser', + 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.Stack(self, self.template, 'F17', 'x86_64', 'cfntools', @@ -56,7 +56,7 @@ class WordPress2EBSEIPFunctionalTest(unittest.TestCase): # Check wordpress installation wp_config_file = '/etc/wordpress/wp-config.php' self.assertTrue(self.webserver.file_present(wp_config_file), - 'wp-config.php is not present') + 'wp-config.php is not present') # Check mysql is installed and running stdin, stdout, sterr = self.database.exec_command( @@ -76,14 +76,17 @@ class WordPress2EBSEIPFunctionalTest(unittest.TestCase): self.assertTrue('/var/lib/mysql' in result) # Check the floating IPs - self.assertTrue(self.webserver.floating_ip_present(), + self.assertTrue( + self.webserver.floating_ip_present(), 'WebServer instance does not have a floating IP assigned') - self.assertTrue(self.database.floating_ip_present(), + self.assertTrue( + self.database.floating_ip_present(), 'WikiDatabase instance does not have a floating IP assigned') # Check wordpress is running and acessible at the correct URL stack_url = self.stack.get_stack_output("WebsiteURL") print "Got stack output WebsiteURL=%s, verifying" % stack_url ver = verify.VerifyStack() - self.assertTrue(ver.verify_wordpress(stack_url), + self.assertTrue( + ver.verify_wordpress(stack_url), 'Wordpress is not accessible at: %s' % stack_url) diff --git a/heat/tests/functional/test_WordPress_Composed_Instances.py b/heat/tests/functional/test_WordPress_Composed_Instances.py index 3b788ac2..455246f0 100644 --- a/heat/tests/functional/test_WordPress_Composed_Instances.py +++ b/heat/tests/functional/test_WordPress_Composed_Instances.py @@ -27,16 +27,17 @@ class WordPressComposedInstancesFunctionalTest(unittest.TestCase): template = 'WordPress_Composed_Instances.template' stack_paramstr = ';'.join(['InstanceType=m1.xlarge', - 'DBUsername=dbuser', - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=dbuser', + 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.Stack(self, template, 'F17', 'x86_64', 'cfntools', - stack_paramstr) + stack_paramstr) self.WebServer = util.Instance(self, 'WebServer') - self.MySqlDatabaseServer = util.Instance(self, - 'DatabaseTemplate.MySqlDatabaseServer') + self.MySqlDatabaseServer = util.Instance( + self, + 'DatabaseTemplate.MySqlDatabaseServer') def tearDown(self): self.stack.cleanup() diff --git a/heat/tests/functional/test_WordPress_Single_Instance.py b/heat/tests/functional/test_WordPress_Single_Instance.py index d8d003f4..2dd37b7b 100644 --- a/heat/tests/functional/test_WordPress_Single_Instance.py +++ b/heat/tests/functional/test_WordPress_Single_Instance.py @@ -30,7 +30,7 @@ class WordPressFunctionalTest(unittest.TestCase): 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.Stack(self, template, 'F17', 'x86_64', 'cfntools', - stack_paramstr) + stack_paramstr) self.WikiDatabase = util.Instance(self, 'WikiDatabase') def tearDown(self): diff --git a/heat/tests/functional/test_WordPress_Single_Instance_Boto.py b/heat/tests/functional/test_WordPress_Single_Instance_Boto.py index cac33c07..52a770f6 100644 --- a/heat/tests/functional/test_WordPress_Single_Instance_Boto.py +++ b/heat/tests/functional/test_WordPress_Single_Instance_Boto.py @@ -27,8 +27,8 @@ class WordPressBotoFunctionalTest(unittest.TestCase): template = 'WordPress_Single_Instance.template' stack_paramstr = ';'.join(['InstanceType=m1.xlarge', - 'DBUsername=dbuser', - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=dbuser', + 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.StackBoto(self, template, 'F17', 'x86_64', 'cfntools', diff --git a/heat/tests/functional/test_WordPress_Single_Instance_With_EBS.py b/heat/tests/functional/test_WordPress_Single_Instance_With_EBS.py index dd1cbf4e..325d8508 100644 --- a/heat/tests/functional/test_WordPress_Single_Instance_With_EBS.py +++ b/heat/tests/functional/test_WordPress_Single_Instance_With_EBS.py @@ -28,11 +28,11 @@ class WordPressSingleEBSFunctionalTest(unittest.TestCase): template = 'WordPress_Single_Instance_With_EBS.template' stack_paramstr = ';'.join(['InstanceType=m1.xlarge', - 'DBUsername=dbuser', - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=dbuser', + 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.Stack(self, template, 'F17', 'x86_64', 'cfntools', - stack_paramstr) + stack_paramstr) self.WikiDatabase = util.Instance(self, 'WikiDatabase') def tearDown(self): @@ -58,7 +58,7 @@ class WordPressSingleEBSFunctionalTest(unittest.TestCase): # Check EBS volume is present and mounted stdin, stdout, sterr = self.WikiDatabase.exec_command( - 'grep vdc /proc/mounts') + 'grep vdc /proc/mounts') result = stdout.readlines().pop().rstrip() self.assertTrue(len(result)) print "Checking EBS volume is attached : %s" % result diff --git a/heat/tests/functional/test_WordPress_Single_Instance_With_EBS_EIP.py b/heat/tests/functional/test_WordPress_Single_Instance_With_EBS_EIP.py index 9964927f..a155e4ef 100644 --- a/heat/tests/functional/test_WordPress_Single_Instance_With_EBS_EIP.py +++ b/heat/tests/functional/test_WordPress_Single_Instance_With_EBS_EIP.py @@ -28,11 +28,11 @@ class WordPressEBSEIPFunctionalTest(unittest.TestCase): template = 'WordPress_Single_Instance_With_EBS_EIP.template' stack_paramstr = ';'.join(['InstanceType=m1.xlarge', - 'DBUsername=dbuser', - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=dbuser', + 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.Stack(self, template, 'F17', 'x86_64', 'cfntools', - stack_paramstr) + stack_paramstr) self.WikiServer = util.Instance(self, 'WikiServer') def tearDown(self): @@ -81,7 +81,7 @@ class WordPressEBSEIPFunctionalTest(unittest.TestCase): # Check EBS volume is present and mounted stdin, stdout, sterr = self.WikiServer.exec_command( - 'grep vdc /proc/mounts') + 'grep vdc /proc/mounts') result = stdout.readlines().pop().rstrip() self.assertTrue(len(result)) print "Checking EBS volume is attached : %s" % result diff --git a/heat/tests/functional/test_WordPress_Single_Instance_With_EIP.py b/heat/tests/functional/test_WordPress_Single_Instance_With_EIP.py index 3902a78e..8194fe4d 100644 --- a/heat/tests/functional/test_WordPress_Single_Instance_With_EIP.py +++ b/heat/tests/functional/test_WordPress_Single_Instance_With_EIP.py @@ -28,11 +28,11 @@ class WordPressEIPFunctionalTest(unittest.TestCase): template = 'WordPress_Single_Instance_With_EIP.template' stack_paramstr = ';'.join(['InstanceType=m1.xlarge', - 'DBUsername=dbuser', - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=dbuser', + 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.Stack(self, template, 'F17', 'x86_64', 'cfntools', - stack_paramstr) + stack_paramstr) self.WebServer = util.Instance(self, 'WebServer') def tearDown(self): diff --git a/heat/tests/functional/test_WordPress_Single_Instance_With_HA.py b/heat/tests/functional/test_WordPress_Single_Instance_With_HA.py index 81087dc4..e6a861b1 100644 --- a/heat/tests/functional/test_WordPress_Single_Instance_With_HA.py +++ b/heat/tests/functional/test_WordPress_Single_Instance_With_HA.py @@ -27,11 +27,11 @@ class HaFunctionalTest(unittest.TestCase): template = 'WordPress_Single_Instance_With_HA.template' stack_paramstr = ';'.join(['InstanceType=m1.xlarge', - 'DBUsername=dbuser', - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=dbuser', + 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.Stack(self, template, 'F17', 'x86_64', 'cfntools', - stack_paramstr) + stack_paramstr) self.WikiDatabase = util.Instance(self, 'WikiDatabase') def tearDown(self): diff --git a/heat/tests/functional/test_WordPress_Single_Instance_With_IHA.py b/heat/tests/functional/test_WordPress_Single_Instance_With_IHA.py index 61c5a796..8a100cfd 100644 --- a/heat/tests/functional/test_WordPress_Single_Instance_With_IHA.py +++ b/heat/tests/functional/test_WordPress_Single_Instance_With_IHA.py @@ -27,11 +27,11 @@ class WordPressIHAFunctionalTest(unittest.TestCase): def setUp(self): template = 'WordPress_Single_Instance_With_IHA.template' stack_paramstr = ';'.join(['InstanceType=m1.xlarge', - 'DBUsername=dbuser', - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=dbuser', + 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.Stack(self, template, 'F17', 'x86_64', 'cfntools', - stack_paramstr) + stack_paramstr) self.WikiDatabase = util.Instance(self, 'WikiDatabase') def tearDown(self): diff --git a/heat/tests/functional/test_WordPress_With_LB.py b/heat/tests/functional/test_WordPress_With_LB.py index dd41969b..f7a29ede 100644 --- a/heat/tests/functional/test_WordPress_With_LB.py +++ b/heat/tests/functional/test_WordPress_With_LB.py @@ -26,16 +26,17 @@ class WordPressWithLBFunctionalTest(unittest.TestCase): template = 'WordPress_With_LB.template' stack_paramstr = ';'.join(['InstanceType=m1.xlarge', - 'DBUsername=dbuser', - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=dbuser', + 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.Stack(self, template, 'F17', 'x86_64', 'cfntools', - stack_paramstr) + stack_paramstr) self.WikiServerOne = util.Instance(self, 'WikiServerOne') self.LBInstance = util.Instance(self, 'LoadBalancer.LB_instance') - self.MySqlDatabaseServer = util.Instance(self, - 'DatabaseServer.MySqlDatabaseServer') + self.MySqlDatabaseServer = util.Instance( + self, + 'DatabaseServer.MySqlDatabaseServer') def tearDown(self): self.stack.cleanup() diff --git a/heat/tests/functional/test_WordPress_With_RDS.py b/heat/tests/functional/test_WordPress_With_RDS.py index a7d90295..384a88e6 100644 --- a/heat/tests/functional/test_WordPress_With_RDS.py +++ b/heat/tests/functional/test_WordPress_With_RDS.py @@ -26,11 +26,11 @@ class WordPressRDSFunctionalTest(unittest.TestCase): def setUp(self): template = 'WordPress_With_RDS.template' stack_paramstr = ';'.join(['InstanceType=m1.xlarge', - 'DBUsername=dbuser', - 'DBPassword=' + os.environ['OS_PASSWORD']]) + 'DBUsername=dbuser', + 'DBPassword=' + os.environ['OS_PASSWORD']]) self.stack = util.Stack(self, template, 'F17', 'x86_64', 'cfntools', - stack_paramstr) + stack_paramstr) self.WebServer = util.Instance(self, 'WebServer') def tearDown(self): diff --git a/heat/tests/functional/util.py b/heat/tests/functional/util.py index 16c9a20b..c237bbe6 100644 --- a/heat/tests/functional/util.py +++ b/heat/tests/functional/util.py @@ -65,15 +65,17 @@ class Instance(object): 'keystone authentication required') self.creds = dict(username=os.environ['OS_USERNAME'], - password=os.environ['OS_PASSWORD'], - tenant=os.environ['OS_TENANT_NAME'], - auth_url=os.environ['OS_AUTH_URL'], - strategy=os.environ['OS_AUTH_STRATEGY']) + password=os.environ['OS_PASSWORD'], + tenant=os.environ['OS_TENANT_NAME'], + auth_url=os.environ['OS_AUTH_URL'], + strategy=os.environ['OS_AUTH_STRATEGY']) dbusername = 'testuser' self.novaclient = nova_client.Client(self.creds['username'], - self.creds['password'], self.creds['tenant'], - self.creds['auth_url'], service_type='compute') + self.creds['password'], + self.creds['tenant'], + self.creds['auth_url'], + service_type='compute') self.ssh = paramiko.SSHClient() @@ -94,7 +96,7 @@ class Instance(object): self.testcase.assertTrue(tries < 150, 'Timed out') time.sleep(10) print 'Instance (%s) ip (%s) status (%s)' % (self.name, self.ip, - server.status) + server.status) tries = 0 while True: @@ -108,7 +110,7 @@ class Instance(object): time.sleep(10) else: print 'Instance (%s) ip (%s) SSH detected.' % (self.name, - self.ip) + self.ip) break tries = 0 @@ -116,8 +118,11 @@ class Instance(object): try: tries += 1 self.testcase.assertTrue(tries < 50, 'Timed out') - self.ssh.connect(self.ip, username='ec2-user', - allow_agent=True, look_for_keys=True, password='password') + self.ssh.connect(self.ip, + username='ec2-user', + allow_agent=True, + look_for_keys=True, + password='password') except paramiko.AuthenticationException: print 'Authentication error' time.sleep(2) @@ -194,7 +199,7 @@ class Instance(object): files = stdout.readlines() cfn_tools_files = ['cfn-init', 'cfn-hup', 'cfn-signal', - 'cfn-get-metadata', 'cfn_helper.py'] + 'cfn-get-metadata', 'cfn_helper.py'] cfntools = {} for file in cfn_tools_files: @@ -266,7 +271,7 @@ class Instance(object): t_data_list = joined_t_data.split('\n') # must match user data injection t_data_list.insert(len(t_data_list) - 1, - u'touch /var/lib/cloud/instance/provision-finished') + u'touch /var/lib/cloud/instance/provision-finished') self.testcase.assertEqual(t_data_list, remote_file_list_u) @@ -294,12 +299,12 @@ class Instance(object): self.testcase.assertEqual(data, f.read()) def get_ssh_client(self): - if self.ssh.get_transport() != None: + if self.ssh.get_transport() is not None: return self.ssh return None def get_sftp_client(self): - if self.sftp != None: + if self.sftp is not None: return self.sftp return None @@ -310,7 +315,7 @@ class Instance(object): class Stack(object): def __init__(self, testcase, template_file, distribution, arch, jeos_type, - stack_paramstr, stackname=DEFAULT_STACKNAME): + stack_paramstr, stackname=DEFAULT_STACKNAME): self.testcase = testcase self.stackname = stackname @@ -332,14 +337,19 @@ class Stack(object): 'keystone', 'keystone authentication required') - self.glanceclient = glance_client.Client(host="0.0.0.0", port=9292, - use_ssl=False, auth_tok=None, creds=self.creds) + self.glanceclient = glance_client.Client(host="0.0.0.0", + port=9292, + use_ssl=False, + auth_tok=None, + creds=self.creds) self.prepare_jeos(distribution, arch, jeos_type) self.novaclient = nova_client.Client(self.creds['username'], - self.creds['password'], self.creds['tenant'], - self.creds['auth_url'], service_type='compute') + self.creds['password'], + self.creds['tenant'], + self.creds['auth_url'], + service_type='compute') self.heatclient = self._create_heat_client() @@ -404,7 +414,7 @@ class Stack(object): self.testcase.assertTrue(create_list) self.testcase.assertEqual(len(create_list), 1) stack_id = create_list[0].findtext('StackId') - self.testcase.assertTrue(stack_id != None) + self.testcase.assertTrue(stack_id is not None) self.check_stackid(stack_id) def _check_update_result(self, result): @@ -414,18 +424,21 @@ class Stack(object): self.testcase.assertTrue(update_list) self.testcase.assertEqual(len(update_list), 1) stack_id = update_list[0].findtext('StackId') - self.testcase.assertTrue(stack_id != None) + self.testcase.assertTrue(stack_id is not None) self.check_stackid(stack_id) def check_stackid(self, stack_id): print "Checking %s matches expected format" % (stack_id) - self.testcase.assertTrue(self.stack_id_re.match(stack_id) != None) + self.testcase.assertTrue(self.stack_id_re.match(stack_id) is not None) def _create_heat_client(self): return heat_client.get_client('0.0.0.0', 8000, - self.creds['username'], self.creds['password'], - self.creds['tenant'], self.creds['auth_url'], - self.creds['strategy'], None, None, False) + self.creds['username'], + self.creds['password'], + self.creds['tenant'], + self.creds['auth_url'], + self.creds['strategy'], + None, None, False) def get_state(self): stack_list = self.heatclient.list_stacks(StackName=self.stackname) @@ -552,9 +565,9 @@ class StackBoto(Stack): # and extract the ec2-credentials, so we can pass them into the # boto client keystone = client.Client(username=self.creds['username'], - password=self.creds['password'], - tenant_name=self.creds['tenant'], - auth_url=self.creds['auth_url']) + password=self.creds['password'], + tenant_name=self.creds['tenant'], + auth_url=self.creds['auth_url']) ksusers = keystone.users.list() ksuid = [u.id for u in ksusers if u.name == self.creds['username']] self.testcase.assertEqual(len(ksuid), 1) @@ -569,11 +582,14 @@ class StackBoto(Stack): # compatibility with the non-boto client wrapper, and are # actually ignored, only the port and credentials are used return heat_client_boto.get_client('0.0.0.0', 8000, - self.creds['username'], self.creds['password'], - self.creds['tenant'], self.creds['auth_url'], - self.creds['strategy'], None, None, False, - aws_access_key=ec2creds[0].access, - aws_secret_key=ec2creds[0].secret) + self.creds['username'], + self.creds['password'], + self.creds['tenant'], + self.creds['auth_url'], + self.creds['strategy'], + None, None, False, + aws_access_key=ec2creds[0].access, + aws_secret_key=ec2creds[0].secret) def get_state(self): stack_list = self.heatclient.list_stacks() -- 2.45.2