From d7b2a61aa5f2c7780c9beeb4cd3e77b60ba1c0f8 Mon Sep 17 00:00:00 2001 From: Alfred Wingate Date: Mon, 24 Feb 2025 21:28:20 +0200 Subject: [PATCH] dev-python/sshtunnel: re-enable tests The patch removing server support lead to bug 683774, so to fix the tests you just require that flag. Still include a patch that fixed the deadlock as its still a real bug that it gets stuck in that while loop. Bug: https://bugs.gentoo.org/666619 Bug: https://bugs.gentoo.org/683774 Signed-off-by: Alfred Wingate Signed-off-by: Sam James --- .../sshtunnel-0.4.0-dont-deadlock-tests.patch | 38 +++++++++++++++++++ dev-python/sshtunnel/sshtunnel-0.4.0.ebuild | 20 +++++++++- profiles/base/package.use.mask | 1 + 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 dev-python/sshtunnel/files/sshtunnel-0.4.0-dont-deadlock-tests.patch diff --git a/dev-python/sshtunnel/files/sshtunnel-0.4.0-dont-deadlock-tests.patch b/dev-python/sshtunnel/files/sshtunnel-0.4.0-dont-deadlock-tests.patch new file mode 100644 index 0000000000000..1e5b06ac49b68 --- /dev/null +++ b/dev-python/sshtunnel/files/sshtunnel-0.4.0-dont-deadlock-tests.patch @@ -0,0 +1,38 @@ +From 96a056fb37684496c0495a831f8fd11b48ef01a9 Mon Sep 17 00:00:00 2001 +From: Alfred Wingate +Date: Sat, 22 Feb 2025 12:40:58 +0200 +Subject: [PATCH] Try to remove defunct threads from running_threads just in + case + +On Gentoo it was decided to remove server functionality from +paramiko leading to the ssh-server to be dead before it could be +properly removed from running_threads. This would lead to a hang where +memory footprint of the process would grow with repeated "thread +ssh-server now stopped" messages inevitably leading to an OOM condition. + +So try to remove defunct threads from running_threads after the fact to +stop this problem from coming back and let it fail normally. + +Bug: https://github.com/pahaz/sshtunnel/issues/153 +Bug: https://bugs.gentoo.org/666619 +Bug: https://bugs.gentoo.org/683774 +Signed-off-by: Alfred Wingate +--- a/tests/test_forwarder.py ++++ b/tests/test_forwarder.py +@@ -251,6 +251,13 @@ class SSHClientTest(unittest.TestCase): + who='tearDown') + if not x.is_alive(): + self.log.info('thread {0} now stopped'.format(thread)) ++ # Try to remove thread running_threads just in case ++ # the thread is dead but hasn't been properly removed. ++ # https://github.com/pahaz/sshtunnel/issues/153 ++ try: ++ self.running_threads.remove(thread) ++ except ValueError: ++ pass + + for attr in ['server', 'tc', 'ts', 'socks', 'ssockl', 'esockl']: + if hasattr(self, attr): +-- +2.49.0 + diff --git a/dev-python/sshtunnel/sshtunnel-0.4.0.ebuild b/dev-python/sshtunnel/sshtunnel-0.4.0.ebuild index 906dd10656c64..5e90a68bc39b7 100644 --- a/dev-python/sshtunnel/sshtunnel-0.4.0.ebuild +++ b/dev-python/sshtunnel/sshtunnel-0.4.0.ebuild @@ -4,6 +4,7 @@ EAPI=8 DISTUTILS_USE_PEP517=setuptools +EPYTEST_XDIST=1 PYTHON_COMPAT=( python3_{10..12} ) inherit distutils-r1 pypi @@ -14,6 +15,21 @@ LICENSE="MIT" SLOT="0" KEYWORDS="amd64 ~arm ~arm64 x86" -RESTRICT="test" - RDEPEND="dev-python/paramiko[${PYTHON_USEDEP}]" +BDEPEND=" + test? ( + dev-python/paramiko[server(+),${PYTHON_USEDEP}] + dev-python/mock[${PYTHON_USEDEP}] + ) +" + +PATCHES=( + "${FILESDIR}"/sshtunnel-0.4.0-dont-deadlock-tests.patch +) + +distutils_enable_tests pytest + +EPYTEST_DESELECT=( + # network-sandbox + tests/test_forwarder.py::SSHClientTest::test_gateway_ip_unresolvable_raises_exception +) diff --git a/profiles/base/package.use.mask b/profiles/base/package.use.mask index 72ecedb607041..f5b3a528feb06 100644 --- a/profiles/base/package.use.mask +++ b/profiles/base/package.use.mask @@ -833,6 +833,7 @@ dev-lang/gnat-gpl jit # be re-enabled with the 'server' USE flag, but this flag is hard # masked. bug #666619 dev-python/paramiko server +dev-python/sshtunnel test # Michał Górny (2018-06-13) # Requires app-arch/snappy[static-libs] that is no longer available.