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