summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-05-25 17:29:27 +0000
committerGerrit Code Review <review@openstack.org>2015-05-25 17:29:27 +0000
commit048e763b75c5c1a0f18bf461577751386043c2d0 (patch)
treef31ab97b76c53395e0b613c292b6397768455547
parente180dbf12cc597c95be363fc309e4f526538373b (diff)
parent9f5c58193bde7e55eebd102be9e2b8de0f7f4f6b (diff)
downloadpython-glanceclient-048e763b75c5c1a0f18bf461577751386043c2d0.tar.gz
Merge "Fix functional tests in gate"
-rw-r--r--functional_creds.conf.sample8
-rw-r--r--glanceclient/tests/functional/base.py15
-rwxr-xr-xglanceclient/tests/functional/hooks/post_test_hook.sh17
3 files changed, 38 insertions, 2 deletions
diff --git a/functional_creds.conf.sample b/functional_creds.conf.sample
new file mode 100644
index 0000000..081a736
--- /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 f710ab6..a39e77d 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 34498f3..ef9be3a 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 <<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
-sudo chown -R jenkins:stack $GLANCECLIENT_DIR
-
# Run tests
echo "Running glanceclient functional test suite"
set +e