Use clouds.yaml for functional test credentials
devstack emits a clouds.yaml file now, so it can be used for finding the credentials needed to connect to the cloud for functional testing. Depends-On: I1150b943f52f10d19f8434b27e8dde73a14d7843 Change-Id: If278565ef07de1a8fef3ff96fc3608e41f3ceea3
This commit is contained in:
parent
6379287480
commit
22569f218e
|
@ -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
|
* tox -e functional - live functional testing against an existing
|
||||||
openstack
|
openstack
|
||||||
|
|
||||||
Functional testing assumes the existance of a functional_creds.conf in
|
Functional testing assumes the existance of a `clouds.yaml` file as supported
|
||||||
the root directory. See the .sample for example format.
|
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`.
|
||||||
|
|
|
@ -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,10 +10,10 @@
|
||||||
# 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 fixtures
|
import fixtures
|
||||||
|
import os_client_config
|
||||||
import tempest_lib.cli.base
|
import tempest_lib.cli.base
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
|
@ -50,6 +50,11 @@ class NoFlavorException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NoCloudConfigException(Exception):
|
||||||
|
"""We couldn't find a cloud configuration."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ClientTestBase(testtools.TestCase):
|
class ClientTestBase(testtools.TestCase):
|
||||||
"""
|
"""
|
||||||
This is a first pass at a simple read only python-novaclient test. This
|
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:
|
# Collecting of credentials:
|
||||||
#
|
#
|
||||||
# Support the existence of a functional_creds.conf for
|
# Grab the cloud config from a user's clouds.yaml file.
|
||||||
# testing. This makes it possible to use a config 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
|
# TODO(sdague): while we collect this information in
|
||||||
# tempest-lib, we do it in a way that's not available for top
|
# 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
|
# level tests. Long term this probably needs to be in the base
|
||||||
# class.
|
# class.
|
||||||
user = os.environ.get('OS_USERNAME')
|
openstack_config = os_client_config.config.OpenStackConfig()
|
||||||
passwd = os.environ.get('OS_PASSWORD')
|
try:
|
||||||
tenant = os.environ.get('OS_TENANT_NAME')
|
cloud_config = openstack_config.get_one_cloud('functional_admin')
|
||||||
auth_url = os.environ.get('OS_AUTH_URL')
|
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
|
||||||
|
|
||||||
config = ConfigParser.RawConfigParser()
|
if cloud_config is None:
|
||||||
if config.read('functional_creds.conf'):
|
raise NoCloudConfigException(
|
||||||
# the OR pattern means the environment is preferred for
|
"Cloud not find a cloud named functional_admin or a cloud"
|
||||||
# override
|
" named devstack. Please check your clouds.yaml file and"
|
||||||
user = user or config.get('admin', 'user')
|
" try again.")
|
||||||
passwd = passwd or config.get('admin', 'pass')
|
auth_info = cloud_config.config['auth']
|
||||||
tenant = tenant or config.get('admin', 'tenant')
|
|
||||||
auth_url = auth_url or config.get('auth', 'uri')
|
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
|
# TODO(sdague): we made a lot of fun of the glanceclient team
|
||||||
# for version as int in first parameter. I guess we know where
|
# for version as int in first parameter. I guess we know where
|
||||||
|
|
|
@ -30,22 +30,10 @@ export NOVACLIENT_DIR="$BASE/new/python-novaclient"
|
||||||
|
|
||||||
sudo chown -R jenkins:stack $NOVACLIENT_DIR
|
sudo chown -R jenkins:stack $NOVACLIENT_DIR
|
||||||
|
|
||||||
# Get admin credentials
|
# ensure clouds.yaml exists
|
||||||
cd $BASE/new/devstack
|
mkdir -p ~/.config/openstack
|
||||||
source openrc admin admin
|
sudo cp -a ~stack/.config/openstack/clouds.yaml ~/.config/openstack
|
||||||
# pass the appropriate variables via a config file
|
sudo chown -R jenkins:stack ~/.config/openstack
|
||||||
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
|
|
||||||
|
|
||||||
# Go to the novaclient dir
|
# Go to the novaclient dir
|
||||||
cd $NOVACLIENT_DIR
|
cd $NOVACLIENT_DIR
|
||||||
|
|
|
@ -10,6 +10,7 @@ keyring>=2.1,!=3.3
|
||||||
mock>=1.0
|
mock>=1.0
|
||||||
requests-mock>=0.6.0 # Apache-2.0
|
requests-mock>=0.6.0 # Apache-2.0
|
||||||
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
|
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
|
||||||
|
os-client-config
|
||||||
oslosphinx>=2.5.0 # Apache-2.0
|
oslosphinx>=2.5.0 # Apache-2.0
|
||||||
testrepository>=0.0.18
|
testrepository>=0.0.18
|
||||||
testscenarios>=0.4
|
testscenarios>=0.4
|
||||||
|
|
Loading…
Reference in New Issue