heat tests : Remove utils.Stack getter methods

Remove the get_*_client getter methods, as they aren't
actually doing anything, so just access the attributes

Change-Id: Ic6740bdfe7d44c40b9fdf9fc4d03f8eddaf9a740
Signed-off-by: Steven Hardy <shardy@redhat.com>
This commit is contained in:
Steven Hardy 2012-10-16 17:24:53 +01:00
parent f3ab48b64e
commit 3308e27648
6 changed files with 26 additions and 63 deletions

View File

@ -112,8 +112,7 @@ class CfnApiFunctionalTest(unittest.TestCase):
self.assertTrue(ver.verify_wordpress(stack_url)) self.assertTrue(ver.verify_wordpress(stack_url))
def testListStacks(self): def testListStacks(self):
client = self.stack.get_heat_client() response = self.stack.heatclient.list_stacks()
response = client.list_stacks()
prefix = '/ListStacksResponse/ListStacksResult/StackSummaries/member' prefix = '/ListStacksResponse/ListStacksResult/StackSummaries/member'
stack_id = self.stack.response_xml_item(response, prefix, "StackId") stack_id = self.stack.response_xml_item(response, prefix, "StackId")
@ -146,10 +145,9 @@ class CfnApiFunctionalTest(unittest.TestCase):
print "ListStacks : OK" print "ListStacks : OK"
def testDescribeStacks(self): def testDescribeStacks(self):
client = self.stack.get_heat_client()
parameters = {} parameters = {}
parameters['StackName'] = self.stack.stackname parameters['StackName'] = self.stack.stackname
response = client.describe_stacks(**parameters) response = self.stack.heatclient.describe_stacks(**parameters)
prefix = '/DescribeStacksResponse/DescribeStacksResult/Stacks/member' prefix = '/DescribeStacksResponse/DescribeStacksResult/Stacks/member'
stack_id = self.stack.response_xml_item(response, prefix, "StackId") stack_id = self.stack.response_xml_item(response, prefix, "StackId")
@ -222,10 +220,9 @@ class CfnApiFunctionalTest(unittest.TestCase):
print "DescribeStacks : OK" print "DescribeStacks : OK"
def testDescribeStackEvents(self): def testDescribeStackEvents(self):
client = self.stack.get_heat_client()
parameters = {} parameters = {}
parameters['StackName'] = self.stack.stackname parameters['StackName'] = self.stack.stackname
response = client.list_stack_events(**parameters) response = self.stack.heatclient.list_stack_events(**parameters)
prefix = '/DescribeStackEventsResponse/DescribeStackEventsResult/' +\ prefix = '/DescribeStackEventsResponse/DescribeStackEventsResult/' +\
'StackEvents/member[LogicalResourceId="' +\ 'StackEvents/member[LogicalResourceId="' +\
self.logical_resource_name + '" and ResourceStatus="' +\ self.logical_resource_name + '" and ResourceStatus="' +\
@ -277,10 +274,9 @@ class CfnApiFunctionalTest(unittest.TestCase):
print "DescribeStackEvents : OK" print "DescribeStackEvents : OK"
def testGetTemplate(self): def testGetTemplate(self):
client = self.stack.get_heat_client()
parameters = {} parameters = {}
parameters['StackName'] = self.stack.stackname parameters['StackName'] = self.stack.stackname
response = client.get_template(**parameters) response = self.stack.heatclient.get_template(**parameters)
prefix = '/GetTemplateResponse/GetTemplateResult' prefix = '/GetTemplateResponse/GetTemplateResult'
# Extract the JSON TemplateBody and prove it parses # Extract the JSON TemplateBody and prove it parses
@ -298,10 +294,9 @@ class CfnApiFunctionalTest(unittest.TestCase):
print "GetTemplate : OK" print "GetTemplate : OK"
def testDescribeStackResource(self): def testDescribeStackResource(self):
client = self.stack.get_heat_client()
parameters = {'StackName': self.stack.stackname, parameters = {'StackName': self.stack.stackname,
'LogicalResourceId': self.logical_resource_name} 'LogicalResourceId': self.logical_resource_name}
response = client.describe_stack_resource(**parameters) response = self.stack.heatclient.describe_stack_resource(**parameters)
prefix = '/DescribeStackResourceResponse/DescribeStackResourceResult'\ prefix = '/DescribeStackResourceResponse/DescribeStackResourceResult'\
+ '/StackResourceDetail' + '/StackResourceDetail'
@ -344,10 +339,9 @@ class CfnApiFunctionalTest(unittest.TestCase):
print "DescribeStackResource : OK" print "DescribeStackResource : OK"
def testDescribeStackResources(self): def testDescribeStackResources(self):
client = self.stack.get_heat_client()
parameters = {'NameOrPid': self.stack.stackname, parameters = {'NameOrPid': self.stack.stackname,
'LogicalResourceId': self.logical_resource_name} 'LogicalResourceId': self.logical_resource_name}
response = client.describe_stack_resources(**parameters) response = self.stack.heatclient.describe_stack_resources(**parameters)
prefix = '/DescribeStackResourcesResponse/' +\ prefix = '/DescribeStackResourcesResponse/' +\
'DescribeStackResourcesResult/StackResources/member' 'DescribeStackResourcesResult/StackResources/member'
@ -385,10 +379,9 @@ class CfnApiFunctionalTest(unittest.TestCase):
print "DescribeStackResources : OK" print "DescribeStackResources : OK"
def testListStackResources(self): def testListStackResources(self):
client = self.stack.get_heat_client()
parameters = {} parameters = {}
parameters['StackName'] = self.stack.stackname parameters['StackName'] = self.stack.stackname
response = client.list_stack_resources(**parameters) response = self.stack.heatclient.list_stack_resources(**parameters)
prefix = '/ListStackResourcesResponse/ListStackResourcesResult' +\ prefix = '/ListStackResourcesResponse/ListStackResourcesResult' +\
'/StackResourceSummaries/member' '/StackResourceSummaries/member'
@ -419,11 +412,10 @@ class CfnApiFunctionalTest(unittest.TestCase):
print "ListStackResources : OK" print "ListStackResources : OK"
def testValidateTemplate(self): def testValidateTemplate(self):
client = self.stack.get_heat_client()
# Use stack.format_parameters to get the TemplateBody # Use stack.format_parameters to get the TemplateBody
params = self.stack.format_parameters() params = self.stack.format_parameters()
val_params = {'TemplateBody': params['TemplateBody']} val_params = {'TemplateBody': params['TemplateBody']}
response = client.validate_template(**val_params) response = self.stack.heatclient.validate_template(**val_params)
prefix = '/ValidateTemplateResponse/ValidateTemplateResult' +\ prefix = '/ValidateTemplateResponse/ValidateTemplateResult' +\
'/Parameters/member' '/Parameters/member'
# Check the response contains all the expected paramter keys # Check the response contains all the expected paramter keys

View File

@ -116,8 +116,7 @@ class CfnApiBotoFunctionalTest(unittest.TestCase):
self.assertTrue(ver.verify_wordpress(stack_url)) self.assertTrue(ver.verify_wordpress(stack_url))
def testListStacks(self): def testListStacks(self):
client = self.stack.get_heat_client() response = self.stack.heatclient.list_stacks()
response = client.list_stacks()
prefix = '/ListStacksResponse/ListStacksResult/StackSummaries/member' prefix = '/ListStacksResponse/ListStacksResult/StackSummaries/member'
# Extract the StackSummary for this stack # Extract the StackSummary for this stack
@ -142,10 +141,9 @@ class CfnApiBotoFunctionalTest(unittest.TestCase):
print "ListStacks : OK" print "ListStacks : OK"
def testDescribeStacks(self): def testDescribeStacks(self):
client = self.stack.get_heat_client()
parameters = {} parameters = {}
parameters['StackName'] = self.stack.stackname parameters['StackName'] = self.stack.stackname
response = client.describe_stacks(**parameters) response = self.stack.heatclient.describe_stacks(**parameters)
# Extract the Stack object for this stack # Extract the Stack object for this stack
stacks = [s for s in response stacks = [s for s in response
@ -200,11 +198,9 @@ class CfnApiBotoFunctionalTest(unittest.TestCase):
print "DescribeStacks : OK" print "DescribeStacks : OK"
def testDescribeStackEvents(self): def testDescribeStackEvents(self):
client = self.stack.get_heat_client()
parameters = {} parameters = {}
parameters['StackName'] = self.stack.stackname parameters['StackName'] = self.stack.stackname
response = client.list_stack_events(**parameters) response = self.stack.heatclient.list_stack_events(**parameters)
events = [e for e in response events = [e for e in response
if e.logical_resource_id == self.logical_resource_name if e.logical_resource_id == self.logical_resource_name
and e.resource_status == self.logical_resource_status] and e.resource_status == self.logical_resource_status]
@ -239,10 +235,9 @@ class CfnApiBotoFunctionalTest(unittest.TestCase):
print "DescribeStackEvents : OK" print "DescribeStackEvents : OK"
def testGetTemplate(self): def testGetTemplate(self):
client = self.stack.get_heat_client()
parameters = {} parameters = {}
parameters['StackName'] = self.stack.stackname parameters['StackName'] = self.stack.stackname
response = client.get_template(**parameters) response = self.stack.heatclient.get_template(**parameters)
self.assertTrue(response != None) self.assertTrue(response != None)
result = response['GetTemplateResponse']['GetTemplateResult'] result = response['GetTemplateResponse']['GetTemplateResult']
@ -259,10 +254,9 @@ class CfnApiBotoFunctionalTest(unittest.TestCase):
print "GetTemplate : OK" print "GetTemplate : OK"
def testDescribeStackResource(self): def testDescribeStackResource(self):
client = self.stack.get_heat_client()
parameters = {'StackName': self.stack.stackname, parameters = {'StackName': self.stack.stackname,
'LogicalResourceId': self.logical_resource_name} 'LogicalResourceId': self.logical_resource_name}
response = client.describe_stack_resource(**parameters) response = self.stack.heatclient.describe_stack_resource(**parameters)
# Note boto_client response for this is a dict, if upstream # Note boto_client response for this is a dict, if upstream
# pull request ever gets merged, this will change, see note/ # pull request ever gets merged, this will change, see note/
@ -299,10 +293,9 @@ class CfnApiBotoFunctionalTest(unittest.TestCase):
print "DescribeStackResource : OK" print "DescribeStackResource : OK"
def testDescribeStackResources(self): def testDescribeStackResources(self):
client = self.stack.get_heat_client()
parameters = {'NameOrPid': self.stack.stackname, parameters = {'NameOrPid': self.stack.stackname,
'LogicalResourceId': self.logical_resource_name} 'LogicalResourceId': self.logical_resource_name}
response = client.describe_stack_resources(**parameters) response = self.stack.heatclient.describe_stack_resources(**parameters)
self.assertEqual(len(response), 1) self.assertEqual(len(response), 1)
res = response[0] res = response[0]
@ -328,10 +321,9 @@ class CfnApiBotoFunctionalTest(unittest.TestCase):
print "DescribeStackResources : OK" print "DescribeStackResources : OK"
def testListStackResources(self): def testListStackResources(self):
client = self.stack.get_heat_client()
parameters = {} parameters = {}
parameters['StackName'] = self.stack.stackname parameters['StackName'] = self.stack.stackname
response = client.list_stack_resources(**parameters) response = self.stack.heatclient.list_stack_resources(**parameters)
self.assertEqual(len(response), 1) self.assertEqual(len(response), 1)
res = response[0] res = response[0]
@ -353,11 +345,10 @@ class CfnApiBotoFunctionalTest(unittest.TestCase):
print "ListStackResources : OK" print "ListStackResources : OK"
def testValidateTemplate(self): def testValidateTemplate(self):
client = self.stack.get_heat_client()
# Use stack.format_parameters to get the TemplateBody # Use stack.format_parameters to get the TemplateBody
params = self.stack.format_parameters() params = self.stack.format_parameters()
val_params = {'TemplateBody': params['TemplateBody']} val_params = {'TemplateBody': params['TemplateBody']}
response = client.validate_template(**val_params) response = self.stack.heatclient.validate_template(**val_params)
# Check the response contains all the expected paramter keys # Check the response contains all the expected paramter keys
templ_params = ['DBUsername', 'LinuxDistribution', 'InstanceType', templ_params = ['DBUsername', 'LinuxDistribution', 'InstanceType',
'DBRootPassword', 'KeyName', 'DBPassword', 'DBName'] 'DBRootPassword', 'KeyName', 'DBPassword', 'DBName']

View File

@ -123,10 +123,9 @@ class CfnApiUpdateStackFunctionalTest(unittest.TestCase):
self.assertTrue(tries < 500) self.assertTrue(tries < 500)
# Now use DescribeStacks to check the parameter is updated # Now use DescribeStacks to check the parameter is updated
client = self.stack.get_heat_client()
parameters = {} parameters = {}
parameters['StackName'] = self.stack.stackname parameters['StackName'] = self.stack.stackname
response = client.describe_stacks(**parameters) response = self.stack.heatclient.describe_stacks(**parameters)
prefix = '/DescribeStacksResponse/DescribeStacksResult/Stacks/member' prefix = '/DescribeStacksResponse/DescribeStacksResult/Stacks/member'
# value for each key, then check the extracted value # value for each key, then check the extracted value
param_prefix = prefix + '/Parameters/member[ParameterKey="DBUsername"]' param_prefix = prefix + '/Parameters/member[ParameterKey="DBUsername"]'

View File

@ -53,13 +53,12 @@ class WordPressEBSEIPFunctionalTest(unittest.TestCase):
print "Wordpress installation detected" print "Wordpress installation detected"
# 2. check floating ip assignment # 2. check floating ip assignment
nclient = self.stack.get_nova_client() if len(self.stack.novaclient.floating_ips.list()) == 0:
if len(nclient.floating_ips.list()) == 0:
print 'zero floating IPs detected' print 'zero floating IPs detected'
self.assertTrue(False) self.assertTrue(False)
else: else:
found = 0 found = 0
mylist = nclient.floating_ips.list() mylist = self.stack.novaclient.floating_ips.list()
for item in mylist: for item in mylist:
if item.instance_id == self.stack.instance_phys_ids()[0]: if item.instance_id == self.stack.instance_phys_ids()[0]:
print 'floating IP found', item.ip print 'floating IP found', item.ip

View File

@ -53,13 +53,12 @@ class WordPressEIPFunctionalTest(unittest.TestCase):
print "Wordpress installation detected" print "Wordpress installation detected"
# 2. check floating ip assignment # 2. check floating ip assignment
nclient = self.stack.get_nova_client() if len(self.stack.novaclient.floating_ips.list()) == 0:
if len(nclient.floating_ips.list()) == 0:
print 'zero floating IPs detected' print 'zero floating IPs detected'
self.assertTrue(False) self.assertTrue(False)
else: else:
found = 0 found = 0
mylist = nclient.floating_ips.list() mylist = self.stack.novaclient.floating_ips.list()
for item in mylist: for item in mylist:
if item.instance_id == self.stack.instance_phys_ids()[0]: if item.instance_id == self.stack.instance_phys_ids()[0]:
print 'floating IP found', item.ip print 'floating IP found', item.ip

View File

@ -333,6 +333,9 @@ class Stack(object):
'keystone', 'keystone',
'keystone authentication required') '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.prepare_jeos(distribution, arch, jeos_type) self.prepare_jeos(distribution, arch, jeos_type)
self.novaclient = nova_client.Client(self.creds['username'], self.novaclient = nova_client.Client(self.creds['username'],
@ -439,8 +442,7 @@ class Stack(object):
def cleanup(self): def cleanup(self):
parameters = {'StackName': self.stackname} parameters = {'StackName': self.stackname}
c = self.get_heat_client() self.heatclient.delete_stack(**parameters)
c.delete_stack(**parameters)
print 'Waiting for stack deletion to be completed' print 'Waiting for stack deletion to be completed'
tries = 0 tries = 0
@ -456,27 +458,9 @@ class Stack(object):
if end_state is not None: if end_state is not None:
self.testcase.assertEqual(end_state, 'DELETE_COMPLETE') self.testcase.assertEqual(end_state, 'DELETE_COMPLETE')
def get_nova_client(self):
if self.novaclient != None:
return self.novaclient
return None
def get_glance_client(self):
if self.glanceclient != None:
return self.glanceclient
return None
def get_heat_client(self):
if self.heatclient != None:
return self.heatclient
return None
def prepare_jeos(self, p_os, arch, type): def prepare_jeos(self, p_os, arch, type):
imagename = p_os + '-' + arch + '-' + type imagename = p_os + '-' + arch + '-' + type
self.glanceclient = glance_client.Client(host="0.0.0.0", port=9292,
use_ssl=False, auth_tok=None, creds=self.creds)
# skip creating jeos if image already available # skip creating jeos if image already available
if not self.poll_glance(self.glanceclient, imagename, False): if not self.poll_glance(self.glanceclient, imagename, False):
self.testcase.assertEqual(os.geteuid(), 0, self.testcase.assertEqual(os.geteuid(), 0,
@ -517,8 +501,7 @@ class Stack(object):
''' '''
# Get the DescribeStacks result for this stack # Get the DescribeStacks result for this stack
parameters = {'StackName': self.stackname} parameters = {'StackName': self.stackname}
c = self.get_heat_client() result = self.heatclient.describe_stacks(**parameters)
result = c.describe_stacks(**parameters)
return self._find_stack_output(result, output_key) return self._find_stack_output(result, output_key)
def _find_stack_output(self, result, output_key): def _find_stack_output(self, result, output_key):