tests: rework functional live tests
This allows to run functional live tests without devstack. And runs tests within the normal tox target without devstack This increases test coverage because all backend are now tested. Change-Id: If475b6d1f43a44540f276209a3651e7e790c2233
This commit is contained in:
parent
bddc811398
commit
3b365a1876
@ -1,5 +1,8 @@
|
|||||||
#!/bin/bash -xe
|
#!/bin/bash -xe
|
||||||
|
|
||||||
|
#FIXME(sileht): remove me when dsvm gate job is removed
|
||||||
|
|
||||||
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# not use this file except in compliance with the License. You may obtain
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
@ -15,50 +18,4 @@
|
|||||||
# This script is executed inside post_test_hook function in devstack gate.
|
# This script is executed inside post_test_hook function in devstack gate.
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
exit 0
|
||||||
function generate_testr_results {
|
|
||||||
if [ -f .testrepository/0 ]; then
|
|
||||||
sudo .tox/functional/bin/testr last --subunit > $WORKSPACE/testrepository.subunit
|
|
||||||
sudo mv $WORKSPACE/testrepository.subunit $BASE/logs/testrepository.subunit
|
|
||||||
sudo /usr/os-testr-env/bin/subunit2html $BASE/logs/testrepository.subunit $BASE/logs/testr_results.html
|
|
||||||
sudo gzip -9 $BASE/logs/testrepository.subunit
|
|
||||||
sudo gzip -9 $BASE/logs/testr_results.html
|
|
||||||
sudo chown jenkins:jenkins $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz
|
|
||||||
sudo chmod a+r $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# If we're running in the gate find our keystone endpoint to give to
|
|
||||||
# gabbi tests and do a chown. Otherwise the existing environment
|
|
||||||
# should provide URL and TOKEN.
|
|
||||||
if [ -d $BASE/new/devstack ]; then
|
|
||||||
export AODH_DIR="$BASE/new/aodh"
|
|
||||||
STACK_USER=stack
|
|
||||||
sudo chown -R $STACK_USER:stack $AODH_DIR
|
|
||||||
source $BASE/new/devstack/openrc admin admin
|
|
||||||
if [ $OS_IDENTITY_API_VERSION == '2.0' ]; then
|
|
||||||
urltag='publicURL'
|
|
||||||
else
|
|
||||||
urltag='public'
|
|
||||||
fi
|
|
||||||
openstack catalog list
|
|
||||||
export AODH_SERVICE_URL=$(openstack catalog show alarming -c endpoints -f value | awk "/$urltag"'/{print $2}')
|
|
||||||
export AODH_SERVICE_TOKEN=$(openstack token issue -c id -f value)
|
|
||||||
# Go to the aodh dir
|
|
||||||
cd $AODH_DIR
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run tests
|
|
||||||
echo "Running aodh functional test suite"
|
|
||||||
set +e
|
|
||||||
|
|
||||||
# NOTE(ityaptin) Expect a script param which contains at least one backend name
|
|
||||||
AODH_TEST_BACKEND="${1:?test backend required}" sudo -E -H -u ${STACK_USER:-${USER}} tox -efunctional
|
|
||||||
EXIT_CODE=$?
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Collect and parse result
|
|
||||||
if [ -n "$AODH_DIR" ]; then
|
|
||||||
generate_testr_results
|
|
||||||
fi
|
|
||||||
exit $EXIT_CODE
|
|
||||||
|
0
aodh/tests/functional_live/__init__.py
Normal file
0
aodh/tests/functional_live/__init__.py
Normal file
0
aodh/tests/functional_live/gabbi/__init__.py
Normal file
0
aodh/tests/functional_live/gabbi/__init__.py
Normal file
@ -1,6 +1,7 @@
|
|||||||
defaults:
|
defaults:
|
||||||
request_headers:
|
request_headers:
|
||||||
x-auth-token: $ENVIRON['AODH_SERVICE_TOKEN']
|
x-auth-token: $ENVIRON['AODH_SERVICE_TOKEN']
|
||||||
|
x-roles: $ENVIRON['AODH_SERVICE_ROLES']
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
- name: list alarms none
|
- name: list alarms none
|
@ -31,7 +31,7 @@ TESTS_DIR = 'gabbits-live'
|
|||||||
|
|
||||||
def load_tests(loader, tests, pattern):
|
def load_tests(loader, tests, pattern):
|
||||||
"""Provide a TestSuite to the discovery process."""
|
"""Provide a TestSuite to the discovery process."""
|
||||||
aodh_url = os.getenv('AODH_SERVICE_URL')
|
aodh_url = os.getenv('AODH_URL')
|
||||||
if aodh_url:
|
if aodh_url:
|
||||||
parsed_url = urlparse.urlsplit(aodh_url)
|
parsed_url = urlparse.urlsplit(aodh_url)
|
||||||
prefix = parsed_url.path.rstrip('/') # turn it into a prefix
|
prefix = parsed_url.path.rstrip('/') # turn it into a prefix
|
||||||
@ -50,4 +50,4 @@ def load_tests(loader, tests, pattern):
|
|||||||
port=port,
|
port=port,
|
||||||
prefix=prefix)
|
prefix=prefix)
|
||||||
elif os.getenv('GABBI_LIVE_FAIL_IF_NO_TEST'):
|
elif os.getenv('GABBI_LIVE_FAIL_IF_NO_TEST'):
|
||||||
raise RuntimeError('AODH_SERVICE_URL is not set')
|
raise RuntimeError('AODH_URL is not set')
|
@ -1,7 +1,20 @@
|
|||||||
#!/bin/bash -x
|
#!/bin/bash -x
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
export AODH_TEST_BACKEND=${AODH_TEST_BACKEND:-mysql}
|
cleanup(){
|
||||||
export AODH_SERVICE_URL=${AODH_SERVICE_URL:-http://127.0.0.1:8042}
|
type -t database_stop >/dev/null && database_stop || true
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
pifpaf -g AODH_TEST_STORAGE_URL run $AODH_TEST_BACKEND -- $*
|
export GABBI_LIVE_FAIL_IF_NO_TEST=1
|
||||||
|
export OS_TEST_PATH=aodh/tests/functional_live/
|
||||||
|
export AODH_SERVICE_TOKEN=foobar # Needed for gabbi
|
||||||
|
export AODH_SERVICE_ROLES=admin
|
||||||
|
|
||||||
|
AODH_TEST_DRIVERS=${AODH_TEST_DRIVERS:-postgresql}
|
||||||
|
for indexer in ${AODH_TEST_DRIVERS}
|
||||||
|
do
|
||||||
|
eval $(pifpaf -e DATABASE run $indexer)
|
||||||
|
pifpaf -e AODH run aodh --database-url $DATABASE_URL -- ./tools/pretty_tox.sh $*
|
||||||
|
cleanup
|
||||||
|
done
|
||||||
|
@ -53,7 +53,7 @@ doc =
|
|||||||
openstackdocstheme>=1.0.3 # Apache-2.0
|
openstackdocstheme>=1.0.3 # Apache-2.0
|
||||||
|
|
||||||
test =
|
test =
|
||||||
pifpaf>=0.1.0
|
pifpaf[gnocchi]>=1.0.1
|
||||||
oslotest>=2.15.0 # Apache-2.0
|
oslotest>=2.15.0 # Apache-2.0
|
||||||
coverage>=3.6
|
coverage>=3.6
|
||||||
fixtures>=1.3.1
|
fixtures>=1.3.1
|
||||||
@ -67,6 +67,7 @@ test =
|
|||||||
os-testr
|
os-testr
|
||||||
python-subunit>=0.0.18
|
python-subunit>=0.0.18
|
||||||
webtest
|
webtest
|
||||||
|
gnocchi[postgresql,file]
|
||||||
|
|
||||||
[entry_points]
|
[entry_points]
|
||||||
aodh.storage =
|
aodh.storage =
|
||||||
|
16
tox.ini
16
tox.ini
@ -1,7 +1,7 @@
|
|||||||
[tox]
|
[tox]
|
||||||
minversion = 1.6
|
minversion = 1.6
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
envlist = py{27,35}{,-mysql,-postgresql,-pgsql},functional,pep8
|
envlist = py{27,35}{,-mysql,-postgresql},functional,pep8
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
# NOTE(tonyb): This project has chosen to *NOT* consume upper-constraints.txt
|
# NOTE(tonyb): This project has chosen to *NOT* consume upper-constraints.txt
|
||||||
@ -14,25 +14,13 @@ setenv =
|
|||||||
AODH_TEST_DEPS=postgresql,mysql
|
AODH_TEST_DEPS=postgresql,mysql
|
||||||
mysql: AODH_TEST_DEPS=mysql
|
mysql: AODH_TEST_DEPS=mysql
|
||||||
postgresql: AODH_TEST_DEPS=postgresql
|
postgresql: AODH_TEST_DEPS=postgresql
|
||||||
|
|
||||||
# TODO(sileht): Remove when infra job are removed
|
|
||||||
pgsql: AODH_TEST_DRIVERS=postgresql
|
|
||||||
pgsql: AODH_TEST_DEPS=postgresql
|
|
||||||
deps = .[test,{env:AODH_TEST_DEPS}]
|
deps = .[test,{env:AODH_TEST_DEPS}]
|
||||||
passenv = OS_TEST_TIMEOUT OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_LOG_CAPTURE AODH_TEST_DRIVERS
|
passenv = OS_TEST_TIMEOUT OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_LOG_CAPTURE AODH_TEST_DRIVERS
|
||||||
commands =
|
commands =
|
||||||
{toxinidir}/run-tests.sh --black-regex '^aodh\.tests\.tempest\..*$' {posargs}
|
{toxinidir}/run-tests.sh --black-regex '^aodh\.tests\.tempest\..*$' {posargs}
|
||||||
|
{toxinidir}/run-functional-tests.sh "{posargs}"
|
||||||
aodh-config-generator
|
aodh-config-generator
|
||||||
|
|
||||||
[testenv:functional]
|
|
||||||
deps = .[mysql,postgresql,test]
|
|
||||||
setenv = VIRTUAL_ENV={envdir}
|
|
||||||
OS_TEST_PATH=aodh/tests/functional/
|
|
||||||
GABBI_LIVE_FAIL_IF_NO_TEST=1
|
|
||||||
passenv = {[testenv]passenv} AODH_*
|
|
||||||
commands =
|
|
||||||
{toxinidir}/run-functional-tests.sh ./tools/pretty_tox.sh "{posargs}"
|
|
||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
commands =
|
commands =
|
||||||
pifpaf -g AODH_TEST_STORAGE_URL run mysql -- python setup.py testr --slowest --coverage --testr-args="{posargs}"
|
pifpaf -g AODH_TEST_STORAGE_URL run mysql -- python setup.py testr --slowest --coverage --testr-args="{posargs}"
|
||||||
|
Loading…
Reference in New Issue
Block a user