summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.rst7
-rw-r--r--functional_creds.conf.sample8
-rw-r--r--novaclient/tests/functional/base.py62
-rwxr-xr-xnovaclient/tests/functional/hooks/post_test_hook.sh20
-rw-r--r--test-requirements.txt1
5 files changed, 52 insertions, 46 deletions
diff --git a/README.rst b/README.rst
index edf26ec6..a98c198c 100644
--- a/README.rst
+++ b/README.rst
@@ -94,5 +94,8 @@ There are multiple test targets that can be run to validate the code.
* tox -e functional - live functional testing against an existing
openstack
-Functional testing assumes the existance of a functional_creds.conf in
-the root directory. See the .sample for example format.
+Functional testing assumes the existance of a `clouds.yaml` file as supported
+by `os-client-config` (http://docs.openstack.org/developer/os-client-config)
+It assumes the existence of a cloud named `devstack` that behaves like a normal
+devstack installation with a demo and an admin user/tenant - or clouds named
+`functional_admin` and `functional_nonadmin`.
diff --git a/functional_creds.conf.sample b/functional_creds.conf.sample
deleted file mode 100644
index 081a7368..00000000
--- a/functional_creds.conf.sample
+++ /dev/null
@@ -1,8 +0,0 @@
-# Credentials for functional testing
-[auth]
-uri = http://10.42.0.50:5000/v2.0
-
-[admin]
-user = admin
-tenant = admin
-pass = secrete
diff --git a/novaclient/tests/functional/base.py b/novaclient/tests/functional/base.py
index ac795325..540bb22f 100644
--- a/novaclient/tests/functional/base.py
+++ b/novaclient/tests/functional/base.py
@@ -10,10 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-import ConfigParser
import os
import fixtures
+import os_client_config
import tempest_lib.cli.base
import testtools
@@ -50,6 +50,11 @@ class NoFlavorException(Exception):
pass
+class NoCloudConfigException(Exception):
+ """We couldn't find a cloud configuration."""
+ pass
+
+
class ClientTestBase(testtools.TestCase):
"""
This is a first pass at a simple read only python-novaclient test. This
@@ -93,30 +98,47 @@ class ClientTestBase(testtools.TestCase):
# Collecting of credentials:
#
- # Support the existence of a functional_creds.conf for
- # testing. This makes it possible to use a config file.
+ # Grab the cloud config from a user's clouds.yaml file.
+ # First look for a functional_admin cloud, as this is a cloud
+ # that the user may have defined for functional testing that has
+ # admin credentials.
+ # If that is not found, get the devstack config and override the
+ # username and project_name to be admin so that admin credentials
+ # will be used.
+ #
+ # Finally, fall back to looking for environment variables to support
+ # existing users running these the old way. We should deprecate that
+ # as tox 2.0 blanks out environment.
#
- # Those variables can be overridden by environmental variables
- # as well to support existing users running these the old
- # way. We should deprecate that.
-
# TODO(sdague): while we collect this information in
# tempest-lib, we do it in a way that's not available for top
# level tests. Long term this probably needs to be in the base
# class.
- user = os.environ.get('OS_USERNAME')
- passwd = os.environ.get('OS_PASSWORD')
- tenant = os.environ.get('OS_TENANT_NAME')
- auth_url = os.environ.get('OS_AUTH_URL')
-
- config = ConfigParser.RawConfigParser()
- if config.read('functional_creds.conf'):
- # the OR pattern means the environment is preferred for
- # override
- user = user or config.get('admin', 'user')
- passwd = passwd or config.get('admin', 'pass')
- tenant = tenant or config.get('admin', 'tenant')
- auth_url = auth_url or config.get('auth', 'uri')
+ openstack_config = os_client_config.config.OpenStackConfig()
+ try:
+ cloud_config = openstack_config.get_one_cloud('functional_admin')
+ except os_client_config.exceptions.OpenStackConfigException:
+ try:
+ cloud_config = openstack_config.get_one_cloud(
+ 'devstack', auth=dict(
+ username='admin', project_name='admin'))
+ except os_client_config.exceptions.OpenStackConfigException:
+ try:
+ cloud_config = openstack_config.get_one_cloud('envvars')
+ except os_client_config.exceptions.OpenStackConfigException:
+ cloud_config = None
+
+ if cloud_config is None:
+ raise NoCloudConfigException(
+ "Cloud not find a cloud named functional_admin or a cloud"
+ " named devstack. Please check your clouds.yaml file and"
+ " try again.")
+ auth_info = cloud_config.config['auth']
+
+ user = auth_info['username']
+ passwd = auth_info['password']
+ tenant = auth_info['project_name']
+ auth_url = auth_info['auth_url']
# TODO(sdague): we made a lot of fun of the glanceclient team
# for version as int in first parameter. I guess we know where
diff --git a/novaclient/tests/functional/hooks/post_test_hook.sh b/novaclient/tests/functional/hooks/post_test_hook.sh
index 5878ace9..8eff1fd2 100755
--- a/novaclient/tests/functional/hooks/post_test_hook.sh
+++ b/novaclient/tests/functional/hooks/post_test_hook.sh
@@ -30,22 +30,10 @@ export NOVACLIENT_DIR="$BASE/new/python-novaclient"
sudo chown -R jenkins:stack $NOVACLIENT_DIR
-# Get admin credentials
-cd $BASE/new/devstack
-source openrc admin admin
-# pass the appropriate variables via a config file
-CREDS_FILE=$NOVACLIENT_DIR/functional_creds.conf
-cat <<EOF > $CREDS_FILE
-# Credentials for functional testing
-[auth]
-uri = $OS_AUTH_URL
-
-[admin]
-user = $OS_USERNAME
-tenant = $OS_TENANT_NAME
-pass = $OS_PASSWORD
-
-EOF
+# ensure clouds.yaml exists
+mkdir -p ~/.config/openstack
+sudo cp -a ~stack/.config/openstack/clouds.yaml ~/.config/openstack
+sudo chown -R jenkins:stack ~/.config/openstack
# Go to the novaclient dir
cd $NOVACLIENT_DIR
diff --git a/test-requirements.txt b/test-requirements.txt
index 22526524..ca767e76 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -10,6 +10,7 @@ keyring>=2.1,!=3.3
mock>=1.0
requests-mock>=0.6.0 # Apache-2.0
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
+os-client-config
oslosphinx>=2.5.0 # Apache-2.0
testrepository>=0.0.18
testscenarios>=0.4