pass credentials via config file instead of magic
Passing credentials via an assumed environment inheritance is bad form, and breaks under new tox. Honestly, we only really need 2 vars passed in, so we might as well make it a config file that we'll parse. Add a functional_creds.conf.sample for people to know what one should look like. Update README to explain it. Related-Bug: #1455102 Change-Id: Ifdab38a03c94f51d30449149c0dbd9c6265460a5
This commit is contained in:
parent
0e35f2a2fa
commit
6379287480
13
README.rst
13
README.rst
|
@ -83,3 +83,16 @@ To use with nova, with keystone as the authentication system::
|
||||||
* Documentation: http://docs.openstack.org/developer/python-novaclient
|
* Documentation: http://docs.openstack.org/developer/python-novaclient
|
||||||
* Source: http://git.openstack.org/cgit/openstack/python-novaclient
|
* Source: http://git.openstack.org/cgit/openstack/python-novaclient
|
||||||
* Bugs: http://bugs.launchpad.net/python-novaclient
|
* Bugs: http://bugs.launchpad.net/python-novaclient
|
||||||
|
|
||||||
|
Testing
|
||||||
|
-------
|
||||||
|
|
||||||
|
There are multiple test targets that can be run to validate the code.
|
||||||
|
|
||||||
|
* tox -e pep8 - style guidelines enforcement
|
||||||
|
* tox -e py27 - traditional unit testing
|
||||||
|
* 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.
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Credentials for functional testing
|
||||||
|
[auth]
|
||||||
|
uri = http://10.42.0.50:5000/v2.0
|
||||||
|
|
||||||
|
[admin]
|
||||||
|
user = admin
|
||||||
|
tenant = admin
|
||||||
|
pass = secrete
|
|
@ -10,6 +10,7 @@
|
||||||
# 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
|
||||||
|
@ -90,14 +91,32 @@ class ClientTestBase(testtools.TestCase):
|
||||||
format=self.log_format,
|
format=self.log_format,
|
||||||
level=None))
|
level=None))
|
||||||
|
|
||||||
|
# Collecting of credentials:
|
||||||
|
#
|
||||||
|
# Support the existence of a functional_creds.conf for
|
||||||
|
# testing. This makes it possible to use a config file.
|
||||||
|
#
|
||||||
|
# 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['OS_USERNAME']
|
user = os.environ.get('OS_USERNAME')
|
||||||
passwd = os.environ['OS_PASSWORD']
|
passwd = os.environ.get('OS_PASSWORD')
|
||||||
tenant = os.environ['OS_TENANT_NAME']
|
tenant = os.environ.get('OS_TENANT_NAME')
|
||||||
auth_url = os.environ['OS_AUTH_URL']
|
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')
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -120,10 +139,10 @@ class ClientTestBase(testtools.TestCase):
|
||||||
os.path.join(os.path.abspath('.'), '.tox/functional/bin'))
|
os.path.join(os.path.abspath('.'), '.tox/functional/bin'))
|
||||||
|
|
||||||
self.cli_clients = tempest_lib.cli.base.CLIClient(
|
self.cli_clients = tempest_lib.cli.base.CLIClient(
|
||||||
username=os.environ.get('OS_USERNAME'),
|
username=user,
|
||||||
password=os.environ.get('OS_PASSWORD'),
|
password=passwd,
|
||||||
tenant_name=os.environ.get('OS_TENANT_NAME'),
|
tenant_name=tenant,
|
||||||
uri=os.environ.get('OS_AUTH_URL'),
|
uri=auth_url,
|
||||||
cli_dir=cli_dir)
|
cli_dir=cli_dir)
|
||||||
|
|
||||||
def nova(self, *args, **kwargs):
|
def nova(self, *args, **kwargs):
|
||||||
|
|
|
@ -28,15 +28,28 @@ function generate_testr_results {
|
||||||
|
|
||||||
export NOVACLIENT_DIR="$BASE/new/python-novaclient"
|
export NOVACLIENT_DIR="$BASE/new/python-novaclient"
|
||||||
|
|
||||||
|
sudo chown -R jenkins:stack $NOVACLIENT_DIR
|
||||||
|
|
||||||
# Get admin credentials
|
# Get admin credentials
|
||||||
cd $BASE/new/devstack
|
cd $BASE/new/devstack
|
||||||
source openrc admin admin
|
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
|
||||||
|
|
||||||
# Go to the novaclient dir
|
# Go to the novaclient dir
|
||||||
cd $NOVACLIENT_DIR
|
cd $NOVACLIENT_DIR
|
||||||
|
|
||||||
sudo chown -R jenkins:stack $NOVACLIENT_DIR
|
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
echo "Running novaclient functional test suite"
|
echo "Running novaclient functional test suite"
|
||||||
set +e
|
set +e
|
||||||
|
|
Loading…
Reference in New Issue