From c7619ab713d9d802a4b4f07c1326d918cf8afbb03f6235494d724f13989aca6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Fri, 1 Feb 2019 10:35:41 +0000 Subject: [PATCH 1/3] - Make sure to skip tests that need network access OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-gevent?expand=0&rev=49 --- python-gevent.changes | 5 +++++ python-gevent.spec | 24 ++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/python-gevent.changes b/python-gevent.changes index 437c9de..979e4eb 100644 --- a/python-gevent.changes +++ b/python-gevent.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Feb 1 10:35:13 UTC 2019 - Tomáš Chvátal + +- Make sure to skip tests that need network access + ------------------------------------------------------------------- Thu Jan 31 09:42:44 UTC 2019 - Tomáš Chvátal diff --git a/python-gevent.spec b/python-gevent.spec index a211612..b6a243a 100644 --- a/python-gevent.spec +++ b/python-gevent.spec @@ -28,21 +28,32 @@ Source: https://files.pythonhosted.org/packages/source/g/gevent/gevent-% Source100: %{name}-rpmlintrc BuildRequires: %{python_module cffi} BuildRequires: %{python_module devel} +BuildRequires: %{python_module dnspython} BuildRequires: %{python_module greenlet >= 0.4.14} BuildRequires: %{python_module mock} BuildRequires: %{python_module objgraph} +BuildRequires: %{python_module requests} BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module zope.event} +BuildRequires: %{python_module zope.interface} +# /etc/protocols needed for tests BuildRequires: c-ares-devel BuildRequires: fdupes BuildRequires: libev-devel +BuildRequires: libuv-devel +BuildRequires: netcfg BuildRequires: python-rpm-macros BuildRequires: python3-testsuite Requires: python-cffi +Requires: python-dnspython Requires: python-greenlet +Requires: python-requests %if 0%{?suse_version} || 0%{?fedora_version} || 0%{?rhel} >= 8 Recommends: python-psutil +Recommends: python-zope.event %else Requires: python-psutil +Requires: python-zope.event %endif %python_subpackages @@ -88,9 +99,18 @@ export GEVENT_NO_CFFI_BUILD=1 %python_expand %fdupes %{buildroot}%{$python_sitearch} %check -# tests passed as 20 need network connection with no way to skip +# create ignore list of tests that reach out to the net +cat <<'EOF' >> network_tests.txt +test_urllib2net.py +test__server.py +test__server_pywsgi.py +test__socket_ssl.py +test___example_servers.py +test__socket_dns.py +test__getaddrinfo_import.py +EOF export GEVENT_RESOLVER=thread -%python_expand PYTHONPATH=%{buildroot}%{$python_sitearch} $python -m gevent.tests || : +%python_expand PYTHONPATH=%{buildroot}%{$python_sitearch} $python -m gevent.tests --ignore network_tests.txt %files %{python_files} %doc AUTHORS README.rst TODO CHANGES.rst CONTRIBUTING.rst From 8520fc1a815b2cbe891aa2fff065e3776a89258a54206e9d5b26c578246bb943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Fri, 1 Feb 2019 14:29:05 +0000 Subject: [PATCH 2/3] OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-gevent?expand=0&rev=50 --- python-gevent.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python-gevent.spec b/python-gevent.spec index b6a243a..14467c3 100644 --- a/python-gevent.spec +++ b/python-gevent.spec @@ -78,6 +78,7 @@ out the list of the open source projects based on gevent. Summary: Documentation for %{name} Group: Documentation/Other Provides: %{python_module gevent-doc = %{version}} +BuildArch: noarch %description -n python-gevent-doc Documentation and examples for %{name}. @@ -88,13 +89,11 @@ Documentation and examples for %{name}. %build export LIBEV_EMBED=0 export CARES_EMBED=0 -export GEVENT_NO_CFFI_BUILD=1 %python_build %install export LIBEV_EMBED=0 export CARES_EMBED=0 -export GEVENT_NO_CFFI_BUILD=1 %python_install %python_expand %fdupes %{buildroot}%{$python_sitearch} @@ -108,6 +107,7 @@ test__socket_ssl.py test___example_servers.py test__socket_dns.py test__getaddrinfo_import.py +test__examples.py EOF export GEVENT_RESOLVER=thread %python_expand PYTHONPATH=%{buildroot}%{$python_sitearch} $python -m gevent.tests --ignore network_tests.txt From 399e35b696eab90555cd0d7d3545fe9df27ec75ff739bc9b951f167a45d04975 Mon Sep 17 00:00:00 2001 From: Todd R Date: Tue, 5 Feb 2019 18:25:27 +0000 Subject: [PATCH 3/3] Accepting request 671192 from home:alarrosa:branches:devel:languages:python - Add patches to fix building the package: * remove-testCongestion.patch to remove a test that is failing due to a timeout * fix-tests.patch to fix some tests - ssl.OP_NO_COMPRESSION is set by default by ssl. - thread_ident can be represented as a negative hex number now, so replace the negative sign with the regex too, and not just the number. * use-libev-cffi.patch, libev-cext seems to be broken on i586, so use libev-cffi by default (also, the gevent documentation mentions that upstream will make libev-cffi the default soon). OBS-URL: https://build.opensuse.org/request/show/671192 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-gevent?expand=0&rev=52 --- fix-tests.patch | 41 +++++++++++++++++++ python-gevent.changes | 14 +++++++ python-gevent.spec | 14 +++++++ remove-testCongestion.patch | 82 +++++++++++++++++++++++++++++++++++++ use-libev-cffi.patch | 23 +++++++++++ 5 files changed, 174 insertions(+) create mode 100644 fix-tests.patch create mode 100644 remove-testCongestion.patch create mode 100644 use-libev-cffi.patch diff --git a/fix-tests.patch b/fix-tests.patch new file mode 100644 index 0000000..e57b2ac --- /dev/null +++ b/fix-tests.patch @@ -0,0 +1,41 @@ +From: Antonio Larrosa +Subject: Fix failing tests + +- ssl.OP_NO_COMPRESSION is set by default by ssl. +- thread_ident can be represented as a negative hex number now, + so replace the negative sign with the regex too, and not just the number. +Index: gevent-1.4.0/src/greentest/2.7/test_ssl.py +=================================================================== +--- gevent-1.4.0.orig/src/greentest/2.7/test_ssl.py ++++ gevent-1.4.0/src/greentest/2.7/test_ssl.py +@@ -742,14 +742,14 @@ class ContextTests(unittest.TestCase): + def test_options(self): + ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) + # OP_ALL | OP_NO_SSLv2 | OP_NO_SSLv3 is the default value +- self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3, ++ self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 | ssl.OP_NO_COMPRESSION, + ctx.options) + ctx.options |= ssl.OP_NO_TLSv1 +- self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 | ssl.OP_NO_TLSv1, ++ self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 | ssl.OP_NO_COMPRESSION | ssl.OP_NO_TLSv1, + ctx.options) + if can_clear_options(): + ctx.options = (ctx.options & ~ssl.OP_NO_SSLv2) | ssl.OP_NO_TLSv1 +- self.assertEqual(ssl.OP_ALL | ssl.OP_NO_TLSv1 | ssl.OP_NO_SSLv3, ++ self.assertEqual(ssl.OP_ALL | ssl.OP_NO_TLSv1 | ssl.OP_NO_SSLv3 | ssl.OP_NO_COMPRESSION, + ctx.options) + ctx.options = 0 + self.assertEqual(0, ctx.options) +Index: gevent-1.4.0/src/gevent/tests/test__util.py +=================================================================== +--- gevent-1.4.0.orig/src/gevent/tests/test__util.py ++++ gevent-1.4.0/src/gevent/tests/test__util.py +@@ -134,7 +134,7 @@ class TestTree(greentest.TestCase): + + def _normalize_tree_format(self, value): + import re +- hexobj = re.compile('0x[0123456789abcdef]+L?', re.I) ++ hexobj = re.compile('-?0x[0123456789abcdef]+L?', re.I) + value = hexobj.sub('X', value) + value = value.replace('epoll', 'select') + value = value.replace('select', 'default') diff --git a/python-gevent.changes b/python-gevent.changes index 979e4eb..d8dab67 100644 --- a/python-gevent.changes +++ b/python-gevent.changes @@ -1,3 +1,17 @@ +------------------------------------------------------------------- +Mon Feb 4 11:37:48 UTC 2019 - Antonio Larrosa + +- Add patches to fix building the package: + * remove-testCongestion.patch to remove a test that is failing + due to a timeout + * fix-tests.patch to fix some tests + - ssl.OP_NO_COMPRESSION is set by default by ssl. + - thread_ident can be represented as a negative hex number now, + so replace the negative sign with the regex too, and not just the number. + * use-libev-cffi.patch, libev-cext seems to be broken on i586, so + use libev-cffi by default (also, the gevent documentation mentions + that upstream will make libev-cffi the default soon). + ------------------------------------------------------------------- Fri Feb 1 10:35:13 UTC 2019 - Tomáš Chvátal diff --git a/python-gevent.spec b/python-gevent.spec index 14467c3..fc8096e 100644 --- a/python-gevent.spec +++ b/python-gevent.spec @@ -26,12 +26,16 @@ Group: Development/Languages/Python URL: http://www.gevent.org/ Source: https://files.pythonhosted.org/packages/source/g/gevent/gevent-%{version}.tar.gz Source100: %{name}-rpmlintrc +Patch0: remove-testCongestion.patch +Patch1: fix-tests.patch +Patch2: use-libev-cffi.patch BuildRequires: %{python_module cffi} BuildRequires: %{python_module devel} BuildRequires: %{python_module dnspython} BuildRequires: %{python_module greenlet >= 0.4.14} BuildRequires: %{python_module mock} BuildRequires: %{python_module objgraph} +BuildRequires: %{python_module psutil} BuildRequires: %{python_module requests} BuildRequires: %{python_module setuptools} BuildRequires: %{python_module zope.event} @@ -85,6 +89,9 @@ Documentation and examples for %{name}. %prep %setup -q -n gevent-%{version} +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 %build export LIBEV_EMBED=0 @@ -110,6 +117,13 @@ test__getaddrinfo_import.py test__examples.py EOF export GEVENT_RESOLVER=thread +# Setting the TRAVIS environment variable makes some different configuration +# for tests that use the network so they don't fail on travis (or obs) +export TRAVIS=1 +# Setting the APPVEYOR environment variable makes the tests use a workaround +# for Appveyor that we also need in obs for "wait_threads() failed to cleanup 1 threads" +export APPVEYOR=1 +export LANG=en_US.UTF-8 %python_expand PYTHONPATH=%{buildroot}%{$python_sitearch} $python -m gevent.tests --ignore network_tests.txt %files %{python_files} diff --git a/remove-testCongestion.patch b/remove-testCongestion.patch new file mode 100644 index 0000000..dbbda53 --- /dev/null +++ b/remove-testCongestion.patch @@ -0,0 +1,82 @@ +From: Antonio Larrosa +Subject: Remove testCongestion from test_socket.py + +Remove testCongestion from test_socket.py which is failing with a timeout. + +Index: gevent-1.4.0/src/greentest/3.7/test_socket.py +=================================================================== +--- gevent-1.4.0.orig/src/greentest/3.7/test_socket.py ++++ gevent-1.4.0/src/greentest/3.7/test_socket.py +@@ -2054,34 +2054,6 @@ class RDSTest(ThreadedRDSSocketTest): + self.data = b'select' + self.cli.sendto(self.data, 0, (HOST, self.port)) + +- def testCongestion(self): +- # wait until the sender is done +- self.evt.wait() +- +- def _testCongestion(self): +- # test the behavior in case of congestion +- self.data = b'fill' +- self.cli.setblocking(False) +- try: +- # try to lower the receiver's socket buffer size +- self.cli.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 16384) +- except OSError: +- pass +- with self.assertRaises(OSError) as cm: +- try: +- # fill the receiver's socket buffer +- while True: +- self.cli.sendto(self.data, 0, (HOST, self.port)) +- finally: +- # signal the receiver we're done +- self.evt.set() +- # sendto() should have failed with ENOBUFS +- self.assertEqual(cm.exception.errno, errno.ENOBUFS) +- # and we should have received a congestion notification through poll +- r, w, x = select.select([self.serv], [], [], 3.0) +- self.assertIn(self.serv, r) +- +- + @unittest.skipIf(fcntl is None, "need fcntl") + @unittest.skipUnless(HAVE_SOCKET_VSOCK, + 'VSOCK sockets required for this test.') +Index: gevent-1.4.0/src/greentest/3.6/test_socket.py +=================================================================== +--- gevent-1.4.0.orig/src/greentest/3.6/test_socket.py ++++ gevent-1.4.0/src/greentest/3.6/test_socket.py +@@ -1769,33 +1769,6 @@ class RDSTest(ThreadedRDSSocketTest): + self.data = b'select' + self.cli.sendto(self.data, 0, (HOST, self.port)) + +- def testCongestion(self): +- # wait until the sender is done +- self.evt.wait() +- +- def _testCongestion(self): +- # test the behavior in case of congestion +- self.data = b'fill' +- self.cli.setblocking(False) +- try: +- # try to lower the receiver's socket buffer size +- self.cli.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 16384) +- except OSError: +- pass +- with self.assertRaises(OSError) as cm: +- try: +- # fill the receiver's socket buffer +- while True: +- self.cli.sendto(self.data, 0, (HOST, self.port)) +- finally: +- # signal the receiver we're done +- self.evt.set() +- # sendto() should have failed with ENOBUFS +- self.assertEqual(cm.exception.errno, errno.ENOBUFS) +- # and we should have received a congestion notification through poll +- r, w, x = select.select([self.serv], [], [], 3.0) +- self.assertIn(self.serv, r) +- + + @unittest.skipUnless(thread, 'Threading required for this test.') + class BasicTCPTest(SocketConnectedTest): diff --git a/use-libev-cffi.patch b/use-libev-cffi.patch new file mode 100644 index 0000000..1ef9a16 --- /dev/null +++ b/use-libev-cffi.patch @@ -0,0 +1,23 @@ +From: Antonio Larrosa +Subject: Fix failing tests + +libev-cext seems to be broken on i586, so use libev-cffi by default +(also, the gevent documentation mentions that upstream will make +libev-cffi the default soon [1]). + +[1] http://www.gevent.org/loop_impls.html#libev + +Index: gevent-1.4.0/src/gevent/_config.py +=================================================================== +--- gevent-1.4.0.orig/src/gevent/_config.py ++++ gevent-1.4.0/src/gevent/_config.py +@@ -352,8 +352,8 @@ class Loop(ImportableSetting, Setting): + """ + + default = [ +- 'libev-cext', + 'libev-cffi', ++ 'libev-cext', + 'libuv-cffi', + ] if not WIN else [ + 'libuv-cffi',