Skip to content

Commit

Permalink
get actual hostname for localhost (needed for Windows)
Browse files Browse the repository at this point in the history
  • Loading branch information
tagomoris committed Dec 20, 2016
1 parent c9ab7a7 commit ddd7baa
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/plugin/test_in_forward.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def teardown
port #{PORT}
bind 127.0.0.1
]
DUMMY_SOCK = Struct.new(:remote_host, :remote_addr, :remote_port).new("localhost", "127.0.0.1", 0)
LOCALHOST_HOSTNAME_GETTER = ->(){sock = UDPSocket.new(::Socket::AF_INET); sock.do_not_reverse_lookup = false; sock.connect("127.0.0.1", 2048); sock.peeraddr[2] }
LOCALHOST_HOSTNAME = LOCALHOST_HOSTNAME_GETTER.call
DUMMY_SOCK = Struct.new(:remote_host, :remote_addr, :remote_port).new(LOCALHOST_HOSTNAME_GETTER.call, "127.0.0.1", 0)
CONFIG_AUTH = %[
port #{PORT}
bind 127.0.0.1
Expand Down Expand Up @@ -520,7 +522,7 @@ def create_driver(conf=CONFIG)
logs = d.instance.log.logs
assert_equal 1, logs.select{|line|
line =~ / \[warn\]: Input chunk size is larger than 'chunk_size_warn_limit':/ &&
line =~ / tag="test.tag" host="localhost" limit=16777216 size=16777501/
line =~ / tag="test.tag" host="#{LOCALHOST_HOSTNAME}" limit=16777216 size=16777501/
}.size, "large chunk warning is not logged"

d.instance_shutdown
Expand All @@ -546,7 +548,7 @@ def create_driver(conf=CONFIG)
logs = d.instance.log.logs
assert_equal 1, logs.select{ |line|
line =~ / \[warn\]: Input chunk size is larger than 'chunk_size_warn_limit':/ &&
line =~ / tag="test.tag" host="localhost" limit=16777216 size=16777501/
line =~ / tag="test.tag" host="#{LOCALHOST_HOSTNAME}" limit=16777216 size=16777501/
}.size, "large chunk warning is not logged"

d.instance_shutdown
Expand Down Expand Up @@ -580,7 +582,7 @@ def create_driver(conf=CONFIG)
logs = d.instance.log.logs
assert_equal 1, logs.select{|line|
line =~ / \[warn\]: Input chunk size is larger than 'chunk_size_limit', dropped:/ &&
line =~ / tag="test.tag" host="localhost" limit=33554432 size=33554989/
line =~ / tag="test.tag" host="#{LOCALHOST_HOSTNAME}" limit=33554432 size=33554989/
}.size, "large chunk warning is not logged"

d.instance_shutdown
Expand All @@ -602,7 +604,7 @@ def create_driver(conf=CONFIG)
# check log
logs = d.instance.log.logs
assert_equal 1, logs.select{|line|
line =~ / \[warn\]: incoming chunk is broken: host="localhost" msg=#{data.inspect}/
line =~ / \[warn\]: incoming chunk is broken: host="#{LOCALHOST_HOSTNAME}" msg=#{data.inspect}/
}.size, "should not accept broken chunk"

d.instance_shutdown
Expand Down

0 comments on commit ddd7baa

Please sign in to comment.