Description :
When running unittests for openstack swift. I have encountered some errors. The errors come in the unit tests from the file test_wsgi.py.
The following functions were being tested : (i) test_multiple_requests_with_proxy
(ii) test_request_with_proxy
(iii)test_request_with_proxy_https
(iv)test_unknown_client_addr
Version of Swift : 2.18.1.dev83
Actual Error Message(its pretty long) :
ERROR: test_multiple_requests_with_proxy (test.unit.common.test_wsgi.TestProxyProtocol)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/bharath1234/swift/test/unit/common/test_wsgi.py", line 1174, in test_multiple_requests_with_proxy
), wsgi.SwiftHttpProxiedProtocol)
File "/home/bharath1234/swift/test/unit/common/test_wsgi.py", line 1128, in _run_bytes_through_protocol
log_output=False, # quiet the test run
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 869, in server
pool.spawn_n(serv.process_request, client_socket)
File "/home/bharath1234/swift/test/unit/common/test_wsgi.py", line 1089, in spawn_n
a_callable(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 719, in process_request
proto.__init__(sock, address, self)
File "/home/bharath1234/swift/swift/common/wsgi.py", line 452, in __init__
SwiftHttpProtocol.__init__(self, *a, **kw)
File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
self.handle()
File "/home/bharath1234/swift/swift/common/wsgi.py", line 510, in handle
return SwiftHttpProtocol.handle(self)
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 379, in handle_one_request
self.environ = self.get_environ()
File "/home/bharath1234/swift/swift/common/wsgi.py", line 513, in get_environ
environ = SwiftHttpProtocol.get_environ(self)
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 590, in get_environ
host, port = self.request.getsockname()[:2]
TypeError: 'Mock' object has no attribute '__getitem__'
======================================================================
ERROR: test_request_with_proxy (test.unit.common.test_wsgi.TestProxyProtocol)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/bharath1234/swift/test/unit/common/test_wsgi.py", line 1138, in test_request_with_proxy
), wsgi.SwiftHttpProxiedProtocol)
File "/home/bharath1234/swift/test/unit/common/test_wsgi.py", line 1128, in _run_bytes_through_protocol
log_output=False, # quiet the test run
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 869, in server
pool.spawn_n(serv.process_request, client_socket)
File "/home/bharath1234/swift/test/unit/common/test_wsgi.py", line 1089, in spawn_n
a_callable(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 719, in process_request
proto.__init__(sock, address, self)
File "/home/bharath1234/swift/swift/common/wsgi.py", line 452, in __init__
SwiftHttpProtocol.__init__(self, *a, **kw)
File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
self.handle()
File "/home/bharath1234/swift/swift/common/wsgi.py", line 510, in handle
return SwiftHttpProtocol.handle(self)
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 379, in handle_one_request
self.environ = self.get_environ()
File "/home/bharath1234/swift/swift/common/wsgi.py", line 513, in get_environ
environ = SwiftHttpProtocol.get_environ(self)
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 590, in get_environ
host, port = self.request.getsockname()[:2]
TypeError: 'Mock' object has no attribute '__getitem__'
======================================================================
ERROR: test_request_with_proxy_https (test.unit.common.test_wsgi.TestProxyProtocol)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/bharath1234/swift/test/unit/common/test_wsgi.py", line 1154, in test_request_with_proxy_https
), wsgi.SwiftHttpProxiedProtocol)
File "/home/bharath1234/swift/test/unit/common/test_wsgi.py", line 1128, in _run_bytes_through_protocol
log_output=False, # quiet the test run
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 869, in server
pool.spawn_n(serv.process_request, client_socket)
File "/home/bharath1234/swift/test/unit/common/test_wsgi.py", line 1089, in spawn_n
a_callable(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 719, in process_request
proto.__init__(sock, address, self)
File "/home/bharath1234/swift/swift/common/wsgi.py", line 452, in __init__
SwiftHttpProtocol.__init__(self, *a, **kw)
File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
self.handle()
File "/home/bharath1234/swift/swift/common/wsgi.py", line 510, in handle
return SwiftHttpProtocol.handle(self)
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 379, in handle_one_request
self.environ = self.get_environ()
File "/home/bharath1234/swift/swift/common/wsgi.py", line 513, in get_environ
environ = SwiftHttpProtocol.get_environ(self)
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 590, in get_environ
host, port = self.request.getsockname()[:2]
TypeError: 'Mock' object has no attribute '__getitem__'
======================================================================
ERROR: test_unknown_client_addr (test.unit.common.test_wsgi.TestProxyProtocol)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/bharath1234/swift/test/unit/common/test_wsgi.py", line 1220, in test_unknown_client_addr
), wsgi.SwiftHttpProxiedProtocol)
File "/home/bharath1234/swift/test/unit/common/test_wsgi.py", line 1128, in _run_bytes_through_protocol
log_output=False, # quiet the test run
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 869, in server
pool.spawn_n(serv.process_request, client_socket)
File "/home/bharath1234/swift/test/unit/common/test_wsgi.py", line 1089, in spawn_n
a_callable(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 719, in process_request
proto.__init__(sock, address, self)
File "/home/bharath1234/swift/swift/common/wsgi.py", line 452, in __init__
SwiftHttpProtocol.__init__(self, *a, **kw)
File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
self.handle()
File "/home/bharath1234/swift/swift/common/wsgi.py", line 510, in handle
return SwiftHttpProtocol.handle(self)
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 379, in handle_one_request
self.environ = self.get_environ()
File "/home/bharath1234/swift/swift/common/wsgi.py", line 513, in get_environ
environ = SwiftHttpProtocol.get_environ(self)
File "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", line 590, in get_environ
host, port = self.request.getsockname()[:2]
TypeError: 'Mock' object has no attribute '__getitem__'
Solution :
This issue was solved by updating the eventlet package to 0.20.1. User must check the version of eventlet using pip show eventlet and proceed to update eventlet to 0.20.1(first remove the original version of eventlet by pip uninstall eventlet) by pip install eventlet==0.20.1.
I can reproduce this.
The cause is that older versions of eventlet expect getsocketname() to return a tuple, but the test mock returns a string.