From: Eric Wong <e@80x24.org>
To: mogilefs-client-public@bogomips.org
Subject: [7/6 PATCH] connect_timeout: match :timeout if unset
Date: Wed, 31 Aug 2016 07:09:51 +0000 [thread overview]
Message-ID: <20160831070951.GA7205@starla> (raw)
In-Reply-To: <20160831025046.24153-5-e@80x24.org>
And add some weak tests while we're at it.
Actually simulating a connection timeout on localhost
will be difficult.
---
lib/mogilefs/backend.rb | 2 +-
test/test_backend.rb | 17 ++++++++++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/lib/mogilefs/backend.rb b/lib/mogilefs/backend.rb
index 4cf2526..7f91508 100644
--- a/lib/mogilefs/backend.rb
+++ b/lib/mogilefs/backend.rb
@@ -79,7 +79,7 @@ def initialize(args)
@mutex = Mutex.new
@timeout = args[:timeout] || 3
- @connect_timeout = args[:connect_timeout] || 3
+ @connect_timeout = args[:connect_timeout] || @timeout
@socket = nil
@lasterr = nil
@lasterrstr = nil
diff --git a/test/test_backend.rb b/test/test_backend.rb
index 2078e9b..4d41354 100644
--- a/test/test_backend.rb
+++ b/test/test_backend.rb
@@ -25,12 +25,14 @@ def test_initialize
assert_equal ['localhost:1'], @backend.hosts
assert_equal 3, @backend.timeout
+ assert_equal 3, @backend.instance_variable_get(:@connect_timeout)
assert_equal nil, @backend.lasterr
assert_equal nil, @backend.lasterrstr
assert_equal({}, @backend.dead)
@backend = MogileFS::Backend.new :hosts => ['localhost:6001'], :timeout => 1
assert_equal 1, @backend.timeout
+ assert_equal 1, @backend.instance_variable_get(:@connect_timeout)
end
def test_do_request
@@ -223,5 +225,18 @@ def test_fail_timeout
c = MogileFS::MogileFS.new(o)
assert_equal 0.666, c.backend.instance_variable_get(:@fail_timeout)
end
-end
+ def test_connect_timeout
+ o = {
+ :domain => "none",
+ :hosts => %w(0:666 0:6 0:66),
+ :connect_timeout => 1
+ }
+ c = MogileFS::MogileFS.new(o)
+ assert_equal 1, c.backend.instance_variable_get(:@connect_timeout)
+ o[:timeout] = 5
+ c = MogileFS::MogileFS.new(o)
+ assert_equal 1, c.backend.instance_variable_get(:@connect_timeout)
+ assert_equal 5, c.backend.instance_variable_get(:@timeout)
+ end
+end
--
EW
next prev parent reply other threads:[~2016-08-31 7:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-31 2:50 [PATCH 0/6] misc fixes and features Eric Wong
2016-08-31 2:50 ` [PATCH 1/6] test_fresh: do not delete non-existent domain Eric Wong
2016-08-31 2:50 ` [PATCH 2/6] admin: map unset reject_bad_md5 field to nil Eric Wong
2016-08-31 2:50 ` [PATCH 3/6] socket/pure_ruby: connect with "exception:false" on Ruby 2.3+ Eric Wong
2016-08-31 2:50 ` [PATCH 4/6] implement :connect_timeout option Eric Wong
2016-08-31 7:09 ` Eric Wong [this message]
2016-08-31 2:50 ` [PATCH 5/6] add .gitattributes for Ruby method detection Eric Wong
2016-08-31 2:50 ` [PATCH 6/6] README: stop mentioning cgit Eric Wong
Reply instructions:
You may reply publicly 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/mogilefs-client/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160831070951.GA7205@starla \
--to=e@80x24.org \
--cc=mogilefs-client-public@bogomips.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/mogilefs-client.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).