yahns Ruby server user/dev discussion
 help / color / Atom feed
From: Eric Wong <e@80x24.org>
To: yahns-public@yhbt.net
Subject: [PATCH 1/5] test_proxy_pass_no_buffering: fix racy test
Date: Tue,  7 Jun 2016 07:39:04 +0000
Message-ID: <20160607073908.31035-2-e@80x24.org> (raw)
In-Reply-To: <20160607073908.31035-1-e@80x24.org>

We can force output buffer files to a directory of our
choosing to avoid being confused by temporary files
from other tests polluting the process we care about.
---
 test/test_proxy_pass_no_buffering.rb | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/test/test_proxy_pass_no_buffering.rb b/test/test_proxy_pass_no_buffering.rb
index b2c8b48..c60ccad 100644
--- a/test/test_proxy_pass_no_buffering.rb
+++ b/test/test_proxy_pass_no_buffering.rb
@@ -35,11 +35,13 @@ def setup
     server_helper_setup
     skip "kcar missing yahns/proxy_pass" unless defined?(Kcar)
     require 'yahns/proxy_pass'
+    @tmpdir = yahns_mktmpdir
   end
 
   def teardown
     @srv2.close if defined?(@srv2) && !@srv2.closed?
     server_helper_teardown
+    FileUtils.rm_rf(@tmpdir) if defined?(@tmpdir)
   end
 
   def check_headers(io)
@@ -55,11 +57,15 @@ def test_proxy_pass_no_buffering
     host2, port2 = @srv2.addr[3], @srv2.addr[1]
     pxp = Yahns::ProxyPass.new("http://#{host2}:#{port2}",
                                proxy_buffering: false)
+    tmpdir = @tmpdir
     pid = mkserver(cfg) do
       ObjectSpace.each_object(Yahns::TmpIO) { |io| io.close unless io.closed? }
       @srv2.close
       cfg.instance_eval do
-        app(:rack, pxp) { listen "#{host}:#{port}" }
+        app(:rack, pxp) do
+          listen "#{host}:#{port}"
+          output_buffering true, tmpdir: tmpdir
+        end
         stderr_path err.path
       end
     end
@@ -85,10 +91,11 @@ def test_proxy_pass_no_buffering
       sleep 0.1
       # ensure no files get created
       if RUBY_PLATFORM =~ /\blinux\b/ && `which lsof 2>/dev/null`.size >= 4
+        qtmpdir = Regexp.quote("#@tmpdir/")
         deleted1 = `lsof -p #{pid}`.split("\n")
-        deleted1 = deleted1.grep(/\bREG\b.* \(deleted\)/)
+        deleted1 = deleted1.grep(/\bREG\b.*#{qtmpdir}.* \(deleted\)/)
         deleted2 = `lsof -p #{pid2}`.split("\n")
-        deleted2 = deleted2.grep(/\bREG\b.* \(deleted\)/)
+        deleted2 = deleted2.grep(/\bREG\b.*#{qtmpdir}.* \(deleted\)/)
         [ deleted1, deleted2 ].each do |ary|
           ary.delete_if { |x| x =~ /\.(?:err|out) \(deleted\)/ }
         end

  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-07  7:39 [PATCH \0/5] another round of proxy-related bugfixes! Eric Wong
2016-06-07  7:39 ` Eric Wong [this message]
2016-06-07  7:39 ` [PATCH 2/5] queue_*: check for closed IO objects Eric Wong
2016-06-07  7:39 ` [PATCH 3/5] cleanup graceful shutdown handling Eric Wong
2016-06-07  7:39 ` [PATCH 4/5] proxy_pass: more descriptive error messages Eric Wong
2016-06-07  7:39 ` [PATCH 5/5] proxy_pass: fix HTTP/1.0 backends on EOF w/o buffering Eric Wong

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/yahns/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160607073908.31035-2-e@80x24.org \
    --to=e@80x24.org \
    --cc=yahns-public@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

yahns Ruby server user/dev discussion

Archives are clonable:
	git clone --mirror https://yhbt.net/yahns-public
	git clone --mirror http://ou63pmih66umazou.onion/yahns-public

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.lang.ruby.yahns
	nntp://ou63pmih66umazou.onion/inbox.comp.lang.ruby.yahns

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox