Synss / python-mbedtls

Cryptographic library with an mbed TLS back end
MIT License
79 stars 28 forks source link

Tests failing on openSUSE Tumbleweed Python 2.7 #24

Closed jayvdb closed 4 years ago

jayvdb commented 4 years ago

Project at https://build.opensuse.org/package/show/home:jayvdb:strictyaml/python-python-mbedtls

It builds both python 2 & then 3.

Python 3 passes the tests, but there are a lot of failures for Python 2. The logs are there. Let me know if you want me to copy them over.

Synss commented 4 years ago

Hi John and thank you for your interest in packaging my library.

I am not too familiar with the UI at build.opensuse.org and could not find the logs. Could you please copy them here?

In principle, it should work since both circle ci and travis build and test for 2.7 but... theory and reality :-)

jayvdb commented 4 years ago

Most of them are in the form

[  410s] 
[  410s] ==================================== ERRORS ====================================
[  410s] _________ ERROR at setup of TestARIA.test_encrypt_decrypt[Mode.ECB-16] _________
[  410s] 
[  410s] self = <test_cipher.TestARIA instance at 0x7fe0252749e0>
[  410s] module = <module 'mbedtls.cipher.ARIA' from '/home/abuild/rpmbuild/BUILDROOT/python-pyt...-0.18.0-16.1.x86_64/usr/lib64/python2.7/site-packages/mbedtls/cipher/ARIA.pyc'>
[  410s] key = '\xb91^g)\x83\x03\xabs\x121\xfc\x1a\xad\xecu', mode = <Mode.ECB: 1>
[  410s] iv = ']]_\x96\x1f\xf0\x8c0\xad\x9a\xea\xe9~\xb6\t`'
[  410s] 
[  410s]     @pytest.fixture
[  410s]     def cipher(self, module, key, mode, iv):
[  410s] >       return module.new(key, mode, iv)
[  410s] 
[  410s] tests/test_cipher.py:94: 
[  410s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  410s] ../../BUILDROOT/python-python-mbedtls-0.18.0-16.1.x86_64/usr/lib64/python2.7/site-packages/mbedtls/cipher/ARIA.py:41: in new
[  410s]     return _cipher.Cipher(name, key, mode, iv)
[  410s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  410s] 
[  410s] >   raise TLSError(msg="unsupported cipher: %r" % cipher_name)
[  410s] E   TLSError: TLSError(unsupported cipher: 'ARIA-128-ECB')
[  410s] 
[  410s] src/mbedtls/cipher/_cipher.pyx:192: TLSError

Other unsupported ciphers:

Then the final set are

[  411s] _ ERROR at teardown of TestTLSCommunication.test_client_server[TLSVersion.MAXIMUM_SUPPORTED-False-16383] _
[  411s] 
[  411s] self = <test_tls.TestTLSCommunication instance at 0x7fe02497a2d8>
[  411s] server = <mbedtls.tls.TLSWrappedSocket object at 0x7fe02488b7d0>
[  411s] cli_conf = TLSConfiguration(validate_certificates=True, certificate_chain=((), None), cip...e=TrustStore([<mbedtls.x509.CRT object at 0x559960e39440>]), sni_callback=None)
[  411s] address = ('127.0.0.1', 60151)
[  411s] 
[  411s]     @pytest.fixture
[  411s]     def client(self, server, cli_conf, address):
[  411s]         ctx = ClientContext(cli_conf)
[  411s]         sock = ctx.wrap_socket(
[  411s]             socket.socket(socket.AF_INET, self.proto),
[  411s]             server_hostname="End Entity",
[  411s]         )
[  411s]         sock.connect(address)
[  411s]         block(sock.do_handshake)
[  411s]         yield sock
[  411s]         with suppress(OSError):
[  411s] >           block(sock.send, self.CLOSE_MESSAGE)
[  411s] 
[  411s] tests/test_tls.py:368: 
[  411s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  411s] tests/test_tls.py:38: in block
[  411s]     return callback(*args, **kwargs)
[  411s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  411s] 
[  411s] >   self._socket.send(encrypted, flags)
[  411s] E   error: [Errno 9] Bad file descriptor
[  411s] 
[  411s] src/mbedtls/tls.pyx:1278: error
[  411s] ----------------------------- Captured stderr call -----------------------------
[  411s] Process Process-21:
[  411s] Traceback (most recent call last):
[  411s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 267, in _bootstrap
[  411s]     self.run()
[  411s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
[  411s]     self._target(*self._args, **self._kwargs)
[  411s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.0/tests/test_tls.py", line 421, in echo
[  411s]     data = block(conn.recv, 20 * 1024)
[  411s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.0/tests/test_tls.py", line 38, in block
[  411s]     return callback(*args, **kwargs)
[  411s]   File "src/mbedtls/tls.pyx", line 1249, in mbedtls.tls.TLSWrappedSocket.recv
[  411s]     return self._buffer.read(bufsize)
[  411s]   File "src/mbedtls/tls.pyx", line 1080, in mbedtls.tls.TLSWrappedBuffer.read
[  411s]     nread += self.readinto(c_buffer[nread:], amt - nread)
[  411s]   File "src/mbedtls/tls.pyx", line 1085, in mbedtls.tls.TLSWrappedBuffer.readinto
[  411s]     return self.context._readinto(buffer, amt)
[  411s]   File "src/mbedtls/tls.pyx", line 857, in mbedtls.tls._BaseContext._readinto
[  411s]     check_error(read)
[  411s]   File "src/mbedtls/exceptions.pyx", line 55, in mbedtls.exceptions.check_error
[  411s]     cpdef check_error(const int err):
[  411s]   File "src/mbedtls/exceptions.pyx", line 58, in mbedtls.exceptions.check_error
[  411s]     raise TLSError(-err)
[  411s] TLSError: TLSError([0x7200] u'SSL - An invalid SSL record was received')
[  411s] =================================== FAILURES ===================================
[  411s] ____ TestTLSCommunication.test_client_server[TLSVersion.TLSv1-False-16383] _____
[  411s] 
[  411s] self = <test_tls.TestTLSCommunication instance at 0x7fe0249bee18>
[  411s] client = <mbedtls.tls.TLSWrappedSocket object at 0x7fe024a7e320>
[  411s] buffer = '\x91\xcf\xb1\x02\x8f<T\xd7\xde\x11\xe7\xbc\xba/;\xa2\xa1G7\x1cr2\x11\x1e^\x1c-\x96\'\x88\\U\x19\x12\x80\xfdZ\xa3\xe25...xa3G\xcdHS=\xc09\x88\xb0WI\xa4\x96\xb8\xc6T\xb7\x11m\xd7\xcaR}\xc6\xd5\xa7m\xb7\xc6(a\\\x08@"\xe7\x19#\x8b\x03\xff\x97'
[  411s] step = 16383
[  411s] 
[  411s]     def test_client_server(self, client, buffer, step):
[  411s]         received = bytearray()
[  411s]         for idx in range(0, len(buffer), step):
[  411s]             view = memoryview(buffer[idx : idx + step])
[  411s]             amt = block(client.send, view)
[  411s]             assert amt == len(view)
[  411s] >           assert block(client.recv, 20 * 1024) == view
[  411s] E           AssertionError: assert '' == <memory at 0x7fe027db48a0>
[  411s] E             -''
[  411s] E             +<memory at 0x7fe027db48a0>
[  411s] 
[  411s] tests/test_tls.py:446: AssertionError
[  411s] ----------------------------- Captured stderr call -----------------------------
[  411s] Process Process-7:
[  411s] Traceback (most recent call last):
[  411s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 267, in _bootstrap
[  411s]     self.run()
[  411s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
[  411s]     self._target(*self._args, **self._kwargs)
[  411s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.0/tests/test_tls.py", line 421, in echo
[  411s]     data = block(conn.recv, 20 * 1024)
[  411s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.0/tests/test_tls.py", line 38, in block
[  411s]     return callback(*args, **kwargs)
[  411s]   File "src/mbedtls/tls.pyx", line 1249, in mbedtls.tls.TLSWrappedSocket.recv
[  411s]     return self._buffer.read(bufsize)
[  411s]   File "src/mbedtls/tls.pyx", line 1080, in mbedtls.tls.TLSWrappedBuffer.read
[  411s]     nread += self.readinto(c_buffer[nread:], amt - nread)
[  411s]   File "src/mbedtls/tls.pyx", line 1085, in mbedtls.tls.TLSWrappedBuffer.readinto
[  411s]     return self.context._readinto(buffer, amt)
[  411s]   File "src/mbedtls/tls.pyx", line 857, in mbedtls.tls._BaseContext._readinto
[  411s]     check_error(read)
[  411s]   File "src/mbedtls/exceptions.pyx", line 55, in mbedtls.exceptions.check_error
[  411s]     cpdef check_error(const int err):
[  411s]   File "src/mbedtls/exceptions.pyx", line 58, in mbedtls.exceptions.check_error
[  411s]     raise TLSError(-err)
[  411s] TLSError: TLSError([0x7200] u'SSL - An invalid SSL record was received')
[  411s] ___ TestTLSCommunication.test_client_server[TLSVersion.TLSv1_1-False-16383] ____
[  411s] 
[  411s] self = <test_tls.TestTLSCommunication instance at 0x7fe0249d0368>
[  411s] client = <mbedtls.tls.TLSWrappedSocket object at 0x7fe0248d7e60>
[  411s] buffer = '\xec\xfa\x17R\x12\x0c\x0f\xcd\xfeii\x82\xef\xf5\xe4\xd0\x13\xd1\xf7\x93\x90v\xb5\n\x06\xe4+\xf3\x0f\xf2\xd9Q\xb1\xa6\...\x04\xc0\xc5X\xb8\xb4g]\xce\x89A\xa5\xb8\xff[\x19\xfb:4\x97\x98\xfc\x8e\xb8\x08\xef\x96\xad\xab@N&F\xcdll\xca8\xff\xba'
[  411s] step = 16383
[  411s] 
[  411s]     def test_client_server(self, client, buffer, step):
[  411s]         received = bytearray()
[  411s]         for idx in range(0, len(buffer), step):
[  411s]             view = memoryview(buffer[idx : idx + step])
[  411s]             amt = block(client.send, view)
[  411s]             assert amt == len(view)
[  411s] >           assert block(client.recv, 20 * 1024) == view
[  411s] E           AssertionError: assert '' == <memory at 0x7fe027db49d0>
[  411s] E             -''
[  411s] E             +<memory at 0x7fe027db49d0>
[  411s] 
[  411s] tests/test_tls.py:446: AssertionError
[  411s] ----------------------------- Captured stderr call -----------------------------
[  411s] Process Process-14:
[  411s] Traceback (most recent call last):
[  411s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 267, in _bootstrap
[  411s]     self.run()
[  411s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
[  411s]     self._target(*self._args, **self._kwargs)
[  411s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.0/tests/test_tls.py", line 421, in echo
[  411s]     data = block(conn.recv, 20 * 1024)
[  411s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.0/tests/test_tls.py", line 38, in block
[  411s]     return callback(*args, **kwargs)
[  411s]   File "src/mbedtls/tls.pyx", line 1249, in mbedtls.tls.TLSWrappedSocket.recv
[  411s]     return self._buffer.read(bufsize)
[  411s]   File "src/mbedtls/tls.pyx", line 1080, in mbedtls.tls.TLSWrappedBuffer.read
[  411s]     nread += self.readinto(c_buffer[nread:], amt - nread)
[  411s]   File "src/mbedtls/tls.pyx", line 1085, in mbedtls.tls.TLSWrappedBuffer.readinto
[  411s]     return self.context._readinto(buffer, amt)
[  411s]   File "src/mbedtls/tls.pyx", line 857, in mbedtls.tls._BaseContext._readinto
[  411s]     check_error(read)
[  411s]   File "src/mbedtls/exceptions.pyx", line 55, in mbedtls.exceptions.check_error
[  411s]     cpdef check_error(const int err):
[  411s]   File "src/mbedtls/exceptions.pyx", line 58, in mbedtls.exceptions.check_error
[  411s]     raise TLSError(-err)
[  411s] TLSError: TLSError([0x7200] u'SSL - An invalid SSL record was received')
[  411s] _ TestTLSCommunication.test_client_server[TLSVersion.MAXIMUM_SUPPORTED-False-16383] _
[  411s] 
[  411s] self = <test_tls.TestTLSCommunication instance at 0x7fe02497a2d8>
[  411s] client = <mbedtls.tls.TLSWrappedSocket object at 0x7fe02488ba00>
[  411s] buffer = '\x16\xbb8(\x9bt\x03`\xb3w\xa21\x0b\nj\x12X\x87\x945\x89\x04Ty~\x89({\x95J\x08>\x9d\x89>\x8c\xd0\x14\xea\xff\xb4w\x07\...f\xd9\x85\x85\xc3\x17@Y\x84\x12\x0c\x89\x18A!\x7fV\xf8\xb5\xbd@/@\xa4\xd8k\xb3\x99\xcd\xee\tB[\x8di\xb6\r\xd2\x15$@v?h'
[  411s] step = 16383
[  411s] 
[  411s]     def test_client_server(self, client, buffer, step):
[  411s]         received = bytearray()
[  411s]         for idx in range(0, len(buffer), step):
[  411s]             view = memoryview(buffer[idx : idx + step])
[  411s]             amt = block(client.send, view)
[  411s]             assert amt == len(view)
[  411s] >           assert block(client.recv, 20 * 1024) == view
[  411s] E           AssertionError: assert '' == <memory at 0x7fe027db4b00>
[  411s] E             -''
[  411s] E             +<memory at 0x7fe027db4b00>
[  411s] 
[  411s] tests/test_tls.py:446: AssertionError
[  411s] ----------------------------- Captured stderr call -----------------------------
[  411s] Process Process-21:
[  411s] Traceback (most recent call last):
[  411s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 267, in _bootstrap
[  411s]     self.run()
[  411s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
[  411s]     self._target(*self._args, **self._kwargs)
[  411s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.0/tests/test_tls.py", line 421, in echo
[  411s]     data = block(conn.recv, 20 * 1024)
[  411s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.0/tests/test_tls.py", line 38, in block
[  411s]     return callback(*args, **kwargs)
[  411s]   File "src/mbedtls/tls.pyx", line 1249, in mbedtls.tls.TLSWrappedSocket.recv
[  411s]     return self._buffer.read(bufsize)
[  411s]   File "src/mbedtls/tls.pyx", line 1080, in mbedtls.tls.TLSWrappedBuffer.read
[  411s]     nread += self.readinto(c_buffer[nread:], amt - nread)
[  411s]   File "src/mbedtls/tls.pyx", line 1085, in mbedtls.tls.TLSWrappedBuffer.readinto
[  411s]     return self.context._readinto(buffer, amt)
[  411s]   File "src/mbedtls/tls.pyx", line 857, in mbedtls.tls._BaseContext._readinto
[  411s]     check_error(read)
[  411s]   File "src/mbedtls/exceptions.pyx", line 55, in mbedtls.exceptions.check_error
[  411s]     cpdef check_error(const int err):
[  411s]   File "src/mbedtls/exceptions.pyx", line 58, in mbedtls.exceptions.check_error
[  411s]     raise TLSError(-err)
[  411s] TLSError: TLSError([0x7200] u'SSL - An invalid SSL record was received')
[  411s] =============================== warnings summary ===============================
[  411s] /usr/lib/python2.7/site-packages/_pytest/mark/structures.py:334
[  411s]   /usr/lib/python2.7/site-packages/_pytest/mark/structures.py:334: PytestUnknownMarkWarning: Unknown pytest.mark.repeat - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html
[  411s]     PytestUnknownMarkWarning,
[  411s] 
[  411s] tests/test_x509.py::TestCRTWikipediaBase::test_eq_pem
[  411s]   /home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.0/tests/test_x509.py:92: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
[  411s]     assert x509 == pem
[  411s] 
[  411s] tests/test_x509.py::TestCRTWikipediaBase::test_eq_pem
[  411s]   /home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.0/tests/test_x509.py:93: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
[  411s]     assert pem == x509
[  411s] 
[  411s] -- Docs: https://docs.pytest.org/en/latest/warnings.html
[  411s] == 3 failed, 3016 passed, 37 skipped, 3 warnings, 37 error in 137.46 seconds ===

They occur around the middle of https://build.opensuse.org/build/home:jayvdb:strictyaml/openSUSE_Tumbleweed/x86_64/python-python-mbedtls/_log

Synss commented 4 years ago

Regarding Aria: It is not present in libmbedtls by default. I compile libmbedtls with

CFLAGS="-DMBEDTLS_ARIA_C=ON" \
SHARED="ON" \
make -C .. -j lib

I realise that I should not assume that much and skip the tests to features that are not in, especially when they are not present by default. I will fix the tests.

Regarding: TLS, I have not idea... I have to look into it.

Synss commented 4 years ago

The tests should now pass when Aria is not in libmbedtls and I have merged your PR. I was not able to reproduce the problem with TLS so far.

Cheers

Synss commented 4 years ago

Regarding the failing TLS communication tests, the first error is error: [Errno 9] Bad file descriptor. Could it be that openSUSE testing environment does not allow the creation of sockets? The tests use regular AF_INET sockets bound to the local host on ports in the range [60 000-65 000].

Synss commented 4 years ago

@jayvdb : About the beginning, the log start with a qemu invocation:

[ 5s] /usr/bin/qemu-kvm -nodefaults -no-reboot -nographic -vga none -cpu host -object rng-random,filename=/dev/hwrng,id=rng0 -device virtio-rng-pci,rng=rng0 -runas qemu -net none -kernel /var/cache/obs/worker/root_8/.mount/boot/kernel -initrd /var/cache/obs/worker/root_8/.mount/boot/initrd -append root=/dev/disk/by-id/virtio-0 rootfstype=ext4 rootflags=noatime ext4.allow_unsupported=1 kpti=off pti=off spectre_v2=off panic=1 quiet no-kvmclock elevator=noop nmi_watchdog=0 rw rd.driver.pre=binfmt_misc console=ttyS0 init=/.build/build -m 8192 -drive file=/var/cache/obs/worker/root_8/root,format=raw,if=none,id=disk,cache=unsafe -device virtio-blk-pci,drive=disk,serial=0 -drive file=/var/cache/obs/worker/root_8/swap,format=raw,if=none,id=swap,cache=unsafe -device virtio-blk-pci,drive=swap,serial=1 -serial stdio -chardev socket,id=monitor,server,nowait,path=/var/cache/obs/worker/root_8/root.qemu/monitor -mon chardev=monitor,mode=readline -smp 8

where -net none could very well be the reason for the EBADF socket, couldn't it?

Synss commented 4 years ago

I have release 0.18.1 that should solve the failing Aria tests.

Regarding the TLS tests, I believe that it comes from you configuration. There could be a way to skip these tests for your config but I need some more information.

What I can say is that the TLS tests pass on a clean system and for all Python versions from the manylinux1 image I am using.

In any case, thank you for reporting!

jayvdb commented 4 years ago

I've updated the build project, and now the Python 2 errors are

[  326s] ==================================== ERRORS ====================================
[  326s] _ ERROR at teardown of TestTLSCommunication.test_client_server[TLSVersion.MAXIMUM_SUPPORTED-False-16383] _
[  326s] 
[  326s] self = <test_tls.TestTLSCommunication instance at 0x7f3636992cf8>
[  326s] server = <mbedtls.tls.TLSWrappedSocket object at 0x7f3636964e60>
[  326s] cli_conf = TLSConfiguration(validate_certificates=True, certificate_chain=((), None), cip...e=TrustStore([<mbedtls.x509.CRT object at 0x55eb39724e50>]), sni_callback=None)
[  326s] address = ('127.0.0.1', 64015)
[  326s] 
[  326s]     @pytest.fixture
[  326s]     def client(self, server, cli_conf, address):
[  326s]         ctx = ClientContext(cli_conf)
[  326s]         sock = ctx.wrap_socket(
[  326s]             socket.socket(socket.AF_INET, self.proto),
[  326s]             server_hostname="End Entity",
[  326s]         )
[  326s]         sock.connect(address)
[  326s]         block(sock.do_handshake)
[  326s]         yield sock
[  326s]         with suppress(OSError):
[  326s] >           block(sock.send, self.CLOSE_MESSAGE)
[  326s] 
[  326s] tests/test_tls.py:368: 
[  326s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  326s] tests/test_tls.py:38: in block
[  326s]     return callback(*args, **kwargs)
[  326s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  326s] 
[  326s] >   self._socket.send(encrypted, flags)
[  326s] E   error: [Errno 9] Bad file descriptor
[  326s] 
[  326s] src/mbedtls/tls.pyx:1278: error
[  326s] ----------------------------- Captured stderr call -----------------------------
[  326s] Process Process-21:
[  326s] Traceback (most recent call last):
[  326s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 267, in _bootstrap
[  326s]     self.run()
[  326s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
[  326s]     self._target(*self._args, **self._kwargs)
[  326s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.1/tests/test_tls.py", line 421, in echo
[  326s]     data = block(conn.recv, 20 * 1024)
[  326s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.1/tests/test_tls.py", line 38, in block
[  326s]     return callback(*args, **kwargs)
[  326s]   File "src/mbedtls/tls.pyx", line 1249, in mbedtls.tls.TLSWrappedSocket.recv
[  326s]     return self._buffer.read(bufsize)
[  326s]   File "src/mbedtls/tls.pyx", line 1080, in mbedtls.tls.TLSWrappedBuffer.read
[  326s]     nread += self.readinto(c_buffer[nread:], amt - nread)
[  326s]   File "src/mbedtls/tls.pyx", line 1085, in mbedtls.tls.TLSWrappedBuffer.readinto
[  326s]     return self.context._readinto(buffer, amt)
[  326s]   File "src/mbedtls/tls.pyx", line 857, in mbedtls.tls._BaseContext._readinto
[  326s]     check_error(read)
[  326s]   File "src/mbedtls/exceptions.pyx", line 55, in mbedtls.exceptions.check_error
[  326s]     cpdef check_error(const int err):
[  326s]   File "src/mbedtls/exceptions.pyx", line 58, in mbedtls.exceptions.check_error
[  326s]     raise TLSError(-err)
[  326s] TLSError: TLSError([0x7200] u'SSL - An invalid SSL record was received')
[  326s] =================================== FAILURES ===================================
[  326s] ____ TestTLSCommunication.test_client_server[TLSVersion.TLSv1-False-16383] _____
[  326s] 
[  326s] self = <test_tls.TestTLSCommunication instance at 0x7f36369f0368>
[  326s] client = <mbedtls.tls.TLSWrappedSocket object at 0x7f363754cb90>
[  326s] buffer = 'j,\x04\x1f:u\xd2\x87\xa7<\x8d\xd2\xc8\xf1@\xa5[\x02r\x9dv\xf5\xdf\xa7\xa8d\xd2\xb6\xeb\x12<j^\x8b8\x1ec\r\xa6T*\xd5V\...5\xfe\xd8\x7f\xba\xc4\t8\xcdc\xdd~N,\tKW\x8d\xd5\xb9\x90\xb8\x12/\xd1e\x01\x10\xbc\xd8X\xb9<\xddy\xed\xe5\xcc/\x9dk,3q'
[  326s] step = 16383
[  326s] 
[  326s]     def test_client_server(self, client, buffer, step):
[  326s]         received = bytearray()
[  326s]         for idx in range(0, len(buffer), step):
[  326s]             view = memoryview(buffer[idx : idx + step])
[  326s]             amt = block(client.send, view)
[  326s]             assert amt == len(view)
[  326s] >           assert block(client.recv, 20 * 1024) == view
[  326s] E           assert '' != memoryview('j,\x04\x1f:u\xd2\x87\xa7<\x8d\xd2\xc8\xf1@\xa5[\x02r\x9dv\xf5\xdf\xa7\xa8d\xd2\xb6\xeb\x12<j^\x8b8\x1ec\r\xa6T*\xd5V\xa0!\x8b3\xc1\x13\xb2\xbd"\x1e,\x92\xb1\x88\x1f\xc3\x8e\x15\x1b\xbd\xc5LWz)\xd7\xd97\xd8\xb6q\x96cGu\xf6\x11\x94j\xe1\xcaX\x85\x9e\xf0\tx\xafwj\x12\xcd\'\x01\x1b!\xca\x9d8L\xc3Z\xda\xb4\xc1!\xcd~\rw\x96\x98\t\xc1\xae\xd1\xca\x14\x85\x8e\xbf\x05\xa6\xd1Eg\xcb\rY\xa3\xea\'\x99}\x8f\xa3fl \xab\x16\xac\xe0\x83?\xb5\xa5{^\xeb\x1e\x94OF\xa8/\x1d~\x95\xb8\xfd\xb3\x97Y\xee\xcc\xd1\x16Jl\x8d\x97a\x0b\x85\xf1\x8f\xb0s\\Z\x08\r6j\xce\xb8\xc6@}$\xf7\xc9U\xa4l\xf7d+\xdfD\x9c`\xb2`\xbfL\x15\xf0%~$\x8c\xbe\x8a\xf3\...
[  326s] E             
[  326s] E             ...Full output truncated (2 lines hidden), use '-vv' to show
[  326s] 
[  326s] tests/test_tls.py:446: AssertionError
[  326s] ----------------------------- Captured stderr call -----------------------------
[  326s] Process Process-7:
[  326s] Traceback (most recent call last):
[  326s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 267, in _bootstrap
[  326s]     self.run()
[  326s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
[  326s]     self._target(*self._args, **self._kwargs)
[  326s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.1/tests/test_tls.py", line 421, in echo
[  326s]     data = block(conn.recv, 20 * 1024)
[  326s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.1/tests/test_tls.py", line 38, in block
[  326s]     return callback(*args, **kwargs)
[  326s]   File "src/mbedtls/tls.pyx", line 1249, in mbedtls.tls.TLSWrappedSocket.recv
[  326s]     return self._buffer.read(bufsize)
[  326s]   File "src/mbedtls/tls.pyx", line 1080, in mbedtls.tls.TLSWrappedBuffer.read
[  326s]     nread += self.readinto(c_buffer[nread:], amt - nread)
[  326s]   File "src/mbedtls/tls.pyx", line 1085, in mbedtls.tls.TLSWrappedBuffer.readinto
[  326s]     return self.context._readinto(buffer, amt)
[  326s]   File "src/mbedtls/tls.pyx", line 857, in mbedtls.tls._BaseContext._readinto
[  326s]     check_error(read)
[  326s]   File "src/mbedtls/exceptions.pyx", line 55, in mbedtls.exceptions.check_error
[  326s]     cpdef check_error(const int err):
[  326s]   File "src/mbedtls/exceptions.pyx", line 58, in mbedtls.exceptions.check_error
[  326s]     raise TLSError(-err)
[  326s] TLSError: TLSError([0x7200] u'SSL - An invalid SSL record was received')
[  326s] ___ TestTLSCommunication.test_client_server[TLSVersion.TLSv1_1-False-16383] ____
[  326s] 
[  326s] self = <test_tls.TestTLSCommunication instance at 0x7f363696b200>
[  326s] client = <mbedtls.tls.TLSWrappedSocket object at 0x7f36369b3550>
[  326s] buffer = '\xc8\x87\xc1*m\xd8s\x89\x81F\xe7\x9e\xee\x0b\xae\x0c\xe6;y\x04\x1do\x07\xb7M\xd5\xd8l9\xf4\x01\x15\x14\x90\x11\x02\xe...=\xeb\xb3`\xd9\x06\xdb\x91\xfd\x11\x13*\x14\x80\xbf~A\xc2\x04\xe4\xe3\x83\x05g\x96\xca\x84k\x1e\xa4\x02\xbd\x1cUT\xe4]'
[  326s] step = 16383
[  326s] 
[  326s]     def test_client_server(self, client, buffer, step):
[  326s]         received = bytearray()
[  326s]         for idx in range(0, len(buffer), step):
[  326s]             view = memoryview(buffer[idx : idx + step])
[  326s]             amt = block(client.send, view)
[  326s]             assert amt == len(view)
[  326s] >           assert block(client.recv, 20 * 1024) == view
[  326s] E           AssertionError: assert '' != memoryview('\xc8\x87\xc1*m\xd8s\x89\x81F\xe7\x9e\xee\x0b\xae\x0c\xe6;y\x04\x1do\x07\xb7M\xd5\xd8l9\xf4\x01\x15\x14\x90\x11\x02\xe7M]\xcf6O\x1a\xd2\x9c:\xc3\x8b\x9c*h\xce\x14\xf3\x8f\xa8<\x93\x1e\xf8\x15 \x84\xe4\x8bN\xf8\x93\xe5%\xcc\x05\xb7t\xceY\xc1A\x9b\n\xc9\xcf\xc1-,\x1a\x850\xe2\xadZ6\xbb\x99$\x8d<\x0c\x95\x0ci\xc0_B\xe7i\x88<\xf6\xc5\xb1F\x96\x97sJN,\x82{p\xf9\xb5\r\xe0\xd3\xb6T\xff\xf5\x1c\xe7r\x0b\xd4\xd0\x8dEx\xfa%\xf1\xb6\x90\xd1\x0b\xeeJ\xdd\xf3\xc4\xa6\x97\xf1\xf1\xd5\n\xd9\xa4\xfbh,\xc3\x95r\xa1\xaet\xc4\x9b\xbbc\xe6\n9B\x9d!\xbd\x9a\x02\x8f\xae\xfdd\xda\x0bnQA\x0b\x08\xc2\xf2Pp\xe3\xab[\xa3F\xb4#K\xe9R\xc2\xb5\x...
[  326s] E             
[  326s] E             ...Full output truncated (2 lines hidden), use '-vv' to show
[  326s] 
[  326s] tests/test_tls.py:446: AssertionError
[  326s] ----------------------------- Captured stderr call -----------------------------
[  326s] Process Process-14:
[  326s] Traceback (most recent call last):
[  326s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 267, in _bootstrap
[  326s]     self.run()
[  326s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
[  326s]     self._target(*self._args, **self._kwargs)
[  326s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.1/tests/test_tls.py", line 421, in echo
[  326s]     data = block(conn.recv, 20 * 1024)
[  326s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.1/tests/test_tls.py", line 38, in block
[  326s]     return callback(*args, **kwargs)
[  326s]   File "src/mbedtls/tls.pyx", line 1249, in mbedtls.tls.TLSWrappedSocket.recv
[  326s]     return self._buffer.read(bufsize)
[  326s]   File "src/mbedtls/tls.pyx", line 1080, in mbedtls.tls.TLSWrappedBuffer.read
[  326s]     nread += self.readinto(c_buffer[nread:], amt - nread)
[  326s]   File "src/mbedtls/tls.pyx", line 1085, in mbedtls.tls.TLSWrappedBuffer.readinto
[  326s]     return self.context._readinto(buffer, amt)
[  326s]   File "src/mbedtls/tls.pyx", line 857, in mbedtls.tls._BaseContext._readinto
[  326s]     check_error(read)
[  326s]   File "src/mbedtls/exceptions.pyx", line 55, in mbedtls.exceptions.check_error
[  326s]     cpdef check_error(const int err):
[  326s]   File "src/mbedtls/exceptions.pyx", line 58, in mbedtls.exceptions.check_error
[  326s]     raise TLSError(-err)
[  326s] TLSError: TLSError([0x7200] u'SSL - An invalid SSL record was received')
[  326s] _ TestTLSCommunication.test_client_server[TLSVersion.MAXIMUM_SUPPORTED-False-16383] _
[  326s] 
[  326s] self = <test_tls.TestTLSCommunication instance at 0x7f3636992cf8>
[  326s] client = <mbedtls.tls.TLSWrappedSocket object at 0x7f363695f0f0>
[  326s] buffer = '1eQ,/\xba5\xa9\xb7\xca\xe3\x16\xe2]7\xca\xfb\x08\x81\xe96o\xd6B{\x08\x12r\x9a\x0c\x0e ^\xb3\x91\xa1-$r\xd8\xcb_\x15\x...5\xcf\xab{K3\x86\xfe2\xc3\xfa\xb7O\x8d\xfeR\x0f\x9dP/\xf7GU\xbe\x95\x85\xce\xf2\xcd`\x9b]\xc4,\xd35\x05N(c\x8d\x84\xeb'
[  326s] step = 16383
[  326s] 
[  326s]     def test_client_server(self, client, buffer, step):
[  326s]         received = bytearray()
[  326s]         for idx in range(0, len(buffer), step):
[  326s]             view = memoryview(buffer[idx : idx + step])
[  326s]             amt = block(client.send, view)
[  326s]             assert amt == len(view)
[  326s] >           assert block(client.recv, 20 * 1024) == view
[  326s] E           assert '' != memoryview('1eQ,/\xba5\xa9\xb7\xca\xe3\x16\xe2]7\xca\xfb\x08\x81\xe96o\xd6B{\x08\x12r\x9a\x0c\x0e ^\xb3\x91\xa1-$r\xd8\xcb_\x15\xf5\xfe\xabA{\xcb\x9cO\xc5\xb1\x9a\r\xda\x94{\xc6\xf6ZqGsV-G\x00\x15\xa6\xe0\xba\xc9d\x0f\xc9\xc1\xf5\x8b~\x8b~\xe6\x0e\xd7\x05B\x9ag\xf0m\xd4\xd1\xdf$\xd6\xcc\xb5B\x9df\x15\xac6a\xee\xd5w\x19\xd2\xe4\x10L\xf7c\x1b\x13\xaa2Y\xc0\xc1\xf4\x9f\xf8"\x05\xd7PY\xd2\x0fi\xb7\x82\xca\xd7\x8b\xbb\xe1\xcb\xec\xfa\xe9\x16\x16\xa8\xeb*\xea\xb3 WQ\x8e\x96\xff\xb0\x0b\x97Yc\'\x04pD\x1dsOa,\x94\x9c\xfd\xf4Y!\xd1\xd5\t\x93\x9ci\x1f\xdfb\x91\xe3\xf6\x13\xf8\x03o\x94\xee\x95J\xc9(h\x8a:\x91\xda<\xa149\x04Z\xc9^\x1a\x8f...
[  326s] E             
[  326s] E             ...Full output truncated (2 lines hidden), use '-vv' to show
[  326s] 
[  326s] tests/test_tls.py:446: AssertionError
[  326s] ----------------------------- Captured stderr call -----------------------------
[  326s] Process Process-21:
[  326s] Traceback (most recent call last):
[  326s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 267, in _bootstrap
[  326s]     self.run()
[  326s]   File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
[  326s]     self._target(*self._args, **self._kwargs)
[  326s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.1/tests/test_tls.py", line 421, in echo
[  326s]     data = block(conn.recv, 20 * 1024)
[  326s]   File "/home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.1/tests/test_tls.py", line 38, in block
[  326s]     return callback(*args, **kwargs)
[  326s]   File "src/mbedtls/tls.pyx", line 1249, in mbedtls.tls.TLSWrappedSocket.recv
[  326s]     return self._buffer.read(bufsize)
[  326s]   File "src/mbedtls/tls.pyx", line 1080, in mbedtls.tls.TLSWrappedBuffer.read
[  326s]     nread += self.readinto(c_buffer[nread:], amt - nread)
[  326s]   File "src/mbedtls/tls.pyx", line 1085, in mbedtls.tls.TLSWrappedBuffer.readinto
[  326s]     return self.context._readinto(buffer, amt)
[  326s]   File "src/mbedtls/tls.pyx", line 857, in mbedtls.tls._BaseContext._readinto
[  326s]     check_error(read)
[  326s]   File "src/mbedtls/exceptions.pyx", line 55, in mbedtls.exceptions.check_error
[  326s]     cpdef check_error(const int err):
[  326s]   File "src/mbedtls/exceptions.pyx", line 58, in mbedtls.exceptions.check_error
[  326s]     raise TLSError(-err)
[  326s] TLSError: TLSError([0x7200] u'SSL - An invalid SSL record was received')
[  326s] __________________________ test_feature[havege-False] __________________________
[  326s] 
[  326s] feature = 'havege', present = False
[  326s] 
[  326s]     @pytest.mark.parametrize(
[  326s]         "feature, present",
[  326s]         (
[  326s]             ("havege", False),
[  326s]             ("MBEDTLS_SSL_RENEGOTIATION", True),
[  326s]             ("ssl_renegotiation", True),
[  326s]             ("md5", True),
[  326s]             ("MD5_C", True),
[  326s]         ),
[  326s]     )
[  326s]     def test_feature(feature, present):
[  326s] >       assert version.has_feature(feature) is present
[  326s] E       AssertionError: assert True is False
[  326s] E        +  where True = <built-in function has_feature>('havege')
[  326s] E        +    where <built-in function has_feature> = version.has_feature
[  326s] 
[  326s] tests/test_version.py:26: AssertionError
[  326s] =============================== warnings summary ===============================
[  326s] /usr/lib/python2.7/site-packages/_pytest/mark/structures.py:334
[  326s]   /usr/lib/python2.7/site-packages/_pytest/mark/structures.py:334: PytestUnknownMarkWarning: Unknown pytest.mark.repeat - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html
[  326s]     PytestUnknownMarkWarning,
[  326s] 
[  326s] tests/test_x509.py::TestCRTWikipediaBase::test_eq_pem
[  326s]   /home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.1/tests/test_x509.py:92: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
[  326s]     assert x509 == pem
[  326s] 
[  326s] tests/test_x509.py::TestCRTWikipediaBase::test_eq_pem
[  326s]   /home/abuild/rpmbuild/BUILD/python-mbedtls-0.18.1/tests/test_x509.py:93: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
[  326s]     assert pem == x509
[  326s] 
[  326s] -- Docs: https://docs.pytest.org/en/latest/warnings.html
[  326s] = 4 failed, 3017 passed, 169 skipped, 7 xfailed, 3 warnings, 1 error in 91.33 seconds =
jayvdb commented 4 years ago

On Python 3 there are four failures. The backtraces are large, so I'll just dump the case names.

[  396s] tests/test_tls.py::TestTLSCommunication::test_client_server[TLSVersion.TLSv1-False-16383] FAILED [ 97%]
[  414s] tests/test_tls.py::TestTLSCommunication::test_client_server[TLSVersion.TLSv1_1-False-16383] FAILED [ 97%]
[  432s] tests/test_tls.py::TestTLSCommunication::test_client_server[TLSVersion.TLSv1_2-False-16383] FAILED [ 97%]
[  433s] tests/test_version.py::test_feature[havege-False] FAILED                 [ 97%]
Synss commented 4 years ago

[ 433s] tests/test_version.py::test_feature[havege-False] FAILED [ 97%]

Interesting. I will fix that.

error: [Errno 9] Bad file descriptor

I will try to detect that and skip the tests if the creation of a socket fails.

Synss commented 4 years ago

I was wrong, some tests using sockets pass on your system. So network does work. I will investigate further.

jayvdb commented 4 years ago

I can easily add pytest skips on my side using pytest -k 'not (foo or bar)', especially for things which are likely due to the VM, or add extra packages and test environment initialisation. The testing VM do allow sockets. They are pretty close to real machines. A good reference point is https://build.opensuse.org/package/show/devel:languages:python/python-pyOpenSSL , which only include a single patch to exclude one test method. I've branched it to https://build.opensuse.org/package/show/home:jayvdb:branches:devel:languages:python/python-pyOpenSSL and added -vv so you can see which tests are being skipped.

If there are still a few unknown problems with python-mbedtls on the build workers, but the common usage cases work, I am happy to try submitting the package to the openSUSE Python collection managers. I would then add sample packages that use python-mbedtls, and ensure their test cases mostly work.

Synss commented 4 years ago

Thank you! I will make another point release with a few more bug fixes on top.

Regarding HAVEGE, the tests assumed that it is not compiled in libmbedtls. That is not correct and the assumption is gone. I actually had plans to include support for it anyway. I now believe that the only assumption left about libmbedtls is MD5.

For the TLS tests with a very large payload, I have increased the size of the internal buffer and also reduced the size of the payload in the tests. 16 KB was working on my system but probably not very realistic anyway.

I am now waiting for my CI to complete. Let us see what happens on openSUSE thereafter!

jayvdb commented 4 years ago

I have done a build of master , and all tests pass on py2 & 3 for at least Tumbleweed. I've removed the '||true', so now any failures in any of the jobs will be red at https://build.opensuse.org/package/show/home:jayvdb:strictyaml/python-python-mbedtls

jayvdb commented 4 years ago

All green except a set of failures on ARM aarch64. I'm going to re-start the jobs, and remove the pin on libmbedtls version, which should re-introduce errors on Leap 15.1 builds because iirc it had a missing header file

aarch64:

[  901s] ==================================== ERRORS ====================================
[  901s] _ ERROR at setup of TestTLSCommunication.test_client_server[TLSVersion.TLSv1-False-1] _
[  901s] 
[  901s] self = <test_tls.TestTLSCommunication instance at 0xffffb6257ab8>
[  901s] srv_conf = TLSConfiguration(validate_certificates=False, certificate_chain=((<mbedtls.x50...e=TrustStore([<mbedtls.x509.CRT object at 0xaaaae6ea1e80>]), sni_callback=None)
[  901s] address = ('127.0.0.1', 22716), version = <TLSVersion.TLSv1: 1>
[  901s] 
[  901s]     @pytest.fixture
[  901s]     def server(self, srv_conf, address, version):
[  901s]         ctx = ServerContext(srv_conf)
[  901s]         sock = ctx.wrap_socket(socket.socket(socket.AF_INET, self.proto))
[  901s]         sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
[  901s] >       sock.bind(address)
[  901s] 
[  901s] tests/test_tls.py:340: 
[  901s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  901s] src/mbedtls/tls.pyx:1211: in mbedtls.tls.TLSWrappedSocket.bind
[  901s]     self._socket.bind(address)
[  901s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  901s] 
[  901s] name = 'bind', self = <socket._socketobject object at 0xffffb63426e0>
[  901s] args = (('127.0.0.1', 22716),)
[  901s] 
[  901s]     def meth(name,self,*args):
[  901s] >       return getattr(self._sock,name)(*args)
[  901s] E       error: [Errno 98] Address already in use
[  901s] 
[  901s] /usr/lib64/python2.7/socket.py:228: error
[  901s] _ ERROR at setup of TestTLSCommunication.test_client_server[TLSVersion.TLSv1_1-False-1] _
[  901s] 
[  901s] self = <test_tls.TestTLSCommunication instance at 0xffffb639f7e8>
[  901s] srv_conf = TLSConfiguration(validate_certificates=False, certificate_chain=((<mbedtls.x50...e=TrustStore([<mbedtls.x509.CRT object at 0xaaaae6ec6920>]), sni_callback=None)
[  901s] address = ('127.0.0.1', 22716), version = <TLSVersion.TLSv1_1: 2>
[  901s] 
[  901s]     @pytest.fixture
[  901s]     def server(self, srv_conf, address, version):
[  901s]         ctx = ServerContext(srv_conf)
[  901s]         sock = ctx.wrap_socket(socket.socket(socket.AF_INET, self.proto))
[  901s]         sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
[  901s] >       sock.bind(address)
[  901s] 
[  901s] tests/test_tls.py:340: 
[  901s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  901s] src/mbedtls/tls.pyx:1211: in mbedtls.tls.TLSWrappedSocket.bind
[  901s]     self._socket.bind(address)
[  901s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  901s] 
[  901s] name = 'bind', self = <socket._socketobject object at 0xffffb622f520>
[  901s] args = (('127.0.0.1', 22716),)
[  901s] 
[  901s]     def meth(name,self,*args):
[  901s] >       return getattr(self._sock,name)(*args)
[  901s] E       error: [Errno 98] Address already in use
[  901s] 
[  901s] /usr/lib64/python2.7/socket.py:228: error
[  901s] _ ERROR at setup of TestTLSCommunication.test_client_server[TLSVersion.MAXIMUM_SUPPORTED-False-1] _
[  901s] 
[  901s] self = <test_tls.TestTLSCommunication instance at 0xffffb63c2908>
[  901s] srv_conf = TLSConfiguration(validate_certificates=False, certificate_chain=((<mbedtls.x50...e=TrustStore([<mbedtls.x509.CRT object at 0xaaaae70aa2b0>]), sni_callback=None)
[  901s] address = ('127.0.0.1', 22716), version = <TLSVersion.MAXIMUM_SUPPORTED: 3>
[  901s] 
[  901s]     @pytest.fixture
[  901s]     def server(self, srv_conf, address, version):
[  901s]         ctx = ServerContext(srv_conf)
[  901s]         sock = ctx.wrap_socket(socket.socket(socket.AF_INET, self.proto))
[  901s]         sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
[  901s] >       sock.bind(address)
[  901s] 
[  901s] tests/test_tls.py:340: 
[  901s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  901s] src/mbedtls/tls.pyx:1211: in mbedtls.tls.TLSWrappedSocket.bind
[  901s]     self._socket.bind(address)
[  901s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  901s] 
[  901s] name = 'bind', self = <socket._socketobject object at 0xffffb622f670>
[  901s] args = (('127.0.0.1', 22716),)
[  901s] 
[  901s]     def meth(name,self,*args):
[  901s] >       return getattr(self._sock,name)(*args)
[  901s] E       error: [Errno 98] Address already in use
[  901s] 
[  901s] /usr/lib64/python2.7/socket.py:228: error
jayvdb commented 4 years ago

Three builds of ARM aarch64 without error, but then a very similar error on arch armv7l

[  944s] ==================================== ERRORS ====================================
[  944s] _ ERROR at setup of TestTLSCommunication.test_client_server[TLSVersion.MAXIMUM_SUPPORTED-False-1] _
[  944s] 
[  944s] self = <test_tls.TestTLSCommunication instance at 0xb3774288>
[  944s] srv_conf = TLSConfiguration(validate_certificates=False, certificate_chain=((<mbedtls.x50...store=TrustStore([<mbedtls.x509.CRT object at 0xb38082e0>]), sni_callback=None)
[  944s] address = ('127.0.0.1', 22716), version = <TLSVersion.MAXIMUM_SUPPORTED: 3>
[  944s] 
[  944s]     @pytest.fixture
[  944s]     def server(self, srv_conf, address, version):
[  944s]         ctx = ServerContext(srv_conf)
[  944s]         sock = ctx.wrap_socket(socket.socket(socket.AF_INET, self.proto))
[  944s]         sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
[  944s] >       sock.bind(address)
[  944s] 
[  944s] tests/test_tls.py:340: 
[  944s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  944s] src/mbedtls/tls.pyx:1211: in mbedtls.tls.TLSWrappedSocket.bind
[  944s]     self._socket.bind(address)
[  944s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  944s] 
[  944s] name = 'bind', self = <socket._socketobject object at 0xb37ecf80>
[  944s] args = (('127.0.0.1', 22716),)
[  944s] 
[  944s]     def meth(name,self,*args):
[  944s] >       return getattr(self._sock,name)(*args)
[  944s] E       error: [Errno 98] Address already in use
[  944s] 
[  944s] /usr/lib/python2.7/socket.py:228: error

So this remaining problem is a bit temperamental.

Synss commented 4 years ago

Master is released as 0.18.2.

[Errno 98] Address already in use

may happen when you build in parallel for the same version of Python on one machine (say 32- and 64-bits at the same time). I could not find a non-racing way to select a free port so now, the port number is a function of the Python version.

An alternative would be to let the OS find a free port with sock.bind(("", 0)) but that could lead to race conditions as well or randomise the order in which the tests run.

In other words, restarting the failed builds is safe. Even if it is not optimal.

Synss commented 4 years ago

sock.bind(("", 0)) has been working so far. So I will close this issue now. There should be a 0.18.3 release in the next few days with approx the current master. Thank you for your feedback, it's really appreciated. Do not hesitate to reopen or create another issue if you find anything else!

jayvdb commented 4 years ago

No worries. Please do drop a note here when it is released so I can package it up and submit for inclusion into openSUSE.

Synss commented 4 years ago

@jayvdb : 0.18.3 is in the cheese shop