horizon/tools/unit_tests.sh
Akihiro Motoki a69ba853a7 UT: Run test_plugins as separate process
This commit changes to run test_plugins in a separate process.

test_plugins touches urlpatterns and Site registry during setUp(),
but the cleanup process in tearDown does not recover urlpatterns correctly.
After tests under test_plugins run, the urlpatterns continues to have
entries of test panels and this leads to NoReverseMatch error when
rendering other panels after that.

I investigated details in setUp/tearDown of PluginTestCase but failed
to find a good solution to recover urlpatterns and Horizon Site registry.
As a workaround, runnig test_plugins in a separate process can avoid
the issue.

Closes-Bug: #1809983
Change-Id: I848f6b341b3f93ed055955b2b12d2497811edc5a
2019-01-31 21:29:29 +09:00

55 lines
2.0 KiB
Bash
Executable File

# Uses envpython and toxinidir from tox run to construct a test command
testcommand="${1} ${2}/manage.py test"
posargs="${@:3}"
tagarg="--exclude-tag selenium --exclude-tag integration --exclude-tag plugin-test"
if [[ -n "${WITH_SELENIUM}" ]]
then
tagarg="--tag selenium"
elif [[ -n "${INTEGRATION_TESTS}" ]]
then
tagarg="--tag integration"
#else
# tag="unit"
fi
# Attempt to identify if any of the arguments passed from tox is a test subset
if [ -n "$posargs" ]; then
for arg in "$posargs"
do
if [ ${arg:0:1} != "-" ]; then
subset=$arg
fi
done
fi
# If we are running a test subset, supply the correct settings file.
# If not, simply run the entire test suite.
if [ -n "$subset" ]; then
project="${subset%%.*}"
if [ $project == "horizon" ]; then
$testcommand --settings=horizon.test.settings --verbosity 2 $tagarg $posargs
elif [ $project == "openstack_dashboard" ]; then
$testcommand --settings=openstack_dashboard.test.settings --verbosity 2 $tagarg $posargs
elif [ $project == "openstack_auth" ]; then
$testcommand --settings=openstack_auth.tests.settings --verbosity 2 $tagarg $posargs
elif [ $project == "plugin-test" ]; then
$testcommand --settings=openstack_dashboard.test.settings --verbosity 2 --tag plugin-test openstack_dashboard.test.test_plugins
fi
else
$testcommand horizon --settings=horizon.test.settings --verbosity 2 $tagarg $posargs
horizon_tests=$?
$testcommand openstack_dashboard --settings=openstack_dashboard.test.settings --verbosity 2 $tagarg $posargs
openstack_dashboard_tests=$?
$testcommand openstack_auth --settings=openstack_auth.tests.settings --verbosity 2 $tagarg $posargs
auth_tests=$?
$testcommand --settings=openstack_dashboard.test.settings --verbosity 2 --tag plugin-test openstack_dashboard.test.test_plugins
plugin_tests=$?
# we have to tell tox if either of these test runs failed
if [[ $horizon_tests != 0 || $openstack_dashboard_tests != 0 || \
$auth_tests != 0 || $plugin_tests != 0 ]]; then
exit 1;
fi
fi