This is an automated email from the ASF dual-hosted git repository.

jdanek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git

commit 76ef8420f8b87e4c3699462998d05b8d9156c1c2
Author: Jiri Danek <[email protected]>
AuthorDate: Sun Mar 10 14:50:36 2019 -0700

    DISPATCH-1282 - Fix port checking in dispatch tests on macOS
    
    On macOS, sockets cannot be reused after a failure
    
    $ python
    >>> import socket
    >>> s = socket.socket()
    >>> s.connect(('127.0.0.1', 8888))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py",
 line 228, in meth
        return getattr(self._sock,name)(*args)
    socket.error: [Errno 61] Connection refused
    >>> s.connect(('127.0.0.1', 8888))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py",
 line 228, in meth
        return getattr(self._sock,name)(*args)
    socket.error: [Errno 22] Invalid argument
    >>> s.close()
    >>> s.connect(('127.0.0.1', 8888))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py",
 line 228, in meth
        return getattr(self._sock,name)(*args)
      File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py",
 line 174, in _dummy
        raise error(EBADF, 'Bad file descriptor')
    socket.error: [Errno 9] Bad file descriptor
    
    With this, the test failures in dispatch tests now are
    
    89% tests passed, 6 tests failed out of 57
    Total Test time (real) = 1747.39 sec
    The following tests FAILED:
          9 - unit_tests (SEGFAULT)
         23 - system_tests_policy (Timeout)
         28 - system_tests_sasl_plain (Failed)
         38 - system_tests_auth_service_plugin (Failed)
         39 - system_tests_authz_service_plugin (Failed)
         48 - system_tests_bad_configuration (Failed)
---
 tests/system_test.py | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/tests/system_test.py b/tests/system_test.py
index c02b2b1..39471eb 100755
--- a/tests/system_test.py
+++ b/tests/system_test.py
@@ -192,15 +192,21 @@ def wait_port(port, protocol_family='IPv4', 
**retry_kwargs):
         """Only retry on connection refused"""
         if not isinstance(e, socket.error) or not e.errno == 
errno.ECONNREFUSED:
             raise
-    s, host = get_local_host_socket(protocol_family)
+
+    def connect():
+        # macOS gives EINVAL for all connection attempts after a ECONNREFUSED
+        # man 3 connect: "If connect() fails, the state of the socket is 
unspecified. [...]"
+        s, host = get_local_host_socket(protocol_family)
+        try:
+            s.connect((host, port))
+        finally:
+            s.close()
+
     try:
-        retry_exception(lambda: s.connect((host, port)), exception_test=check,
-                        **retry_kwargs)
+        retry_exception(connect, exception_test=check, **retry_kwargs)
     except Exception as e:
         raise Exception("wait_port timeout on host %s port %s: %s"%(host, 
port, e))
 
-    finally: s.close()
-
 def wait_ports(ports, **retry_kwargs):
     """Wait up to timeout for all ports (on host) to be connectable.
     Takes same keyword arguments as retry to control the timeout"""


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to