]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add a gate-specific tox env for functional tests
authorMaru Newby <marun@redhat.com>
Wed, 2 Jul 2014 00:35:12 +0000 (00:35 +0000)
committerMaru Newby <marun@redhat.com>
Wed, 9 Jul 2014 06:05:11 +0000 (06:05 +0000)
The functional gate jobs (*-neutron-dsvm-functional) need special
configuration (e.g. OS_SUDO_TESTING, OS_ROOTWRAP_CMD) to run tests.
This patch adds a new gate-specific tox env (tox -e dsvm-functional)
that sets the appropriate values and allows easy duplication of the
results of the upstream job on a host that has successfully run
devstack with neutron enabled.

A new configuration option, OS_FAIL_ON_MISSING_DEPS, is also set by
the dsvm-functional tox env to ensure that dependency failures will
result in failures rather than skips when run in the gate.

Change-Id: Idbfef1ba72ed129a3021509c7969e2685b8a6d09
Partial-bug: #1336172

TESTING.rst
neutron/tests/functional/agent/linux/base.py
neutron/tests/functional/agent/linux/test_ovsdb_monitor.py
neutron/tests/functional/base.py
tox.ini

index 0d6814e8ee8de431856c3eb8031b719d9af30276..64a217f83e70a91da29e9a3938c619f972993152 100644 (file)
@@ -4,16 +4,16 @@ Testing Neutron
 Overview
 --------
 
-The unit tests are meant to cover as much code as possible and should
-be executed without the service running. They are designed to test
-the various pieces of the neutron tree to make sure any new changes
-don't break existing functionality.
+The unit tests (neutron/test/unit/) are meant to cover as much code as
+possible and should be executed without the service running. They are
+designed to test the various pieces of the neutron tree to make sure
+any new changes don't break existing functionality.
 
-The functional tests are intended to validate actual system
-interaction.  Mocks should be used sparingly, if at all.  Care
-should be taken to ensure that existing system resources are not
-modified and that resources created in tests are properly cleaned
-up.
+The functional tests (neutron/tests/functional/) are intended to
+validate actual system interaction.  Mocks should be used sparingly,
+if at all.  Care should be taken to ensure that existing system
+resources are not modified and that resources created in tests are
+properly cleaned up.
 
 Development process
 -------------------
@@ -100,6 +100,16 @@ Neutron source code::
 
     tox
 
+To run functional tests that do not require sudo privileges or
+specific-system dependencies::
+
+    tox -e functional
+
+To run all the functional tests in an environment that has been configured
+by devstack to support sudo and system-specific dependencies::
+
+    tox -e dsvm-functional
+
 For more information on the standard Tox-based test infrastructure used by
 OpenStack and how to do some common test/debugging procedures with Testr,
 see this wiki page:
index 5891c872e9fa66e4cde7d0f54a2c4f13ba628ceb..29198004ae281796ff78d9f70723e5e88a15f3f7 100644 (file)
@@ -29,7 +29,7 @@ class BaseLinuxTestCase(functional_base.BaseSudoTestCase):
         try:
             utils.execute(cmd, root_helper=root_helper)
         except RuntimeError as e:
-            if error_text in str(e):
+            if error_text in str(e) and not self.fail_on_missing_deps:
                 self.skipTest(skip_msg)
             raise
 
index 9d8570deda17aa6cbac725d5587d7ffa42a68913..3f37ce0edc4493da3b71f81eae0413c30da2cfd5 100644 (file)
@@ -47,8 +47,6 @@ class BaseMonitorTest(linux_base.BaseOVSLinuxTestCase):
 
     def _check_test_requirements(self):
         self.check_sudo_enabled()
-        self.check_command(['which', 'ovsdb-client'],
-                           'Exit code: 1', 'ovsdb-client is not installed')
         self.check_command(['ovsdb-client', 'list-dbs'],
                            'Exit code: 1',
                            'password-less sudo not granted for ovsdb-client',
index 471acaea64c977416c8886a854bd752fa7ba6295..fe25535fa92bf83c41a29a719ad792d2acf2e7ba 100644 (file)
@@ -46,8 +46,12 @@ class BaseSudoTestCase(base.BaseTestCase):
 
     def setUp(self):
         super(BaseSudoTestCase, self).setUp()
-        self.root_helper = os.environ.get('OS_ROOTWRAP_CMD', SUDO_CMD)
+        env = os.environ
+        self.sudo_enabled = env.get('OS_SUDO_TESTING') in base.TRUE_STRING
+        self.root_helper = env.get('OS_ROOTWRAP_CMD', SUDO_CMD)
+        self.fail_on_missing_deps = (
+            env.get('OS_FAIL_ON_MISSING_DEPS') in base.TRUE_STRING)
 
     def check_sudo_enabled(self):
-        if os.environ.get('OS_SUDO_TESTING') not in base.TRUE_STRING:
+        if not self.sudo_enabled:
             self.skipTest('testing with sudo is not enabled')
diff --git a/tox.ini b/tox.ini
index d459887c3e529ab81b4265f206210af1a35bd37b..5891515f40ddee5af5665eab3b9f55ab4e7728ec 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -18,6 +18,14 @@ setenv = OS_TEST_PATH=./neutron/tests/functional
 commands =
   python setup.py testr --slowest --testr-args='{posargs}'
 
+[testenv:dsvm-functional]
+setenv = OS_TEST_PATH=./neutron/tests/functional
+         OS_SUDO_TESTING=1
+         OS_ROOTWRAP_CMD=sudo /usr/local/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
+         OS_FAIL_ON_MISSING_DEPS=1
+commands =
+  python setup.py testr --slowest --testr-args='{posargs}'
+
 [tox:jenkins]
 sitepackages = True
 downloadcache = ~/cache/pip