Collect test result reports

Fix the post_test_hook.sh and tox.ini to use right tox enviroment.
Post_test_hook.sh collects the result reports.

Change-Id: Ie60cd55521d89cb2e00f3ecff0fe3af989e0f6ea
Closes-bug: 1559861
This commit is contained in:
gong yong sheng 2016-03-21 14:54:58 +08:00
parent 8b0d413b1c
commit 8bdccea2bb
4 changed files with 74 additions and 20 deletions

View File

@ -14,26 +14,65 @@
# This script is executed inside post_test_hook function in devstack gate. # This script is executed inside post_test_hook function in devstack gate.
VENV=${1:-"dsvm-functional"} set -xe
export GATE_DEST=$BASE/new TACKER_DIR="$BASE/new/tacker"
export DEVSTACK_DIR=$GATE_DEST/devstack SCRIPTS_DIR="/usr/os-testr-env/bin/"
export TACKER_DIR="$GATE_DEST/tacker"
case $VENV in venv=${1:-"dsvm-functional"}
dsvm-functional)
owner=stack
;;
esac
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 sudo chown -R $owner:stack $TACKER_DIR
cd $TACKER_DIR # Run tests
echo "Running tacker $venv test suite"
set +e
# Run functional tests sudo -H -u $owner $sudo_env tox -e $venv
echo "Running Tacker $VENV test suite" testr_exit_code=$?
source $DEVSTACK_DIR/openrc admin admin set -e
sudo -E -H -u $owner tox -e functional -- --concurrency=1
EXIT_CODE=$? # Collect and parse results
generate_testr_results
exit $testr_exit_code
exit $EXIT_CODE

View File

@ -4,7 +4,7 @@
# Despite above warning added by global sync process, please use # Despite above warning added by global sync process, please use
# ascii betical order. # 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 cliff!=1.16.0,!=1.17.0,>=1.15.0 # Apache-2.0
coverage>=3.6 # Apache-2.0 coverage>=3.6 # Apache-2.0
discover # BSD discover # BSD
@ -16,6 +16,7 @@ python-subunit>=0.0.18 # Apache-2.0/BSD
ordereddict # MIT ordereddict # MIT
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 # BSD sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 # BSD
oslotest>=1.10.0 # Apache-2.0 oslotest>=1.10.0 # Apache-2.0
os-testr>=0.4.1 # Apache-2.0
tempest-lib>=0.14.0 # Apache-2.0 tempest-lib>=0.14.0 # Apache-2.0
testrepository>=0.0.18 # Apache-2.0/BSD testrepository>=0.0.18 # Apache-2.0/BSD
testtools>=1.4.0 # MIT testtools>=1.4.0 # MIT

8
tools/ostestr_compat_shim.sh Executable file
View File

@ -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

12
tox.ini
View File

@ -22,13 +22,19 @@ commands =
python -m tacker.openstack.common.lockutils python setup.py testr --slowest --testr-args='{posargs}' python -m tacker.openstack.common.lockutils python setup.py testr --slowest --testr-args='{posargs}'
[testenv:functional] [testenv:functional]
sitepackages = True
setenv = OS_TEST_PATH=./tacker/tests/functional setenv = OS_TEST_PATH=./tacker/tests/functional
commands =
python setup.py testr --slowest --testr-args='{posargs}'
deps = deps =
{[testenv]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] [tox:jenkins]
sitepackages = True sitepackages = True