From b3cede24420ccd6605609c9e4ce0c0fd8b1ac8ae Mon Sep 17 00:00:00 2001 From: Michael Banck Date: Sun, 13 Feb 2022 22:42:40 +0100 Subject: [PATCH] * debian/patches/regression_tests_psutil_compat.patch: New patch, add compatibility for newer psutil in the regression tests (Closes: #1003562). --- debian/changelog | 2 + .../regression_tests_psutil_compat.patch | 96 +++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 99 insertions(+) create mode 100644 debian/patches/regression_tests_psutil_compat.patch diff --git a/debian/changelog b/debian/changelog index 679a495..b19e5c0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,8 @@ patroni (2.1.2-3) UNRELEASED; urgency=medium * debian/tests/test: No longer remove raft tests, no longer needed. * debian/patches/regression_tests_disable_raft_tests.py: Removed, no longer needed. + * debian/patches/regression_tests_psutil_compat.patch: New patch, add + compatibility for newer psutil in the regression tests (Closes: #1003562). -- Debian PostgreSQL Maintainers Sun, 13 Feb 2022 15:54:41 +0100 diff --git a/debian/patches/regression_tests_psutil_compat.patch b/debian/patches/regression_tests_psutil_compat.patch new file mode 100644 index 0000000..a73691c --- /dev/null +++ b/debian/patches/regression_tests_psutil_compat.patch @@ -0,0 +1,96 @@ +From 01d40a4a1384156928131aea6f93f5e2cddc90b7 Mon Sep 17 00:00:00 2001 +From: Alexander Kukushkin +Date: Wed, 5 Jan 2022 09:53:33 +0100 +Subject: [PATCH] Compatibility with latest psutil and setuptools (#2155) + +Issues don't affect Patroni code, only unit-tests +--- + setup.py | 9 ++++----- + tests/test_cancellable.py | 4 ++-- + tests/test_postmaster.py | 8 ++++---- + 3 files changed, 10 insertions(+), 11 deletions(-) + +Index: patroni/setup.py +=================================================================== +--- patroni.orig/setup.py ++++ patroni/setup.py +@@ -5,6 +5,7 @@ + """ + + import inspect ++import logging + import os + import sys + +@@ -132,12 +133,8 @@ class PyTest(Command): + except Exception: + raise RuntimeError('py.test is not installed, run: pip install pytest') + +- import logging +- silence = logging.WARNING +- logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=os.getenv('LOGLEVEL', silence)) +- + args = ['--verbose', 'tests', '--doctest-modules', MAIN_PACKAGE] +\ +- ['-s' if logging.getLogger().getEffectiveLevel() < silence else '--capture=fd'] ++ ['-s' if logging.getLogger().getEffectiveLevel() < logging.WARNING else '--capture=fd'] + if self.cov: + args += self.cov + +@@ -161,6 +158,8 @@ def read(fname): + + + def setup_package(version): ++ logging.basicConfig(format='%(message)s', level=os.getenv('LOGLEVEL', logging.WARNING)) ++ + # Assemble additional setup commands + cmdclass = {'test': PyTest, 'flake8': Flake8} + +Index: patroni/tests/test_cancellable.py +=================================================================== +--- patroni.orig/tests/test_cancellable.py ++++ patroni/tests/test_cancellable.py +@@ -27,8 +27,8 @@ class TestCancellableSubprocess(unittest + def test_cancel(self): + self.c._process = Mock() + self.c._process.is_running.return_value = True +- self.c._process.children.side_effect = psutil.Error() +- self.c._process.suspend.side_effect = psutil.Error() ++ self.c._process.children.side_effect = psutil.NoSuchProcess(123) ++ self.c._process.suspend.side_effect = psutil.AccessDenied() + self.c.cancel() + self.c._process.is_running.side_effect = [True, False] + self.c.cancel() +Index: patroni/tests/test_postmaster.py +=================================================================== +--- patroni.orig/tests/test_postmaster.py ++++ patroni/tests/test_postmaster.py +@@ -73,7 +73,7 @@ class TestPostmasterProcess(unittest.Tes + + # all processes successfully stopped + mock_children.return_value = [Mock()] +- mock_children.return_value[0].kill.side_effect = psutil.Error ++ mock_children.return_value[0].kill.side_effect = psutil.NoSuchProcess(123) + self.assertTrue(proc.signal_kill()) + + # postmaster has gone before suspend +@@ -81,17 +81,17 @@ class TestPostmasterProcess(unittest.Tes + self.assertTrue(proc.signal_kill()) + + # postmaster has gone before we got a list of children +- mock_suspend.side_effect = psutil.Error() ++ mock_suspend.side_effect = psutil.AccessDenied() + mock_children.side_effect = psutil.NoSuchProcess(123) + self.assertTrue(proc.signal_kill()) + + # postmaster has gone after we got a list of children +- mock_children.side_effect = psutil.Error() ++ mock_children.side_effect = psutil.AccessDenied() + mock_kill.side_effect = psutil.NoSuchProcess(123) + self.assertTrue(proc.signal_kill()) + + # failed to kill postmaster +- mock_kill.side_effect = psutil.AccessDenied(123) ++ mock_kill.side_effect = psutil.AccessDenied() + self.assertFalse(proc.signal_kill()) + + @patch('psutil.Process.__init__', Mock()) diff --git a/debian/patches/series b/debian/patches/series index ba10579..ae79d15 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -4,3 +4,4 @@ requirements_setuptools.patch offline_intersphinx.patch regression_tests_disable_requirement_download.patch requirements_cdiff.patch +regression_tests_psutil_compat.patch