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:
parent
d3ea91f615
commit
52cc56e284
1
.gitignore
vendored
1
.gitignore
vendored
@ -27,6 +27,7 @@ pip-log.txt
|
|||||||
.coverage
|
.coverage
|
||||||
.tox
|
.tox
|
||||||
nosetests.xml
|
nosetests.xml
|
||||||
|
functional_creds.conf
|
||||||
|
|
||||||
# Translations
|
# Translations
|
||||||
*.mo
|
*.mo
|
||||||
|
12
functional_creds.conf.sample
Normal file
12
functional_creds.conf.sample
Normal 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
|
@ -22,13 +22,37 @@ fi
|
|||||||
|
|
||||||
echo "Successfully contacted Mistral API"
|
echo "Successfully contacted Mistral API"
|
||||||
|
|
||||||
# Where tempest code lives
|
export BASE=/opt/stack
|
||||||
TEMPEST_DIR=${TEMPEST_DIR:-/opt/stack/new/tempest}
|
export MISTRALCLIENT_DIR="$BASE/new/python-mistralclient"
|
||||||
|
|
||||||
# Add tempest source tree to PYTHONPATH
|
# Get demo credentials.
|
||||||
export PYTHONPATH=$PYTHONPATH:$TEMPEST_DIR
|
cd ${BASE}/new/devstack
|
||||||
|
source openrc demo demo
|
||||||
|
|
||||||
#installing requirements for tempest
|
export OS_ALT_USERNAME=${OS_USERNAME}
|
||||||
pip install -r $TEMPEST_DIR/requirements.txt
|
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
|
||||||
|
@ -14,10 +14,51 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from tempest import config
|
from six.moves import configparser
|
||||||
from tempest_lib.cli import base
|
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):
|
class MistralCLIAuth(base.ClientTestBase):
|
||||||
@ -25,12 +66,15 @@ class MistralCLIAuth(base.ClientTestBase):
|
|||||||
_mistral_url = None
|
_mistral_url = None
|
||||||
|
|
||||||
def _get_admin_clients(self):
|
def _get_admin_clients(self):
|
||||||
|
creds = credentials()
|
||||||
|
|
||||||
clients = base.CLIClient(
|
clients = base.CLIClient(
|
||||||
username=CONF.identity.admin_username,
|
username=creds['username'],
|
||||||
password=CONF.identity.admin_password,
|
password=creds['password'],
|
||||||
tenant_name=CONF.identity.admin_tenant_name,
|
tenant_name=creds['tenant_name'],
|
||||||
uri=CONF.identity.uri,
|
uri=creds['auth_url'],
|
||||||
cli_dir='/usr/local/bin')
|
cli_dir=CLI_DIR
|
||||||
|
)
|
||||||
|
|
||||||
return clients
|
return clients
|
||||||
|
|
||||||
@ -56,12 +100,15 @@ class MistralCLIAltAuth(base.ClientTestBase):
|
|||||||
_mistral_url = None
|
_mistral_url = None
|
||||||
|
|
||||||
def _get_alt_clients(self):
|
def _get_alt_clients(self):
|
||||||
|
creds = credentials('demo')
|
||||||
|
|
||||||
clients = base.CLIClient(
|
clients = base.CLIClient(
|
||||||
username=CONF.identity.alt_username,
|
username=creds['username'],
|
||||||
password=CONF.identity.alt_password,
|
password=creds['password'],
|
||||||
tenant_name=CONF.identity.alt_tenant_name,
|
tenant_name=creds['tenant_name'],
|
||||||
uri=CONF.identity.uri,
|
uri=creds['auth_url'],
|
||||||
cli_dir='/usr/local/bin')
|
cli_dir=CLI_DIR
|
||||||
|
)
|
||||||
|
|
||||||
return clients
|
return clients
|
||||||
|
|
||||||
|
@ -8,4 +8,5 @@ unittest2
|
|||||||
fixtures>=0.3.14
|
fixtures>=0.3.14
|
||||||
mock>=1.0
|
mock>=1.0
|
||||||
nose
|
nose
|
||||||
|
tempest-lib>=0.6.1
|
||||||
testtools>=1.4.0
|
testtools>=1.4.0
|
||||||
|
5
tox.ini
5
tox.ini
@ -21,6 +21,11 @@ deps =
|
|||||||
-r{toxinidir}/test-requirements.txt
|
-r{toxinidir}/test-requirements.txt
|
||||||
commands = nosetests mistralclient/tests/unit
|
commands = nosetests mistralclient/tests/unit
|
||||||
|
|
||||||
|
[testenv:functional]
|
||||||
|
setenv =
|
||||||
|
OS_TEST_PATH = ./mistralclient/tests/functional
|
||||||
|
commands = {posargs}
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
commands = flake8 {posargs}
|
commands = flake8 {posargs}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user