FWaaS: Reorganize unit test tree
Similar to what is happening in Neutron, this commit renames and moves unit test files so that they match the directory structure of the code tree. Since the FWaaS repo's test files have imports from Neutron, there are import changes as well, to the imports to match the Neutron test file organization. A check script is added to monitor the test file naming and locations (to ensure consistency). Note: In the future the Neutron check_unit_test_structure.sh should be made configurable, and duplicate files removed from *aaS repos. Change-Id: I4cf1093eac88f62bbe1303233bfd37058db3821a Closes-Bug: #1441501
This commit is contained in:
parent
3a6cca8dd5
commit
96dc29350d
@ -15,7 +15,7 @@
|
||||
#
|
||||
|
||||
from neutron.tests import base as n_base
|
||||
from neutron.tests.unit import test_db_plugin
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2 as test_db_plugin
|
||||
|
||||
|
||||
class BaseTestCase(n_base.BaseTestCase):
|
||||
|
@ -19,8 +19,8 @@ import mock
|
||||
from neutron.openstack.common import uuidutils
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.tests import base
|
||||
from neutron.tests.unit import test_api_v2
|
||||
from neutron.tests.unit import test_api_v2_extension
|
||||
from neutron.tests.unit.api.v2 import test_base as test_api_v2
|
||||
from neutron.tests.unit.extensions import base as test_api_v2_extension
|
||||
from webob import exc
|
||||
import webtest
|
||||
|
0
neutron_fwaas/tests/unit/services/firewall/agents/varmour/__init__.py
Executable file → Normal file
0
neutron_fwaas/tests/unit/services/firewall/agents/varmour/__init__.py
Executable file → Normal file
@ -18,7 +18,7 @@ from oslo_config import cfg
|
||||
|
||||
from neutron.agent.common import config as a_cfg
|
||||
from neutron.tests import base
|
||||
from neutron.tests.unit import test_api_v2
|
||||
from neutron.tests.unit.api.v2 import test_base as test_api_v2
|
||||
import neutron_fwaas.services.firewall.drivers.linux.iptables_fwaas as fwaas
|
||||
|
||||
|
||||
|
0
neutron_fwaas/tests/unit/services/firewall/drivers/mcafee/__init__.py
Executable file → Normal file
0
neutron_fwaas/tests/unit/services/firewall/drivers/mcafee/__init__.py
Executable file → Normal file
0
neutron_fwaas/tests/unit/services/firewall/drivers/varmour/__init__.py
Executable file → Normal file
0
neutron_fwaas/tests/unit/services/firewall/drivers/varmour/__init__.py
Executable file → Normal file
@ -21,7 +21,8 @@ from neutron import manager
|
||||
from webob import exc
|
||||
|
||||
from neutron.plugins.common import constants as const
|
||||
from neutron_fwaas.tests.unit.db.firewall import test_db_firewall
|
||||
from neutron_fwaas.tests.unit.db.firewall import (
|
||||
test_firewall_db as test_db_firewall)
|
||||
|
||||
"""Unit testing for Freescale FWaaS Plugin."""
|
||||
|
@ -20,20 +20,22 @@ from neutron.api.v2 import attributes as attr
|
||||
from neutron import context
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as const
|
||||
from neutron.tests.unit import test_l3_plugin
|
||||
from neutron.tests.unit.extensions import test_l3 as test_l3_plugin
|
||||
|
||||
import neutron_fwaas
|
||||
from neutron_fwaas.db.cisco import cisco_fwaas_db as csrfw_db
|
||||
from neutron_fwaas.extensions.cisco import csr_firewall_insertion
|
||||
from neutron_fwaas.extensions import firewall
|
||||
from neutron_fwaas.services.firewall.plugins.cisco import cisco_fwaas_plugin
|
||||
from neutron_fwaas.tests.unit.db.firewall import test_db_firewall
|
||||
from neutron_fwaas.tests.unit.db.firewall import (
|
||||
test_firewall_db as test_db_firewall)
|
||||
from oslo_config import cfg
|
||||
|
||||
# We need the test_l3_plugin to ensure we have a valid port_id corresponding
|
||||
# to a router interface.
|
||||
CORE_PLUGIN_KLASS = 'neutron.tests.unit.test_l3_plugin.TestNoL3NatPlugin'
|
||||
L3_PLUGIN_KLASS = 'neutron.tests.unit.test_l3_plugin.TestL3NatServicePlugin'
|
||||
CORE_PLUGIN_KLASS = 'neutron.tests.unit.extensions.test_l3.TestNoL3NatPlugin'
|
||||
L3_PLUGIN_KLASS = (
|
||||
'neutron.tests.unit.extensions.test_l3.TestL3NatServicePlugin')
|
||||
# the plugin under test
|
||||
CSR_FW_PLUGIN_KLASS = (
|
||||
"neutron_fwaas.services.firewall.plugins.cisco.cisco_fwaas_plugin."
|
||||
|
@ -22,7 +22,7 @@ from neutron.api.v2 import attributes as attr
|
||||
from neutron import context
|
||||
from neutron import manager
|
||||
from neutron.plugins.common import constants as const
|
||||
from neutron.tests.unit import test_l3_plugin
|
||||
from neutron.tests.unit.extensions import test_l3 as test_l3_plugin
|
||||
from oslo_config import cfg
|
||||
from webob import exc
|
||||
|
||||
@ -31,7 +31,8 @@ from neutron_fwaas.extensions import firewall
|
||||
from neutron_fwaas.extensions import firewallrouterinsertion
|
||||
from neutron_fwaas.services.firewall import fwaas_plugin
|
||||
from neutron_fwaas.tests import base
|
||||
from neutron_fwaas.tests.unit.db.firewall import test_db_firewall
|
||||
from neutron_fwaas.tests.unit.db.firewall import (
|
||||
test_firewall_db as test_db_firewall)
|
||||
|
||||
extensions_path = neutron_fwaas.extensions.__path__[0]
|
||||
|
||||
@ -66,9 +67,9 @@ class TestFirewallRouterInsertionBase(
|
||||
plugin = None
|
||||
# the plugin without L3 support
|
||||
if not plugin:
|
||||
plugin = 'neutron.tests.unit.test_l3_plugin.TestNoL3NatPlugin'
|
||||
plugin = 'neutron.tests.unit.extensions.test_l3.TestNoL3NatPlugin'
|
||||
# the L3 service plugin
|
||||
l3_plugin = ('neutron.tests.unit.test_l3_plugin.'
|
||||
l3_plugin = ('neutron.tests.unit.extensions.test_l3.'
|
||||
'TestL3NatServicePlugin')
|
||||
|
||||
cfg.CONF.set_override('api_extensions_path', extensions_path)
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
# Ignore comments, but include shebangs
|
||||
OBSERVED=$(grep -E '^([^#]|#!).*bash' tox.ini tools/* | wc -l)
|
||||
EXPECTED=5
|
||||
EXPECTED=6
|
||||
if [ ${EXPECTED} -ne ${OBSERVED} ]; then
|
||||
echo Unexpected number of bash usages are detected.
|
||||
echo Please read the comment in $0
|
||||
|
52
tools/check_unit_test_structure.sh
Executable file
52
tools/check_unit_test_structure.sh
Executable file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script identifies the unit test modules that do not correspond
|
||||
# directly with a module in the code tree. See TESTING.rst for the
|
||||
# intended structure.
|
||||
|
||||
neutron_path=$(cd "$(dirname "$0")/.." && pwd)
|
||||
base_test_path=neutron_fwaas/tests/unit
|
||||
test_path=$neutron_path/$base_test_path
|
||||
|
||||
test_files=$(find ${test_path} -iname 'test_*.py')
|
||||
|
||||
ignore_regexes=(
|
||||
"^plugins.*$"
|
||||
)
|
||||
|
||||
error_count=0
|
||||
ignore_count=0
|
||||
total_count=0
|
||||
for test_file in ${test_files[@]}; do
|
||||
relative_path=${test_file#$test_path/}
|
||||
expected_path=$(dirname $neutron_path/neutron_fwaas/$relative_path)
|
||||
test_filename=$(basename "$test_file")
|
||||
expected_filename=${test_filename#test_}
|
||||
# Module filename (e.g. foo/bar.py -> foo/test_bar.py)
|
||||
filename=$expected_path/$expected_filename
|
||||
# Package dir (e.g. foo/ -> test_foo.py)
|
||||
package_dir=${filename%.py}
|
||||
if [ ! -f "$filename" ] && [ ! -d "$package_dir" ]; then
|
||||
for ignore_regex in ${ignore_regexes[@]}; do
|
||||
if [[ "$relative_path" =~ $ignore_regex ]]; then
|
||||
((ignore_count++))
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
echo "Unexpected test file: $base_test_path/$relative_path"
|
||||
((error_count++))
|
||||
fi
|
||||
((total_count++))
|
||||
done
|
||||
|
||||
if [ "$ignore_count" -ne 0 ]; then
|
||||
echo "$ignore_count unmatched test modules were ignored"
|
||||
fi
|
||||
|
||||
if [ "$error_count" -eq 0 ]; then
|
||||
echo 'Success! All test modules match targets in the code tree.'
|
||||
exit 0
|
||||
else
|
||||
echo "Failure! $error_count of $total_count test modules do not match targets in the code tree."
|
||||
exit 1
|
||||
fi
|
3
tox.ini
3
tox.ini
@ -47,8 +47,7 @@ downloadcache = ~/cache/pip
|
||||
commands =
|
||||
sh ./tools/check_bash.sh
|
||||
flake8
|
||||
#neutron-db-manage check_migration
|
||||
#sh -c "find neutron-fwaas -type f -regex '.*\.pot?' -print0|xargs -0 -n 1 msgfmt --check-format -o /dev/null"
|
||||
{toxinidir}/tools/check_unit_test_structure.sh
|
||||
whitelist_externals = sh
|
||||
|
||||
[testenv:i18n]
|
||||
|
Loading…
Reference in New Issue
Block a user