Skip to content

Commit

Permalink
fix test with added (missing) error definition
Browse files Browse the repository at this point in the history
  • Loading branch information
tagomoris authored and okkez committed May 16, 2016
1 parent 0c99097 commit 4474997
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions test/plugin/test_out_forward.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setup
]

def create_driver(conf=CONFIG)
Fluent::Test::OutputTestDriver.new(Fluent::ForwardOutput) {
Fluent::Test::BufferedOutputTestDriver.new(Fluent::ForwardOutput) {
attr_reader :responses, :exceptions

def initialize
Expand Down Expand Up @@ -231,10 +231,12 @@ def test_require_a_node_not_supporting_responses_to_respond_with_ack
end
d.run_timeout = 2

target_input_driver.run do
d.run do
records.each do |record|
d.emit record, time
assert_raise Fluent::ForwardOutputACKTimeoutError do
target_input_driver.run do
d.run do
records.each do |record|
d.emit record, time
end
end
end
end
Expand Down Expand Up @@ -272,10 +274,12 @@ def test_require_a_node_not_supporting_responses_2_to_respond_with_ack
end
d.run_timeout = 2

target_input_driver.run do
d.run do
records.each do |record|
d.emit record, time
assert_raise Fluent::ForwardOutputConnectionClosedError do
target_input_driver.run do
d.run do
records.each do |record|
d.emit record, time
end
end
end
end
Expand Down Expand Up @@ -318,7 +322,10 @@ def write(data)
end

def close
@sock.close
unless @sock.closed?
@sock.close_write
@sock.close
end
end
}

Expand All @@ -332,14 +339,18 @@ def close
handler.on_read(raw_data)
# chunk_counter is reset to zero only after all the data have been received and successfully deserialized.
break if handler.chunk_counter == 0
break if sock.closed?
end
if disconnect
handler.close
sock = nil
end
sleep # wait for connection to be closed by client
ensure
sock.close if sock
if sock && !sock.closed?
sock.close_write
sock.close
end
end
end
end
Expand Down Expand Up @@ -370,10 +381,6 @@ class DummyEngineDriver < Fluent::Test::TestDriver
def initialize(klass, &block)
super(klass, &block)
@engine = DummyEngineClass.new
@klass = klass
# To avoid accessing Fluent::Engine, set Engine as a plugin's class constant (Fluent::SomePlugin::Engine).
# But this makes it impossible to run tests concurrently by threading in a process.
@klass.const_set(:Engine, @engine)
end

def inject_router
Expand All @@ -383,9 +390,6 @@ def inject_router

def run(&block)
super(&block)
@klass.class_eval do
remove_const(:Engine)
end
end

def emits
Expand Down

0 comments on commit 4474997

Please sign in to comment.