pyca/pyopenssl

test_ssl:TestConnection.test_connect_ex succeeds unexpectedly on FreeBSD 13.1-RELEASE-p3

Opened this issue · 1 comments

pyopenssl/tests/test_ssl.py

Lines 2390 to 2407 in cac7478

@pytest.mark.skipif(
platform == "darwin",
reason="connect_ex sometimes causes a kernel panic on OS X 10.6.4",
)
def test_connect_ex(self):
"""
If there is a connection error, `Connection.connect_ex` returns the
errno instead of raising an exception.
"""
port = socket_any_family()
port.bind(("", 0))
port.listen(3)
clientSSL = Connection(Context(SSLv23_METHOD), socket(port.family))
clientSSL.setblocking(False)
result = clientSSL.connect_ex(port.getsockname())
expected = (EINPROGRESS, EWOULDBLOCK)
assert result in expected

This test fails fairly reliably on my physical host. If I space out the commands so the socket is fully setup, then call connect_ex, the test succeeded. Some additional synchronization is likely required to make the test pass/fail reliably.

Configuration

  • FreeBSD 13.1-RELEASE-p3
  • pytest 7.2.0
  • python 3.9.16
$ openssl version
OpenSSL 1.1.1o-freebsd  3 May 2022
$ pkg query %dn-%dv py39-openssl | sort -u
py39-cryptography-39.0.2
py39-setuptools-63.1.0
py39-six-1.16.0
python39-3.9.16

Example failure

self = <tests.test_ssl.TestConnection object at 0x804971610>

    @pytest.mark.skipif(
        platform == "darwin",
        reason="connect_ex sometimes causes a kernel panic on OS X 10.6.4",
    )
    def test_connect_ex(self):
        """
        If there is a connection error, `Connection.connect_ex` returns the
        errno instead of raising an exception.
        """
        port = socket_any_family()
        port.bind(("", 0))
        port.listen(3)
    
        clientSSL = Connection(Context(SSLv23_METHOD), socket(port.family))
        clientSSL.setblocking(False)
        result = clientSSL.connect_ex(port.getsockname())
        expected = (EINPROGRESS, EWOULDBLOCK)
>       assert result in expected
E       assert 0 in (36, 35)
mtelka commented

OpenIndiana (an illumos distro) is affected too.