diff --git a/tacker/tests/contrib/post_test_hook.sh b/tacker/tests/contrib/post_test_hook.sh index 2f96ba4c5..99411b36c 100755 --- a/tacker/tests/contrib/post_test_hook.sh +++ b/tacker/tests/contrib/post_test_hook.sh @@ -14,26 +14,65 @@ # This script is executed inside post_test_hook function in devstack gate. -VENV=${1:-"dsvm-functional"} +set -xe -export GATE_DEST=$BASE/new -export DEVSTACK_DIR=$GATE_DEST/devstack -export TACKER_DIR="$GATE_DEST/tacker" +TACKER_DIR="$BASE/new/tacker" +SCRIPTS_DIR="/usr/os-testr-env/bin/" -case $VENV in - dsvm-functional) - owner=stack - ;; -esac +venv=${1:-"dsvm-functional"} +function generate_test_logs { + local path="$1" + # Compress all $path/*.txt files and move the directories holding those + # files to /opt/stack/logs. Files with .log suffix have their + # suffix changed to .txt (so browsers will know to open the compressed + # files and not download them). + if [ -d "$path" ] + then + sudo find $path -iname "*.log" -type f -exec mv {} {}.txt \; -exec gzip -9 {}.txt \; + sudo mv $path/* /opt/stack/logs/ + fi +} + +function generate_testr_results { + # Give job user rights to access tox logs + sudo -H -u $owner chmod o+rw . + sudo -H -u $owner chmod o+rw -R .testrepository + if [ -f ".testrepository/0" ] ; then + .tox/$venv/bin/subunit-1to2 < .testrepository/0 > ./testrepository.subunit + $SCRIPTS_DIR/subunit2html ./testrepository.subunit testr_results.html + gzip -9 ./testrepository.subunit + gzip -9 ./testr_results.html + sudo mv ./*.gz /opt/stack/logs/ + fi + + if [[ "$venv" == dsvm-functional* ]] + then + generate_test_logs $log_dir + fi +} + + +if [[ "$venv" == dsvm-functional* ]] +then + owner=stack + sudo_env= + log_dir="/tmp/${venv}-logs" +fi + +# Set owner permissions according to job's requirements. +cd $TACKER_DIR sudo chown -R $owner:stack $TACKER_DIR -cd $TACKER_DIR +# Run tests +echo "Running tacker $venv test suite" +set +e -# Run functional tests -echo "Running Tacker $VENV test suite" -source $DEVSTACK_DIR/openrc admin admin -sudo -E -H -u $owner tox -e functional -- --concurrency=1 -EXIT_CODE=$? +sudo -H -u $owner $sudo_env tox -e $venv +testr_exit_code=$? +set -e + +# Collect and parse results +generate_testr_results +exit $testr_exit_code -exit $EXIT_CODE diff --git a/test-requirements.txt b/test-requirements.txt index 051a6d442..e966c7c11 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,7 +4,7 @@ # Despite above warning added by global sync process, please use # ascii betical order. - +http://tarballs.openstack.org/python-tackerclient/python-tackerclient-master.tar.gz#egg=python-tackerclient cliff!=1.16.0,!=1.17.0,>=1.15.0 # Apache-2.0 coverage>=3.6 # Apache-2.0 discover # BSD @@ -16,6 +16,7 @@ python-subunit>=0.0.18 # Apache-2.0/BSD ordereddict # MIT sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 # BSD oslotest>=1.10.0 # Apache-2.0 +os-testr>=0.4.1 # Apache-2.0 tempest-lib>=0.14.0 # Apache-2.0 testrepository>=0.0.18 # Apache-2.0/BSD testtools>=1.4.0 # MIT diff --git a/tools/ostestr_compat_shim.sh b/tools/ostestr_compat_shim.sh new file mode 100755 index 000000000..a483ed1a1 --- /dev/null +++ b/tools/ostestr_compat_shim.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# preserve old behavior of using an arg as a regex when '--' is not present +case $@ in + (*--*) ostestr $@;; + ('') ostestr;; + (*) ostestr --regex "$@" +esac diff --git a/tox.ini b/tox.ini index 391cd117a..404794c07 100644 --- a/tox.ini +++ b/tox.ini @@ -22,13 +22,19 @@ commands = python -m tacker.openstack.common.lockutils python setup.py testr --slowest --testr-args='{posargs}' [testenv:functional] -sitepackages = True setenv = OS_TEST_PATH=./tacker/tests/functional -commands = - python setup.py testr --slowest --testr-args='{posargs}' deps = {[testenv]deps} +[testenv:dsvm-functional] +basepython = python2.7 +setenv = {[testenv]setenv} + {[testenv:functional]setenv} +deps = + {[testenv:functional]deps} +commands = + {toxinidir}/tools/ostestr_compat_shim.sh {posargs} + [tox:jenkins] sitepackages = True