From commits-return-49882-archive-asf-public=cust-asf.ponee.io@qpid.apache.org Tue Jun 9 13:23:50 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id E19D418062B for ; Tue, 9 Jun 2020 15:23:49 +0200 (CEST) Received: (qmail 35310 invoked by uid 500); 9 Jun 2020 13:23:49 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 35301 invoked by uid 99); 9 Jun 2020 13:23:49 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Jun 2020 13:23:49 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 0BD64814A0; Tue, 9 Jun 2020 13:23:49 +0000 (UTC) Date: Tue, 09 Jun 2020 13:23:48 +0000 To: "commits@qpid.apache.org" Subject: [qpid-proton] branch master updated: PROTON-2220: smarter accounting for file descriptors in tests (#259) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <159170902896.29593.17680719564263975993@gitbox.apache.org> From: jdanek@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: qpid-proton X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: caaa9459e77a593017fe4cfdea883bd21f66bf67 X-Git-Newrev: e4af6984b06bf663a14c4c0847c81f175828567b X-Git-Rev: e4af6984b06bf663a14c4c0847c81f175828567b X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. jdanek pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/qpid-proton.git The following commit(s) were added to refs/heads/master by this push: new e4af698 PROTON-2220: smarter accounting for file descriptors in tests (#259) e4af698 is described below commit e4af6984b06bf663a14c4c0847c81f175828567b Author: Jiri Daněk AuthorDate: Tue Jun 9 15:23:39 2020 +0200 PROTON-2220: smarter accounting for file descriptors in tests (#259) --- ...test_PROTON_1800_syncrequestresponse_fd_leak.py | 23 +++++++++++++--------- ...test_PROTON_2121_blocking_connection_fd_leak.py | 14 ++++++------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/python/tests/integration/test_PROTON_1800_syncrequestresponse_fd_leak.py b/python/tests/integration/test_PROTON_1800_syncrequestresponse_fd_leak.py index 08afc86..62134c2 100644 --- a/python/tests/integration/test_PROTON_1800_syncrequestresponse_fd_leak.py +++ b/python/tests/integration/test_PROTON_1800_syncrequestresponse_fd_leak.py @@ -31,6 +31,7 @@ import gc import os import threading import subprocess +import warnings from collections import namedtuple import cproton @@ -45,20 +46,24 @@ from proton.handlers import IncomingMessageHandler from test_unittest import unittest -def count_fds(): - # type: () -> int - return len(os.listdir('/proc/self/fd/')) +def get_fd_set(): + # type: () -> set[str] + return set(os.listdir('/proc/self/fd/')) @contextlib.contextmanager def no_fd_leaks(test): # type: (unittest.TestCase) -> None - before = count_fds() - yield - delta = count_fds() - before - if delta != 0: - subprocess.check_call("ls -lF /proc/{0}/fd/".format(os.getpid()), shell=True) - test.assertEqual(0, delta, "Found {0} new fd(s) after the test".format(delta)) + with warnings.catch_warnings(record=True) as ws: + before = get_fd_set() + yield + delta = get_fd_set().difference(before) + if len(delta) != 0: + subprocess.check_call("ls -lF /proc/{0}/fd/".format(os.getpid()), shell=True) + test.fail("Found {0} new fd(s) after the test".format(delta)) + + if len(ws) > 0: + test.fail([w.message for w in ws]) class Broker(proton.handlers.MessagingHandler): diff --git a/python/tests/integration/test_PROTON_2121_blocking_connection_fd_leak.py b/python/tests/integration/test_PROTON_2121_blocking_connection_fd_leak.py index dd6dcbe..97ed624 100644 --- a/python/tests/integration/test_PROTON_2121_blocking_connection_fd_leak.py +++ b/python/tests/integration/test_PROTON_2121_blocking_connection_fd_leak.py @@ -42,21 +42,21 @@ import proton.reactor from test_unittest import unittest -def count_fds(): - # type: () -> int - return len(os.listdir('/proc/self/fd/')) +def get_fd_set(): + # type: () -> set[str] + return set(os.listdir('/proc/self/fd/')) @contextlib.contextmanager def no_fd_leaks(test): # type: (unittest.TestCase) -> None with warnings.catch_warnings(record=True) as ws: - before = count_fds() + before = get_fd_set() yield - delta = count_fds() - before - if delta != 0: + delta = get_fd_set().difference(before) + if len(delta) != 0: subprocess.check_call("ls -lF /proc/{0}/fd/".format(os.getpid()), shell=True) - test.assertEqual(0, delta, "Found {0} new fd(s) after the test".format(delta)) + test.fail("Found {0} new fd(s) after the test".format(delta)) if len(ws) > 0: test.fail([w.message for w in ws]) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org For additional commands, e-mail: commits-help@qpid.apache.org