Fixing launching mistralclient tests

* Fixed mistral cli path: it provides via venv
   like in other OpenStack projects
 * Added credentials config file like in other projects
 * Modified .gitignore

Depends-On: I07aabeace56d3cf336f10085179cd4aa8e0102c3

Change-Id: I742e8124fb8a74e1cca4abb8ddf25950b7b2b2c9
This commit is contained in:
Nikolay Mahotkin 2015-07-10 12:09:50 +03:00
parent d3ea91f615
commit 52cc56e284
6 changed files with 109 additions and 19 deletions

1
.gitignore vendored
View File

@ -27,6 +27,7 @@ pip-log.txt
.coverage
.tox
nosetests.xml
functional_creds.conf
# Translations
*.mo

View File

@ -0,0 +1,12 @@
# Credentials for functional testing
[auth]
uri = http://10.42.0.50:5000/v2.0
[admin]
user = admin
tenant = admin
pass = secrete
[demo]
user = demo
tenant = demo
pass = demo_secret

View File

@ -22,13 +22,37 @@ fi
echo "Successfully contacted Mistral API"
# Where tempest code lives
TEMPEST_DIR=${TEMPEST_DIR:-/opt/stack/new/tempest}
export BASE=/opt/stack
export MISTRALCLIENT_DIR="$BASE/new/python-mistralclient"
# Add tempest source tree to PYTHONPATH
export PYTHONPATH=$PYTHONPATH:$TEMPEST_DIR
# Get demo credentials.
cd ${BASE}/new/devstack
source openrc demo demo
#installing requirements for tempest
pip install -r $TEMPEST_DIR/requirements.txt
export OS_ALT_USERNAME=${OS_USERNAME}
export OS_ALT_TENANT_NAME=${OS_TENANT_NAME}
export OS_ALT_PASSWORD=${OS_PASSWORD}
nosetests -sv mistralclient/tests/functional/
# Get admin credentials.
source openrc admin admin
# Store these credentials into the config file.
CREDS_FILE=${MISTRALCLIENT_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
[demo]
user = $OS_ALT_USERNAME
tenant = $OS_ALT_TENANT_NAME
pass = $OS_ALT_PASSWORD
EOF
cd $MISTRALCLIENT_DIR
# Run tests
tox -efunctional -- nosetests -sv mistralclient/tests/functional

View File

@ -14,10 +14,51 @@
import os
from tempest import config
from six.moves import configparser
from tempest_lib.cli import base
CONF = config.CONF
CLI_DIR = os.environ.get(
'OS_MISTRALCLIENT_EXEC_DIR',
os.path.join(os.path.abspath('.'), '.tox/functional/bin')
)
_CREDS_FILE = 'functional_creds.conf'
def credentials(group='admin'):
"""Retrieves credentials to run functional tests.
Credentials are either read from the environment or from a config file
('functional_creds.conf'). Environment variables override those from the
config file.
The 'functional_creds.conf' file is the clean and new way to use (by
default tox 2.0 does not pass environment variables).
"""
if group == 'admin':
username = os.environ.get('OS_USERNAME')
password = os.environ.get('OS_PASSWORD')
tenant_name = os.environ.get('OS_TENANT_NAME')
else:
username = os.environ.get('OS_ALT_USERNAME')
password = os.environ.get('OS_ALT_PASSWORD')
tenant_name = os.environ.get('OS_ALT_TENANT_NAME')
auth_url = os.environ.get('OS_AUTH_URL')
config = configparser.RawConfigParser()
if config.read(_CREDS_FILE):
username = username or config.get(group, 'user')
password = password or config.get(group, 'pass')
tenant_name = tenant_name or config.get(group, 'tenant')
auth_url = auth_url or config.get('auth', 'uri')
return {
'username': username,
'password': password,
'tenant_name': tenant_name,
'auth_url': auth_url
}
class MistralCLIAuth(base.ClientTestBase):
@ -25,12 +66,15 @@ class MistralCLIAuth(base.ClientTestBase):
_mistral_url = None
def _get_admin_clients(self):
creds = credentials()
clients = base.CLIClient(
username=CONF.identity.admin_username,
password=CONF.identity.admin_password,
tenant_name=CONF.identity.admin_tenant_name,
uri=CONF.identity.uri,
cli_dir='/usr/local/bin')
username=creds['username'],
password=creds['password'],
tenant_name=creds['tenant_name'],
uri=creds['auth_url'],
cli_dir=CLI_DIR
)
return clients
@ -56,12 +100,15 @@ class MistralCLIAltAuth(base.ClientTestBase):
_mistral_url = None
def _get_alt_clients(self):
creds = credentials('demo')
clients = base.CLIClient(
username=CONF.identity.alt_username,
password=CONF.identity.alt_password,
tenant_name=CONF.identity.alt_tenant_name,
uri=CONF.identity.uri,
cli_dir='/usr/local/bin')
username=creds['username'],
password=creds['password'],
tenant_name=creds['tenant_name'],
uri=creds['auth_url'],
cli_dir=CLI_DIR
)
return clients

View File

@ -8,4 +8,5 @@ unittest2
fixtures>=0.3.14
mock>=1.0
nose
tempest-lib>=0.6.1
testtools>=1.4.0

View File

@ -21,6 +21,11 @@ deps =
-r{toxinidir}/test-requirements.txt
commands = nosetests mistralclient/tests/unit
[testenv:functional]
setenv =
OS_TEST_PATH = ./mistralclient/tests/functional
commands = {posargs}
[testenv:pep8]
commands = flake8 {posargs}