From d20543e306136393f4807ebdebc76e921e630329 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Wed, 5 Sep 2012 10:47:46 +0100 Subject: [PATCH] heat tests : FuncUtils use heat_client in create_stack Use heat_client (not subprocess) to create the stack, as this will allow easier testing of the boto_client library and easier checking of create_stack result Change-Id: Ic3f710ec2e467bcd2fde1a2451709d444b89aca0 Signed-off-by: Steven Hardy --- heat/tests/functional/util.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/heat/tests/functional/util.py b/heat/tests/functional/util.py index deba33f8..fd2b82a3 100644 --- a/heat/tests/functional/util.py +++ b/heat/tests/functional/util.py @@ -144,21 +144,35 @@ class FuncUtils: keyname = self.novaclient.keypairs.list().pop().name - subprocess.call(['heat', '-d', 'create', self.stackname, - '--template-file=' + self.basepath + - '/templates/' + template_file, - '--parameters=InstanceType=m1.xlarge;DBUsername=' + - self.dbusername + - ';DBPassword=' + os.environ['OS_PASSWORD'] + - ';KeyName=' + keyname + - ';LinuxDistribution=' + distribution]) - self.heatclient = 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) + assert self.heatclient + + # Dummy up the optparse.Values we get from CLI args in bin/heat + stack_paramstr = ';'.join(['InstanceType=m1.xlarge', + 'DBUsername=' + self.dbusername, + 'DBPassword=' + os.environ['OS_PASSWORD'], + 'KeyName=' + keyname, + 'LinuxDistribution=' + distribution]) + template_params = optparse.Values({'parameters': stack_paramstr}) + + # Format parameters and create the stack parameters = {} + parameters['StackName'] = self.stackname + template_path = self.basepath + '/templates/' + template_file + parameters['TemplateBody'] = open(template_path).read() + parameters.update(self.heatclient.format_parameters(template_params)) + result = self.heatclient.create_stack(**parameters) + + # Check result looks OK + root = etree.fromstring(result) + create_list = root.xpath('/CreateStackResponse/CreateStackResult' + + '[StackName="' + self.stackname + '"]') + assert create_list + assert len(create_list) == 1 alist = None tries = 0 -- 2.45.2