From a69ba853a78090d0e23be2dd5f8f2e5d4e564df4 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Sun, 6 Jan 2019 15:05:43 +0900 Subject: [PATCH] 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 --- openstack_dashboard/test/helpers.py | 7 +++++++ tools/unit_tests.sh | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/openstack_dashboard/test/helpers.py b/openstack_dashboard/test/helpers.py index c146b1b2c5..002336467b 100644 --- a/openstack_dashboard/test/helpers.py +++ b/openstack_dashboard/test/helpers.py @@ -537,6 +537,13 @@ def my_custom_sort(flavor): return sort_order[flavor.name] +# TODO(amotoki): Investigate a way to run PluginTestCase with the main +# unit tests. Currently we fail to find a way to clean up urlpatterns and +# Site registry touched by setUp() cleanly. As a workaround, we run +# PluginTestCase as a separate test process. Hopefully this workaround has gone +# in future. For more detail, see bug 1809983 and +# https://review.openstack.org/#/c/627640/. +@tag('plugin-test') class PluginTestCase(TestCase): """Test case for testing plugin system of Horizon. diff --git a/tools/unit_tests.sh b/tools/unit_tests.sh index 641ffd27ac..e42ec9c7bc 100755 --- a/tools/unit_tests.sh +++ b/tools/unit_tests.sh @@ -2,7 +2,7 @@ testcommand="${1} ${2}/manage.py test" posargs="${@:3}" -tagarg="--exclude-tag selenium --exclude-tag integration" +tagarg="--exclude-tag selenium --exclude-tag integration --exclude-tag plugin-test" if [[ -n "${WITH_SELENIUM}" ]] then @@ -34,6 +34,8 @@ if [ -n "$subset" ]; 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 @@ -42,9 +44,11 @@ else 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 ]]; then + $auth_tests != 0 || $plugin_tests != 0 ]]; then exit 1; fi fi