From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Flag: YES X-Spam-Level: **** X-Spam-ASN: AS1759 84.248.0.0/14 X-Spam-Status: Yes, score=4.2 required=3.0 tests=BAYES_05, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_BL,RCVD_IN_MSPIKE_ZBI,RCVD_IN_PBL, RCVD_IN_SORBS_DUL,RCVD_IN_XBL,RDNS_DYNAMIC,SPF_FAIL,SPF_HELO_FAIL shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 X-Spam-Report: * 3.3 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL * [84.251.91.165 listed in zen.spamhaus.org] * 0.4 RCVD_IN_XBL RBL: Received via a relay in Spamhaus XBL * 0.0 RCVD_IN_DNSWL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to DNSWL * was blocked. See * http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for * more information. * [84.251.91.165 listed in list.dnswl.org] * 0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP address * [84.251.91.165 listed in dnsbl.sorbs.net] * 0.0 SPF_FAIL SPF: sender does not match SPF record (fail) * [SPF failed: Please see http://www.openspf.org/Why?s=mfrom;id=e%4080x24.org;ip=84.251.91.165;r=dcvr.yhbt.net] * 0.0 SPF_HELO_FAIL SPF: HELO does not match SPF record (fail) * [SPF failed: Please see http://www.openspf.org/Why?s=helo;id=80x24.org;ip=84.251.91.165;r=dcvr.yhbt.net] * -0.5 BAYES_05 BODY: Bayes spam probability is 1 to 5% * [score: 0.0283] * 0.0 RCVD_IN_MSPIKE_BL Mailspike blacklisted * 1.0 RDNS_DYNAMIC Delivered to internal network by host with * dynamic-looking rDNS * 0.0 RCVD_IN_MSPIKE_ZBI No description available. Received: from 80x24.org (dsl-olubrasgw1-54fb5b-165.dhcp.inet.fi [84.251.91.165]) by dcvr.yhbt.net (Postfix) with ESMTP id C54081F99B for ; Sun, 15 May 2016 08:41:42 +0000 (UTC) From: Eric Wong To: yahns-public@yhbt.net Subject: [PATCH] test/test_client_expire: fix for high RLIMIT_NOFILE Date: Sun, 15 May 2016 08:41:40 +0000 Message-Id: <20160515084140.31239-1-e@80x24.org> List-Id: The ab(1) command we use for testing is limited to 20000 open connections under Debian jessie; a perfectly reasonable limit to avoid port exhaustion. I never noticed this limit before, but systemd under Jessie seems to have upped the default RLIMIT_NOFILE to 65536(!), causing ab to error out. We don't even need 10K connections for testing, we just need to hit *some* limit before we start expiring. So lower the RLIMIT_NOFILE back to 1024 in the forked server process so we can test more quickly without running out of ports or memory, since exhausting the 65536 RLIMIT_NOFILE limit is not going to happen with a single TCP address. --- test/test_client_expire.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/test_client_expire.rb b/test/test_client_expire.rb index b2f932b..b6dec1a 100644 --- a/test/test_client_expire.rb +++ b/test/test_client_expire.rb @@ -99,6 +99,14 @@ def test_client_expire_desperate end stderr_path err.path end + + # 1024 is common on old systems, but nowadays Jessie seems to be 65536 + nr = Process.getrlimit(:NOFILE)[0] + if nr >= 1024 + nr = 1024 + do_rlimit = true + end + pid = mkserver(cfg) do keep = { $stderr => true, $stdout => true, $stdin => true, @srv => true } ObjectSpace.each_object(IO) do |obj| @@ -108,7 +116,9 @@ def test_client_expire_desperate rescue IOError # could be uninitialized end end + Process.setrlimit(:NOFILE, nr) if do_rlimit end + f = get_tcp_client(host, port) f.write "G" s = get_tcp_client(host, port) @@ -119,10 +129,9 @@ def test_client_expire_desperate assert_match(%r{keep-alive}, str) sleep 1 - # ignore errors, just beat the crap out of the process - nr = Process.getrlimit(:NOFILE)[0] # 1024 is common assert_operator nr, :>, 666, "increase RLIM_NOFILE (ulimit -n)" nr -= 50 + # ignore errors, just beat the crap out of the process opts = { out: "/dev/null", err: "/dev/null", close_others: true } begin pids = 2.times.map do