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
This commit is contained in:
@@ -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
|
|
@@ -10,12 +10,28 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import ConfigParser
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import os_client_config
|
||||||
from tempest_lib.cli import base
|
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):
|
class ClientTestBase(base.ClientTestBase):
|
||||||
"""This is a first pass at a simple read only python-glanceclient test.
|
"""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):
|
def _get_clients(self):
|
||||||
|
self.creds = credentials().get_auth_args()
|
||||||
cli_dir = os.environ.get(
|
cli_dir = os.environ.get(
|
||||||
'OS_GLANCECLIENT_EXEC_DIR',
|
'OS_GLANCECLIENT_EXEC_DIR',
|
||||||
os.path.join(os.path.abspath('.'), '.tox/functional/bin'))
|
os.path.join(os.path.abspath('.'), '.tox/functional/bin'))
|
||||||
|
|
||||||
return base.CLIClient(
|
return base.CLIClient(
|
||||||
username=self.username,
|
username=self.creds['username'],
|
||||||
password=self.password,
|
password=self.creds['password'],
|
||||||
tenant_name=self.tenant_name,
|
tenant_name=self.creds['project_name'],
|
||||||
uri=self.uri,
|
uri=self.creds['auth_url'],
|
||||||
cli_dir=cli_dir)
|
cli_dir=cli_dir)
|
||||||
|
|
||||||
def glance(self, *args, **kwargs):
|
def glance(self, *args, **kwargs):
|
||||||
|
@@ -30,23 +30,6 @@ export GLANCECLIENT_DIR="$BASE/new/python-glanceclient"
|
|||||||
|
|
||||||
sudo chown -R jenkins:stack $GLANCECLIENT_DIR
|
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
|
# Go to the glanceclient dir
|
||||||
cd $GLANCECLIENT_DIR
|
cd $GLANCECLIENT_DIR
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ class SimpleReadOnlyGlanceClientTest(base.ClientTestBase):
|
|||||||
'this-does-not-exist')
|
'this-does-not-exist')
|
||||||
|
|
||||||
def test_member_list_v1(self):
|
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',
|
out = self.glance('--os-image-api-version 1 member-list',
|
||||||
params=tenant_name)
|
params=tenant_name)
|
||||||
endpoints = self.parser.listing(out)
|
endpoints = self.parser.listing(out)
|
||||||
|
@@ -6,6 +6,7 @@ hacking<0.11,>=0.10.0
|
|||||||
coverage>=3.6
|
coverage>=3.6
|
||||||
discover
|
discover
|
||||||
mock>=1.2
|
mock>=1.2
|
||||||
|
os-client-config>=1.4.0,!=1.6.2
|
||||||
oslosphinx>=2.5.0 # Apache-2.0
|
oslosphinx>=2.5.0 # Apache-2.0
|
||||||
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
|
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
|
||||||
testrepository>=0.0.18
|
testrepository>=0.0.18
|
||||||
|
Reference in New Issue
Block a user