Skip to content

Commit

Permalink
out_http: Add test for connection recreation
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Norbert Menges <[email protected]>
  • Loading branch information
Garfield96 authored and daipom committed Apr 30, 2024
1 parent 5844e96 commit 7a5662a
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/plugin/test_out_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -518,4 +518,40 @@ def test_write_with_https
assert_not_empty result.headers
end
end

sub_test_case 'connection_reuse' do
def server_port
19883
end

def test_connection_recreation
d = create_driver(%[
endpoint http://127.0.0.1:#{server_port}/test
reuse_connections true
])

d.run(default_tag: 'test.http', shutdown: false) do
d.feed(test_events[0])
end

data = @@result.data

# Restart server to simulate connection loss
@@http_server_thread.kill
@@http_server_thread.join
@@http_server_thread = Thread.new do
run_http_server
end

d.run(default_tag: 'test.http') do
d.feed(test_events[1])
end

result = @@result
assert_equal 'POST', result.method
assert_equal 'application/x-ndjson', result.content_type
assert_equal test_events, data.concat(result.data)
assert_not_empty result.headers
end
end
end

0 comments on commit 7a5662a

Please sign in to comment.