Allow setting env variables for functional options

The shade functional tests are hardcoded to use the cloud configuration
that is typically provided by devstack. It turns out that shade
functional tests are a useful way to quickly test that a cloud is up and
configured.

Allow providing new values for flavor, image and cloud variables so that
the functional tests can be run on a non-devstack cloud.

Change-Id: I90ab125be77091eaf16ae16e47f4336d4ef49880
This commit is contained in:
Jamie Lennox 2016-10-20 12:57:31 +11:00
parent 7d02b5d209
commit ecb317d610
3 changed files with 23 additions and 3 deletions

View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
import os_client_config as occ
import shade
@ -22,12 +24,15 @@ class BaseFunctionalTestCase(base.TestCase):
def setUp(self):
super(BaseFunctionalTestCase, self).setUp()
demo_name = os.environ.get('SHADE_DEMO_CLOUD', 'devstack')
op_name = os.environ.get('SHADE_OPERATOR_CLOUD', 'devstack-admin')
self.config = occ.OpenStackConfig()
demo_config = self.config.get_one_cloud(cloud='devstack')
demo_config = self.config.get_one_cloud(cloud=demo_name)
self.demo_cloud = shade.OpenStackCloud(
cloud_config=demo_config,
log_inner_exceptions=True)
operator_config = self.config.get_one_cloud(cloud='devstack-admin')
operator_config = self.config.get_one_cloud(cloud=op_name)
self.operator_cloud = shade.OperatorCloud(
cloud_config=operator_config,
log_inner_exceptions=True)

View File

@ -19,12 +19,20 @@ util
Util methods for functional tests
"""
import operator
import os
def pick_flavor(flavors):
"""Given a flavor list pick the smallest one."""
# Enable running functional tests against rax - which requires
# performance flavors be used for boot from volume
flavor_name = os.environ.get('SHADE_FLAVOR')
if flavor_name:
for flavor in flavors:
if flavor.name == flavor_name:
return flavor
return None
for flavor in sorted(
flavors,
key=operator.attrgetter('ram')):
@ -37,6 +45,13 @@ def pick_flavor(flavors):
def pick_image(images):
image_name = os.environ.get('SHADE_IMAGE')
if image_name:
for image in images:
if image.name == image_name:
return image
return None
for image in images:
if image.name.startswith('cirros') and image.name.endswith('-uec'):
return image

View File

@ -32,7 +32,7 @@ commands = python setup.py testr --slowest --testr-args='--concurrency=1 {posarg
[testenv:functional]
setenv =
OS_TEST_PATH = ./shade/tests/functional
passenv = OS_*
passenv = OS_* SHADE_*
commands = python setup.py testr --slowest --testr-args='--concurrency=1 {posargs}'
[testenv:pep8]