]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Clean up IPV6 config checks in test_wsgi.
authorjohn-griffith <john.griffith@solidfire.com>
Fri, 18 Jan 2013 17:07:10 +0000 (10:07 -0700)
committerJohn Griffith <john.griffith@solidfire.com>
Sun, 20 Jan 2013 02:52:19 +0000 (19:52 -0700)
Two tests in test_wsgi require a configured IPV6 interface.
We added a check/skip for this but it wasn't very graceful and
didn't work on OS-X or platforms other than Linux.

This patch implements the checks a bit cleaner using the skip_if
decorator, and combines the linux/path check and configured interface
check.

Change-Id: I950fdfeb8135912faf5dcaabe52fb87abd73dd1e

cinder/tests/test_wsgi.py

index f69c7e0a4143ec597181af964e901736a14c4478..0060442f9313f925199e83915ebd54e587e4e96f 100644 (file)
@@ -89,6 +89,15 @@ document_root = /tmp
 
 class TestWSGIServer(unittest.TestCase):
     """WSGI server tests."""
+    def _ipv6_configured():
+        try:
+            out, err = utils.execute('cat', '/proc/net/if_inet6')
+        except exception.ProcessExecutionError:
+            return False
+
+        if not out:
+            return False
+        return True
 
     def test_no_app(self):
         server = cinder.wsgi.Server("test_app", None)
@@ -102,12 +111,9 @@ class TestWSGIServer(unittest.TestCase):
         server.stop()
         server.wait()
 
+    @test.skip_if(not _ipv6_configured(),
+                  "Test requires an IPV6 configured interface")
     def test_start_random_port_with_ipv6(self):
-        #check to see if we have IPV6 configured on this system
-        out, err = utils.execute('cat', '/proc/net/if_inet6')
-        if not out:
-            self.skipTest("No IPV6 interface configured")
-
         server = cinder.wsgi.Server("test_random_port",
                                     None,
                                     host="::1")
@@ -156,12 +162,9 @@ class TestWSGIServer(unittest.TestCase):
 
         server.stop()
 
+    @test.skip_if(not _ipv6_configured(),
+                  "Test requires an IPV6 configured interface")
     def test_app_using_ipv6_and_ssl(self):
-        #check to see if we have IPV6 configured on this system
-        out, err = utils.execute('cat', '/proc/net/if_inet6')
-        if not out:
-            self.skipTest("No IPV6 interface configured")
-
         CONF.set_default("ssl_cert_file",
                          os.path.join(TEST_VAR_DIR, 'certificate.crt'))
         CONF.set_default("ssl_key_file",