summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-01-16 18:36:23 +0000
committerGerrit Code Review <review@openstack.org>2015-01-16 18:36:23 +0000
commitf640b5e3f8b374892645549693bb557efdc448db (patch)
tree9f30e127265be837bd89926b33d972848de92af5
parent33d48509bcf0e6afe7637ce4ec2c072c8412fc3a (diff)
parent72750165445f4c39e2b830c82daadf1d3fa2786a (diff)
downloadoslosphinx-f640b5e3f8b374892645549693bb557efdc448db.tar.gz
Merge "Add run_cross_tests.sh from incubator"
-rw-r--r--.gitignore1
-rw-r--r--openstack-common.conf7
-rwxr-xr-xtools/run_cross_tests.sh91
3 files changed, 99 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 54989fa..ae9850e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,3 +20,4 @@ doc/source/api/tests.*.rst
doc/source/api/autoindex.rst
doc/source/sourcecode
*.mo
+.update-venv
diff --git a/openstack-common.conf b/openstack-common.conf
new file mode 100644
index 0000000..2bae3b4
--- /dev/null
+++ b/openstack-common.conf
@@ -0,0 +1,7 @@
+[DEFAULT]
+
+# The list of modules to copy from oslo-incubator.git
+script = tools/run_cross_tests.sh
+
+# The base module to hold the copy of openstack.common
+base=oslosphinx
diff --git a/tools/run_cross_tests.sh b/tools/run_cross_tests.sh
new file mode 100755
index 0000000..5e7bc11
--- /dev/null
+++ b/tools/run_cross_tests.sh
@@ -0,0 +1,91 @@
+#!/bin/bash
+#
+# Run cross-project tests
+#
+# Usage:
+#
+# run_cross_tests.sh project_dir venv
+
+# Fail the build if any command fails
+set -e
+
+project_dir="$1"
+venv="$2"
+
+if [ -z "$project_dir" -o -z "$venv" ]
+then
+ cat - <<EOF
+ERROR: Missing argument(s)
+
+Usage:
+
+ $0 PROJECT_DIR VIRTUAL_ENV
+
+Example, run the python 2.7 tests for python-neutronclient:
+
+ $0 /opt/stack/python-neutronclient py27
+
+EOF
+ exit 1
+fi
+
+# Set up the virtualenv without running the tests
+(cd $project_dir && tox --notest -e $venv)
+
+tox_envbin=$project_dir/.tox/$venv/bin
+
+our_name=$(python setup.py --name)
+
+# Replace the pip-installed package with the version in our source
+# tree. Look to see if we are already installed before trying to
+# uninstall ourselves, to avoid failures from packages that do not use us
+# yet.
+if $tox_envbin/pip freeze | grep -q $our_name
+then
+ $tox_envbin/pip uninstall -y $our_name
+fi
+$tox_envbin/pip install -U .
+
+# Run the tests
+(cd $project_dir && tox -e $venv)
+result=$?
+
+
+# The below checks are modified from
+# openstack-infra/config/modules/jenkins/files/slave_scripts/run-unittests.sh.
+
+# They expect to be run in the project being tested.
+cd $project_dir
+
+echo "Begin pip freeze output from test virtualenv:"
+echo "======================================================================"
+.tox/$venv/bin/pip freeze
+echo "======================================================================"
+
+# We only want to run the next check if the tool is installed, so look
+# for it before continuing.
+if [ -f /usr/local/jenkins/slave_scripts/subunit2html.py -a -d ".testrepository" ] ; then
+ if [ -f ".testrepository/0.2" ] ; then
+ cp .testrepository/0.2 ./subunit_log.txt
+ elif [ -f ".testrepository/0" ] ; then
+ .tox/$venv/bin/subunit-1to2 < .testrepository/0 > ./subunit_log.txt
+ fi
+ .tox/$venv/bin/python /usr/local/jenkins/slave_scripts/subunit2html.py ./subunit_log.txt testr_results.html
+ gzip -9 ./subunit_log.txt
+ gzip -9 ./testr_results.html
+
+ export PYTHON=.tox/$venv/bin/python
+ set -e
+ rancount=$(.tox/$venv/bin/testr last | sed -ne 's/Ran \([0-9]\+\).*tests in.*/\1/p')
+ if [ "$rancount" -eq "0" ] ; then
+ echo
+ echo "Zero tests were run. At least one test should have been run."
+ echo "Failing this test as a result"
+ echo
+ exit 1
+ fi
+fi
+
+# If we make it this far, report status based on the tests that were
+# run.
+exit $result