summaryrefslogtreecommitdiff
path: root/glanceclient/tests/functional
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2015-10-18 12:16:25 -0400
committerMonty Taylor <mordred@inaugust.com>2015-10-21 05:43:26 +0900
commit84538d8870b2204cb9ea0a24217e5b3cb6f38b4f (patch)
treeee8375da569aadcf70c931edf7c32fc25d44d709 /glanceclient/tests/functional
parent8cf2bfce3cbfdb7ec84385539b37258dbac408df (diff)
downloadpython-glanceclient-84538d8870b2204cb9ea0a24217e5b3cb6f38b4f.tar.gz
Use clouds.yaml from devstack for functional tests
devstack produces a file called clouds.yaml already with credentials in it. Rather than producing our own config file to run functional tests, just consume the clouds.yaml file that's already there. Closes-Bug: #1507386 Change-Id: I82c071b2cd903b9578d1f2ec515882c815812692
Diffstat (limited to 'glanceclient/tests/functional')
-rw-r--r--glanceclient/tests/functional/base.py48
-rwxr-xr-xglanceclient/tests/functional/hooks/post_test_hook.sh17
-rw-r--r--glanceclient/tests/functional/test_readonly_glance.py2
3 files changed, 23 insertions, 44 deletions
diff --git a/glanceclient/tests/functional/base.py b/glanceclient/tests/functional/base.py
index 9488595..6029a06 100644
--- a/glanceclient/tests/functional/base.py
+++ b/glanceclient/tests/functional/base.py
@@ -10,12 +10,28 @@
# License for the specific language governing permissions and limitations
# under the License.
-import ConfigParser
import os
+import os_client_config
from tempest_lib.cli import base
+def credentials(cloud='devstack-admin'):
+ """Retrieves credentials to run functional tests
+
+ Credentials are either read via os-client-config from the environment
+ or from a config file ('clouds.yaml'). Environment variables override
+ those from the config file.
+
+ devstack produces a clouds.yaml with two named clouds - one named
+ 'devstack' which has user privs and one named 'devstack-admin' which
+ has admin privs. This function will default to getting the devstack-admin
+ cloud as that is the current expected behavior.
+ """
+
+ return os_client_config.OpenStackConfig().get_one_cloud(cloud=cloud)
+
+
class ClientTestBase(base.ClientTestBase):
"""This is a first pass at a simple read only python-glanceclient test.
@@ -28,37 +44,17 @@ class ClientTestBase(base.ClientTestBase):
"""
- def __init__(self, *args, **kwargs):
- super(ClientTestBase, self).__init__(*args, **kwargs)
-
- # Collecting of credentials:
- #
- # Support the existence of a functional_creds.conf for
- # testing. This makes it possible to use a config file.
- self.username = os.environ.get('OS_USERNAME')
- self.password = os.environ.get('OS_PASSWORD')
- self.tenant_name = os.environ.get('OS_TENANT_NAME')
- self.uri = 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
- self.username = self.username or config.get('admin', 'user')
- self.password = self.password or config.get('admin', 'pass')
- self.tenant_name = self.tenant_name or config.get('admin',
- 'tenant')
- self.uri = self.uri or config.get('auth', 'uri')
-
def _get_clients(self):
+ self.creds = credentials().get_auth_args()
cli_dir = os.environ.get(
'OS_GLANCECLIENT_EXEC_DIR',
os.path.join(os.path.abspath('.'), '.tox/functional/bin'))
return base.CLIClient(
- username=self.username,
- password=self.password,
- tenant_name=self.tenant_name,
- uri=self.uri,
+ username=self.creds['username'],
+ password=self.creds['password'],
+ tenant_name=self.creds['project_name'],
+ uri=self.creds['auth_url'],
cli_dir=cli_dir)
def glance(self, *args, **kwargs):
diff --git a/glanceclient/tests/functional/hooks/post_test_hook.sh b/glanceclient/tests/functional/hooks/post_test_hook.sh
index 02aa2f1..e0c2de0 100755
--- a/glanceclient/tests/functional/hooks/post_test_hook.sh
+++ b/glanceclient/tests/functional/hooks/post_test_hook.sh
@@ -30,23 +30,6 @@ export GLANCECLIENT_DIR="$BASE/new/python-glanceclient"
sudo chown -R jenkins:stack $GLANCECLIENT_DIR
-# Get admin credentials
-cd $BASE/new/devstack
-source openrc admin admin
-# pass the appropriate variables via a config file
-CREDS_FILE=$GLANCECLIENT_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
-
# Go to the glanceclient dir
cd $GLANCECLIENT_DIR
diff --git a/glanceclient/tests/functional/test_readonly_glance.py b/glanceclient/tests/functional/test_readonly_glance.py
index 9302927..72ded1f 100644
--- a/glanceclient/tests/functional/test_readonly_glance.py
+++ b/glanceclient/tests/functional/test_readonly_glance.py
@@ -42,7 +42,7 @@ class SimpleReadOnlyGlanceClientTest(base.ClientTestBase):
'this-does-not-exist')
def test_member_list_v1(self):
- tenant_name = '--tenant-id %s' % self.tenant_name
+ tenant_name = '--tenant-id %s' % self.creds['project_name']
out = self.glance('--os-image-api-version 1 member-list',
params=tenant_name)
endpoints = self.parser.listing(out)