diff options
| author | Qiu Yu <unicell@gmail.com> | 2013-06-06 23:45:41 +0800 |
|---|---|---|
| committer | Qiu Yu <unicell@gmail.com> | 2013-06-07 00:16:27 +0800 |
| commit | a24d3dabc1f4ca506ab6d542e4ec1d87bbdd09b8 (patch) | |
| tree | 4c28db44afc6d684924983d063b032b46aabc8e4 | |
| parent | 0d81ea487fa470d928da7481d5a455ed918be6aa (diff) | |
| download | nova-a24d3dabc1f4ca506ab6d542e4ec1d87bbdd09b8.tar.gz nova-a24d3dabc1f4ca506ab6d542e4ec1d87bbdd09b8.tar.xz nova-a24d3dabc1f4ca506ab6d542e4ec1d87bbdd09b8.zip | |
Skip ipv6 tests on system without ipv6 support
On system without ipv6 support, CONFIG_IPV6 disabled kernel for
instance, WSGI service testcases for ipv6 would fail for "[Errno 97]
Address family not supported by protocol".
Since there is no easy way to detect actual ipv6 support,
socket.has_ipv6 not working for this case, simply skip ipv6 tests if
errno.EAFNOSUPPORT happens.
Fixes: bug 1174404
Change-Id: I9fa8653f5ccfbcb8c31c51bfda137cb58388afde
| -rw-r--r-- | nova/tests/test_service.py | 3 | ||||
| -rw-r--r-- | nova/tests/test_wsgi.py | 5 | ||||
| -rw-r--r-- | nova/tests/utils.py | 14 |
3 files changed, 22 insertions, 0 deletions
diff --git a/nova/tests/test_service.py b/nova/tests/test_service.py index 3ca6d7bc1..055e46bfd 100644 --- a/nova/tests/test_service.py +++ b/nova/tests/test_service.py @@ -21,6 +21,7 @@ Unit Tests for remote procedure calls using queue """ import sys +import testtools import mox from oslo.config import cfg @@ -31,6 +32,7 @@ from nova import exception from nova import manager from nova import service from nova import test +from nova.tests import utils from nova import wsgi test_service_opts = [ @@ -184,6 +186,7 @@ class TestWSGIService(test.TestCase): self.assertNotEqual(0, test_service.port) test_service.stop() + @testtools.skipIf(not utils.is_ipv6_supported(), "no ipv6 support") def test_service_random_port_with_ipv6(self): CONF.set_default("test_service_listen", "::1") test_service = service.WSGIService("test_service") diff --git a/nova/tests/test_wsgi.py b/nova/tests/test_wsgi.py index cd64688a2..d1d659fe3 100644 --- a/nova/tests/test_wsgi.py +++ b/nova/tests/test_wsgi.py @@ -20,6 +20,7 @@ import os.path import tempfile +import testtools import eventlet import httplib2 @@ -27,6 +28,7 @@ import paste import nova.exception from nova import test +from nova.tests import utils import nova.wsgi import urllib2 import webob @@ -101,6 +103,7 @@ class TestWSGIServer(test.TestCase): server.stop() server.wait() + @testtools.skipIf(not utils.is_ipv6_supported(), "no ipv6 support") def test_start_random_port_with_ipv6(self): server = nova.wsgi.Server("test_random_port", None, host="::1", port=0) @@ -198,6 +201,7 @@ class TestWSGIServerWithSSL(test.TestCase): fake_ssl_server.stop() fake_ssl_server.wait() + @testtools.skipIf(not utils.is_ipv6_supported(), "no ipv6 support") def test_app_using_ipv6_and_ssl(self): greetings = 'Hello, World!!!' @@ -210,6 +214,7 @@ class TestWSGIServerWithSSL(test.TestCase): host="::1", port=0, use_ssl=True) + server.start() response = urllib2.urlopen('https://[::1]:%d/' % server.port) diff --git a/nova/tests/utils.py b/nova/tests/utils.py index 3d429aada..35c25b9c3 100644 --- a/nova/tests/utils.py +++ b/nova/tests/utils.py @@ -14,7 +14,9 @@ # License for the specific language governing permissions and limitations # +import errno import platform +import socket from oslo.config import cfg @@ -200,3 +202,15 @@ def killer_xml_body(): 'c': '&b;' * 10, 'd': '&c;' * 9999, }).strip() + + +def is_ipv6_supported(): + has_ipv6_support = True + try: + s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) + except socket.error as e: + if e.errno == errno.EAFNOSUPPORT: + has_ipv6_support = False + else: + raise e + return has_ipv6_support |
