diff --git a/aodh/tests/functional/hooks/post_test_hook.sh b/aodh/tests/functional/hooks/post_test_hook.sh index 992d34ad9..4eba96f54 100755 --- a/aodh/tests/functional/hooks/post_test_hook.sh +++ b/aodh/tests/functional/hooks/post_test_hook.sh @@ -1,5 +1,8 @@ #!/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 # not use this file except in compliance with the License. You may obtain # a copy of the License at @@ -15,50 +18,4 @@ # This script is executed inside post_test_hook function in devstack gate. set -e - -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 +exit 0 diff --git a/aodh/tests/functional_live/__init__.py b/aodh/tests/functional_live/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/aodh/tests/functional_live/gabbi/__init__.py b/aodh/tests/functional_live/gabbi/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/aodh/tests/functional/gabbi/gabbits-live/alarms.yaml b/aodh/tests/functional_live/gabbi/gabbits-live/alarms.yaml similarity index 98% rename from aodh/tests/functional/gabbi/gabbits-live/alarms.yaml rename to aodh/tests/functional_live/gabbi/gabbits-live/alarms.yaml index b8fcedd51..2458b1fe8 100644 --- a/aodh/tests/functional/gabbi/gabbits-live/alarms.yaml +++ b/aodh/tests/functional_live/gabbi/gabbits-live/alarms.yaml @@ -1,6 +1,7 @@ defaults: request_headers: x-auth-token: $ENVIRON['AODH_SERVICE_TOKEN'] + x-roles: $ENVIRON['AODH_SERVICE_ROLES'] tests: - name: list alarms none diff --git a/aodh/tests/functional/gabbi/test_gabbi_live.py b/aodh/tests/functional_live/gabbi/test_gabbi_live.py similarity index 94% rename from aodh/tests/functional/gabbi/test_gabbi_live.py rename to aodh/tests/functional_live/gabbi/test_gabbi_live.py index ff6dfa1d3..7f48c7395 100644 --- a/aodh/tests/functional/gabbi/test_gabbi_live.py +++ b/aodh/tests/functional_live/gabbi/test_gabbi_live.py @@ -31,7 +31,7 @@ TESTS_DIR = 'gabbits-live' def load_tests(loader, tests, pattern): """Provide a TestSuite to the discovery process.""" - aodh_url = os.getenv('AODH_SERVICE_URL') + aodh_url = os.getenv('AODH_URL') if aodh_url: parsed_url = urlparse.urlsplit(aodh_url) prefix = parsed_url.path.rstrip('/') # turn it into a prefix @@ -50,4 +50,4 @@ def load_tests(loader, tests, pattern): port=port, prefix=prefix) elif os.getenv('GABBI_LIVE_FAIL_IF_NO_TEST'): - raise RuntimeError('AODH_SERVICE_URL is not set') + raise RuntimeError('AODH_URL is not set') diff --git a/run-functional-tests.sh b/run-functional-tests.sh index 7ab73c10c..6720dc9d4 100755 --- a/run-functional-tests.sh +++ b/run-functional-tests.sh @@ -1,7 +1,20 @@ #!/bin/bash -x set -e -export AODH_TEST_BACKEND=${AODH_TEST_BACKEND:-mysql} -export AODH_SERVICE_URL=${AODH_SERVICE_URL:-http://127.0.0.1:8042} +cleanup(){ + 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 diff --git a/setup.cfg b/setup.cfg index 4a958f260..f90f0f967 100644 --- a/setup.cfg +++ b/setup.cfg @@ -53,7 +53,7 @@ doc = openstackdocstheme>=1.0.3 # Apache-2.0 test = - pifpaf>=0.1.0 + pifpaf[gnocchi]>=1.0.1 oslotest>=2.15.0 # Apache-2.0 coverage>=3.6 fixtures>=1.3.1 @@ -67,6 +67,7 @@ test = os-testr python-subunit>=0.0.18 webtest + gnocchi[postgresql,file] [entry_points] aodh.storage = diff --git a/tox.ini b/tox.ini index 1c1c1a4ac..237e52c7a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] minversion = 1.6 skipsdist = True -envlist = py{27,35}{,-mysql,-postgresql,-pgsql},functional,pep8 +envlist = py{27,35}{,-mysql,-postgresql},functional,pep8 [testenv] # NOTE(tonyb): This project has chosen to *NOT* consume upper-constraints.txt @@ -14,25 +14,13 @@ setenv = AODH_TEST_DEPS=postgresql,mysql mysql: AODH_TEST_DEPS=mysql 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}] passenv = OS_TEST_TIMEOUT OS_STDOUT_CAPTURE OS_STDERR_CAPTURE OS_LOG_CAPTURE AODH_TEST_DRIVERS commands = {toxinidir}/run-tests.sh --black-regex '^aodh\.tests\.tempest\..*$' {posargs} + {toxinidir}/run-functional-tests.sh "{posargs}" 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] commands = pifpaf -g AODH_TEST_STORAGE_URL run mysql -- python setup.py testr --slowest --coverage --testr-args="{posargs}"