Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failures with Fedora package #1637

Closed
opoplawski opened this issue Jun 6, 2020 · 6 comments
Closed

Test failures with Fedora package #1637

opoplawski opened this issue Jun 6, 2020 · 6 comments
Labels
Platform: POSIX PyVer: python3 Affects Python 3 Type: Question User support and/or waiting for responses

Comments

@opoplawski
Copy link

  • gevent version: 20.6.0
  • Python version: python3-3.9.0~b1-4.fc33
  • Operating System: Fedora Rawhide (F33) x86_64

Description:

I'm working on the Fedora python-gevent package. Fedora Rawhide recently updated to python 3.9. Since then we've seen some failures in gevent.

Updated the package to 20.6.0 but tests fail:

+ /usr/bin/python3 -m gevent.tests
WARNING: Testing monkey-patched stdlib has been disabled
Running tests in parallel with concurrency 4 (concurrency available: 3).
...
  ERROR: test_certificate (gevent.tests.test__server.TestSSLGetCertificate)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 47, in wrapper
      return method(self, *args, **kwargs)
    File "/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 34, in wrapper
      return method(self, *args, **kwargs)
    File "/usr/lib64/python3.9/site-packages/gevent/testing/testcase.py", line 182, in wrapper
      return method(self, *args, **kwargs)
    File "/usr/lib64/python3.9/site-packages/gevent/tests/test__server.py", line 472, in test_certificate
      from gevent import monkey, ssl
    File "/usr/lib64/python3.9/site-packages/gevent/ssl.py", line 32, in <module>
      from gevent import _ssl3 as _source # pragma: no cover
    File "/usr/lib64/python3.9/site-packages/gevent/_ssl3.py", line 171, in <module>
      class SSLSocket(socket):
    File "/usr/lib64/python3.9/site-packages/gevent/_ssl3.py", line 184, in SSLSocket
      family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None,
  NameError: name 'AF_INET' is not defined

This same error occurs many times.

@opoplawski
Copy link
Author

Sorry, the above failure was user error - I was running the tests against the 20.5.0 version.

However, I am still seeing the following test failures. Many are likely due to the lack of networking in the Fedora build environment, but some may not be. In any case, it would be very helpful to be able to disable network dependent tests if any.

+ /usr/bin/python3 -m gevent.tests
        GEVENTTEST_QUIET        =       True
GEVENTTEST_USE_RESOURCES        =       all
           PYTHONDEVMODE        =
      PYTHONFAULTHANDLER        =       true
            PYTHONMALLOC        =       default
              PYTHONPATH        =       /builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages
          PYTHONWARNINGS        =       default,default::DeprecationWarning,default::ResourceWarning,ignore:::site:,ignore:::pkgutil:,ignore:::importlib._bootstrap:,ignore:::importlib._bootstrap_external:,ignore:::pkg_resources._vendor.pyparsing:,ignore:::dns.namedict:,ignore:::dns.hash:,ignore:::dns.zone:                                     
sys.warnoptions:         ['default', 'default::DeprecationWarning', 'default::ResourceWarning', 'ignore:::site:', 'ignore:::pkgutil:', 'ignore:::importlib._bootstrap:', 'ignore:::importlib._bootstrap_external:', 'ignore:::pkg_resources._vendor.pyparsing:', 'ignore:::dns.namedict:', 'ignore:::dns.hash:', 'ignore:::dns.zone:']
WARNING: Testing monkey-patched stdlib has been disabled
Running tests in parallel with concurrency 4 (concurrency available: 3).
...
| /usr/bin/python3 -u -m unittest gevent.tests.test__pywsgi gevent.tests.test__refcount gevent.tests.test__socket gevent.tests.test__socket_ssl gevent.tests.test__socketpair gevent.tests.test__ssl
  ..............s........................s.........................................s....s....s..........s.....s.......s..............ss...s...Traceback (most recent call last):
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__socket.py", line 177, in _test_sendall
      getattr(client, client_method)(data)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/_ssl3.py", line 500, in send
      return self._sslobj.write(data)
  ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2446)
  .....F...F..
  ======================================================================
  FAIL: test_sendall_array (gevent.tests.test__ssl.TestSSL)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 47, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 34, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 47, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 34, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__socket.py", line 227, in test_sendall_array
      self._test_sendall(data)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__socket.py", line 215, in _test_sendall
      self.assertEqual(read_data, match_data)
  AssertionError: Lists differ: [b'0'[135073 chars], b' '] != [b'0'[135073 chars], b' 13290', b' 13291', b' 13292', b' 13293', [73760 chars]999']
  
  First differing element 13290:
  b' '
  b' 13290'
  
  Second list contains 6709 additional elements.
  First extra element 13291:
  b' 13291'
  
  Diff is 268898 characters long. Set self.maxDiff to None to see it.
  
  ======================================================================
  FAIL: test_sendall_str (gevent.tests.test__ssl.TestSSL)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 47, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 34, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 47, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 34, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__socket.py", line 218, in test_sendall_str
      self._test_sendall(self.long_data)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__socket.py", line 215, in _test_sendall
      self.assertEqual(read_data, match_data)
  AssertionError: Lists differ: [b'0'[135073 chars], b' '] != [b'0'[135073 chars], b' 13290', b' 13291', b' 13292', b' 13293', [73760 chars]999']
  
  First differing element 13290:
  b' '
  b' 13290'
  
  Second list contains 6709 additional elements.
  First extra element 13291:
  b' 13291'
  
  Diff is 268898 characters long. Set self.maxDiff to None to see it.
  
  ----------------------------------------------------------------------
  Ran 152 tests in 5.765s
  
  FAILED (failures=2, skipped=11)

! /usr/bin/python3 -u -m unittest gevent.tests.test__pywsgi gevent.tests.test__refcount gevent.tests.test__socket gevent.tests.test__socket_ssl gevent.tests.test__socketpair gevent.tests.test__ssl [code 1] [Ran 152 tests in 10.0s]
  ======================================================================
  FAIL: test_server_makefile1 (gevent.tests.test__makefile_ref.TestSSL)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 47, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 34, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/testcase.py", line 182, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__makefile_ref.py", line 358, in test_server_makefile1
      self.assert_open(client_socket, fileno)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__makefile_ref.py", line 101, in assert_open
      self.__assert_fd_open(fileno)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__makefile_ref.py", line 73, in __assert_fd_open
      raise AssertionError('%r is not open:\n%s' % (fileno, open_files['data']))
  AssertionError: 7 is not open:
  [pconn(fd=5, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=38639), raddr=(), status='LISTEN'), 'From psutil', psutil.Process(pid=2753, name='python3', started='12:26:29')]
  
  ======================================================================
  FAIL: test_server_makefile2 (gevent.tests.test__makefile_ref.TestSSL)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 47, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 34, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/testcase.py", line 182, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__makefile_ref.py", line 382, in test_server_makefile2
      self.assert_open(client_socket, fileno)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__makefile_ref.py", line 101, in assert_open
      self.__assert_fd_open(fileno)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__makefile_ref.py", line 73, in __assert_fd_open
      raise AssertionError('%r is not open:\n%s' % (fileno, open_files['data']))
  AssertionError: 7 is not open:
  [pconn(fd=5, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=35053), raddr=(), status='LISTEN'), 'From psutil', psutil.Process(pid=2753, name='python3', started='12:26:29')]
  
  ======================================================================
  FAIL: test_server_simple (gevent.tests.test__makefile_ref.TestSSL)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 47, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 34, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/testcase.py", line 182, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__makefile_ref.py", line 338, in test_server_simple
      self.assert_open(client_socket, fileno)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__makefile_ref.py", line 101, in assert_open
      self.__assert_fd_open(fileno)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__makefile_ref.py", line 73, in __assert_fd_open
      raise AssertionError('%r is not open:\n%s' % (fileno, open_files['data']))
  AssertionError: 7 is not open:
  [pconn(fd=5, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=45781), raddr=(), status='LISTEN'), 'From psutil', psutil.Process(pid=2753, name='python3', started='12:26:29')]
  
  ======================================================================
  FAIL: test_serverssl_makefile2 (gevent.tests.test__makefile_ref.TestSSL)
  ----------------------------------------------------------------------
  Traceback (most recent call last):
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 47, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/errorhandler.py", line 34, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/testing/testcase.py", line 182, in wrapper
      return method(self, *args, **kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__makefile_ref.py", line 446, in test_serverssl_makefile2
      self.assert_open(client_socket, fileno)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__makefile_ref.py", line 101, in assert_open
      self.__assert_fd_open(fileno)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__makefile_ref.py", line 73, in __assert_fd_open
      raise AssertionError('%r is not open:\n%s' % (fileno, open_files['data']))
  AssertionError: 7 is not open:
  [pconn(fd=5, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, laddr=addr(ip='127.0.0.1', port=34447), raddr=(), status='LISTEN'), 'From psutil', psutil.Process(pid=2753, name='python3', started='12:26:29')]
  
  ----------------------------------------------------------------------
  Ran 71 tests in 2.723s
  
  FAILED (failures=4, skipped=4)

! /usr/bin/python3 -u -m unittest gevent.tests.test__local gevent.tests.test__makefile_ref gevent.tests.test__monkey gevent.tests.test__monkey_queue gevent.tests.test__monkey_select gevent.tests.test__monkey_selectors [code 1] [Ran 71 tests in 3.3s]
| /usr/bin/python3 -u -mgevent.tests.test__getaddrinfo_import
  Traceback (most recent call last):
    File "/usr/lib64/python3.9/runpy.py", line 197, in _run_module_as_main
      return _run_code(code, main_globals, None,
    File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
      exec(code, run_globals)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/test__getaddrinfo_import.py", line 6, in <module>
      import getaddrinfo_module
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/tests/getaddrinfo_module.py", line 4, in <module>
      gevent_socket.getaddrinfo(u'gevent.org', None, socket.AF_INET)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/_socketcommon.py", line 230, in getaddrinfo
      addrlist = get_hub().resolver.getaddrinfo(host, port, family, type, proto, flags)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/resolver/thread.py", line 63, in getaddrinfo
      return self.pool.apply(_socket.getaddrinfo, args, kwargs)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/pool.py", line 161, in apply
      return self.spawn(func, *args, **kwds).get()
    File "src/gevent/event.py", line 305, in gevent._gevent_cevent.AsyncResult.get
      def get(self, block=True, timeout=None):
    File "src/gevent/event.py", line 335, in gevent._gevent_cevent.AsyncResult.get
      return self.get(block=False)
    File "src/gevent/event.py", line 323, in gevent._gevent_cevent.AsyncResult.get
      return self._raise_exception()
    File "src/gevent/event.py", line 303, in gevent._gevent_cevent.AsyncResult._raise_exception
      reraise(*self.exc_info)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/_compat.py", line 65, in reraise
      raise value.with_traceback(tb)
    File "/builddir/build/BUILDROOT/python-gevent-20.6.0-1.fc33.x86_64/usr/lib64/python3.9/site-packages/gevent/threadpool.py", line 142, in __run_task
      thread_result.set(func(*args, **kwargs))
  socket.gaierror: [Errno -2] Name or service not known

! /usr/bin/python3 -u -mgevent.tests.test__getaddrinfo_import [code 1] [took 0.2s]

@opoplawski opoplawski changed the title NameError: name 'AF_INET' is not defined with Python 3.9 Test failures with Fedora package Jun 6, 2020
@jamadden
Copy link
Member

jamadden commented Jun 7, 2020

it would be very helpful to be able to disable network dependent tests if any.

Tests using the external network can be disabled through the standard library's test resources. (That doesn't generally disable things using just localhost or unix sockets though. And since its applied by hand it might not always get everything, either.)

More tests can be altered to be more tolerant or disabled altogether if the testrunner is told it's running on a CI platform. The script that builds manylinux wheels does both these things.

export GEVENTTEST_USE_RESOURCES="-network"
export CI=1
export TRAVIS=true

I have observed the test_sendall_* tests to be a bit racy, for some reason that I haven't delved deeply into. Usually a second or isolated run lets them pass…

I don't know why test__makefile_ref:TestSSL tests failed to find open client socket descriptors, apparently only finding the server socket to be open. At that point, we have the client socket object and so we should have a file descriptor too...

@opoplawski
Copy link
Author

Many thanks for the pointers. Disabling the the network resource resolves this failure:

- /usr/bin/python3 -u -m unittest gevent.tests.test__os gevent.tests.test__pool gevent.tests.test__queue gevent.tests.test__real_greenlet gevent.tests.test__refcount_core gevent.tests.test__resolver_dnspython

Adding the CI/TRAVIS variables did not appear to have any discernible effect.
Running:

/usr/bin/python3 -m gevent.tests gevent.tests.test__ssl

by itself still results in test_sendall_{array,str} failures. Let me know if any other information would be helpful.

@jamadden
Copy link
Member

jamadden commented Jun 8, 2020

Running: /usr/bin/python3 -m gevent.tests gevent.tests.test__ssl by itself still results in test_sendall_{array,str} failures. Let me know if any other information would be helpful.

I'm unable to reproduce that on a couple different platforms locally, so this is debugging in the dark.

Adding the -v argument (python -m gevent.tests.test__ssl -v) will produce quite a bit more output showing the timing of things. The results of a failed run with that info might be useful.

It might also be useful to know what version of OpenSSL Python is using. I know that from 1.0 to 1.1 and TLS 1.3 certain things changed that had timing impacts that exposed ordering assumptions in test cases and which required changes. Locally it looks like I'm testing 1.1.1g (I'm not sure what we get on plain Travis Thanks to pyenv, on Travis it looks like 2.7 gets OpenSSL 1.0.1q and 3.x gets 1.1.0j; The macOS builds distribute their own libssl).

@jamadden jamadden added Platform: POSIX PyVer: python3 Affects Python 3 Type: Question User support and/or waiting for responses labels Jun 8, 2020
@jamadden
Copy link
Member

jamadden commented Jun 8, 2020

The kernel version would also be interesting (errors on Ubuntu Bionic are vaguely similar).

@jamadden
Copy link
Member

jamadden commented Jun 8, 2020

I found the Fedora rawhide docker images and with a bit of work was able to get an image running where I can trivially duplicate the problem.

If I run the test without gevent (no monkey-patching) I get a similar but more explicit error. The "server" fails to read all the bytes sent by the client (just as with gevent) but instead of silently truncating, the server raises a ConnectionResetError when the client executes client.close(). In the gevent case, the server silently truncates the data.

If I tweak the test to always client.shutdown(socket.SHUT_RDWR) (as it does on Python 2) both the gevent and stdlib versions of the test pass. Comments, however, indicate that calling shutdown() on Python 3 tended to produce errors of some sort (they're no more explicit than that).

Now I have more questions :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: POSIX PyVer: python3 Affects Python 3 Type: Question User support and/or waiting for responses
Projects
None yet
Development

No branches or pull requests

2 participants