From 9f5c58193bde7e55eebd102be9e2b8de0f7f4f6b Mon Sep 17 00:00:00 2001 From: Stuart McLaren Date: Fri, 15 May 2015 13:51:07 +0000 Subject: [PATCH] Fix functional tests in gate The check-glanceclient-dsvm-functional gate job was failing due to the functional tests not picking up valid OpenStack credentials. Update how we aquire credentials -- fixes side effect of how tox 2.0 handles environment variables. Change-Id: Ia665dc9673d09421508476d05039d2da8a5e1a29 Closes-bug: 1455102 --- functional_creds.conf.sample | 8 ++++++++ glanceclient/tests/functional/base.py | 15 +++++++++++++++ .../tests/functional/hooks/post_test_hook.sh | 17 +++++++++++++++-- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 functional_creds.conf.sample diff --git a/functional_creds.conf.sample b/functional_creds.conf.sample new file mode 100644 index 00000000..081a7368 --- /dev/null +++ b/functional_creds.conf.sample @@ -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 diff --git a/glanceclient/tests/functional/base.py b/glanceclient/tests/functional/base.py index f710ab65..a39e77d0 100644 --- a/glanceclient/tests/functional/base.py +++ b/glanceclient/tests/functional/base.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +import ConfigParser import os from tempest_lib.cli import base @@ -30,10 +31,24 @@ 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): cli_dir = os.environ.get( diff --git a/glanceclient/tests/functional/hooks/post_test_hook.sh b/glanceclient/tests/functional/hooks/post_test_hook.sh index 34498f34..ef9be3ad 100755 --- a/glanceclient/tests/functional/hooks/post_test_hook.sh +++ b/glanceclient/tests/functional/hooks/post_test_hook.sh @@ -28,15 +28,28 @@ function generate_testr_results { 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 < $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 -sudo chown -R jenkins:stack $GLANCECLIENT_DIR - # Run tests echo "Running glanceclient functional test suite" set +e