From b00f90e83df4076cbe84655235c8f5acd05d1af2 Mon Sep 17 00:00:00 2001 From: Christian Norbert Menges Date: Mon, 6 Nov 2023 11:17:53 +0100 Subject: [PATCH] out_http: Add test for connection recreation Signed-off-by: Christian Norbert Menges --- test/plugin/test_out_http.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/plugin/test_out_http.rb b/test/plugin/test_out_http.rb index b0e1a469a7..688c99e861 100644 --- a/test/plugin/test_out_http.rb +++ b/test/plugin/test_out_http.rb @@ -426,4 +426,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 https://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