From 06c4313ec0ed043970a60cbbc463f3dcad71f6f4 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Fri, 9 Dec 2016 14:11:33 +0100 Subject: [PATCH] Adjust test suite for new psutil versions psutil 2.x and above has a lot of API changes as described in: https://github.com/giampaolo/psutil/blob/master/HISTORY.rst So we should work correctly with both old and new psutil versions by using a version check and use the correct method/attributes. This allows to eventually unlift the version cap that starts to hurt. Related-Bug: 1645918 Change-Id: I6be775e83876271012f6b7a777ea2b5cc3a008f6 --- glance/tests/functional/test_reload.py | 7 ++++++- glance/tests/functional/v1/test_multiprocessing.py | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/glance/tests/functional/test_reload.py b/glance/tests/functional/test_reload.py index 4c7acfb1a0..62d51a2df5 100644 --- a/glance/tests/functional/test_reload.py +++ b/glance/tests/functional/test_reload.py @@ -76,7 +76,12 @@ class TestReload(functional.FunctionalTest): pid = None pid = self._get_parent(server) process = psutil.Process(pid) - children = process.get_children() + try: + # psutils version >= 2 + children = process.children() + except AttributeError: + # psutils version < 2 + children = process.get_children() pids = set() for child in children: pids.add(child.pid) diff --git a/glance/tests/functional/v1/test_multiprocessing.py b/glance/tests/functional/v1/test_multiprocessing.py index 0a8034296a..8c7c0685a6 100644 --- a/glance/tests/functional/v1/test_multiprocessing.py +++ b/glance/tests/functional/v1/test_multiprocessing.py @@ -47,8 +47,12 @@ class TestMultiprocessing(functional.FunctionalTest): def _get_children(self): api_pid = self.api_server.process_pid process = psutil.Process(api_pid) - - children = process.get_children() + try: + # psutils version >= 2 + children = process.children() + except AttributeError: + # psutils version < 2 + children = process.get_children() pids = [str(child.pid) for child in children] return pids