Create clouds.yaml for functional tests

Change-Id: I5d6d0c587b65e0ca877a4d13c89c4cd6ac90ef50
This commit is contained in:
Terry Howe 2015-05-20 11:06:46 -07:00 committed by TerryHowe
parent aeeae00445
commit c0358d0bd5
3 changed files with 40 additions and 3 deletions

30
create_yaml.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
#
# NOTE(thowe): There are some issues with OCC envvars that force us to do
# this for now.
#
mkdir -p ~/.config/openstack/
FILE=~/.config/openstack/clouds.yaml
echo 'clouds:' >$FILE
echo ' test_cloud:' >>$FILE
env | grep OS_ | tr '=' ' ' | while read k v
do
k=$(echo $k | sed -e 's/OS_//')
k=$(echo $k | tr '[A-Z]' '[a-z]')
case "$k" in
region_name|*_api_version)
echo " $k: $v" >>$FILE
esac
done
echo " auth:" >>$FILE
env | grep OS_ | tr '=' ' ' | while read k v
do
k=$(echo $k | sed -e 's/OS_//')
k=$(echo $k | tr '[A-Z]' '[a-z]')
case "$k" in
region_name|*_api_version)
;;
*)
echo " $k: $v" >>$FILE
esac
done

View File

@ -24,11 +24,16 @@ class TestStack(base.BaseFunctionalTest):
super(TestStack, cls).setUpClass()
if cls.conn.compute.find_keypair(cls.NAME) is None:
cls.conn.compute.create_keypair(name=cls.NAME)
image = cls.conn.image.find_image('fedora-20.x86_64')
if image is None:
image = cls.conn.image.find_image('cirros-0.3.4-x86_64-uec')
if image is None:
image = cls.conn.image.images().next()
template_url = ('http://git.openstack.org/cgit/openstack/' +
'heat-templates/plain/hot/F20/WordPress_Native.yaml')
sot = cls.conn.orchestration.create_stack(
name=cls.NAME,
parameters={'key_name': cls.NAME, 'image_id': 'fedora-20.x86_64'},
parameters={'key_name': cls.NAME, 'image_id': image.id},
template_url=template_url,
)
assert isinstance(sot, stack.Stack)
@ -44,5 +49,5 @@ class TestStack(base.BaseFunctionalTest):
cls.conn.compute.delete_keypair(cls.NAME)
def test_list(self):
names = [o.name for o in self.conn.orchestration.list_stacks()]
names = [o.name for o in self.conn.orchestration.stacks()]
self.assertIn(self.NAME, names)

View File

@ -9,9 +9,11 @@ DIR=$(cd $(dirname "$0") && pwd)
echo "Running SDK functional test suite"
sudo -H -u stack -i <<!
source ~stack/devstack/accrc/admin/admin
export OS_CLOUD=envvars
export OS_CLOUD=test_cloud
echo 'Running tests with:'
env | grep OS_
${DIR}/create_yaml.sh
cd ${DIR}
tox -e functional
!