From 24a84d04e7e5fd06083a8e8ee383c0abaceeebc1 Mon Sep 17 00:00:00 2001 From: john-griffith Date: Fri, 18 Jan 2013 10:07:10 -0700 Subject: [PATCH] Clean up IPV6 config checks in test_wsgi. 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 | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/cinder/tests/test_wsgi.py b/cinder/tests/test_wsgi.py index f69c7e0a4..0060442f9 100644 --- a/cinder/tests/test_wsgi.py +++ b/cinder/tests/test_wsgi.py @@ -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", -- 2.45.2