Skip to content

Commit a3d2d02

Browse files
committed
Fixed unit tests on Logstash 8.x
Unit tests were failing due to a new requirement to include the `rackup` gem. This commit includes the version of `rackup` prior to the Fiber based rework, as that was causing test failures. This commit also ensures that the request body is rewound before being read in tests.
1 parent 5cab162 commit a3d2d02

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 5.7.1
2+
- Added new development `rackup` dependency to fix tests
3+
14
## 5.7.0
25
- Added new `ssl_enabled` setting for enabling/disabling the SSL configurations [#144](https://github.com/logstash-plugins/logstash-output-http/pull/144)
36

logstash-output-http.gemspec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'logstash-output-http'
3-
s.version = '5.7.0'
3+
s.version = '5.7.1'
44
s.licenses = ['Apache License (2.0)']
55
s.summary = "Sends events to a generic HTTP or HTTPS endpoint"
66
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -25,4 +25,7 @@ Gem::Specification.new do |s|
2525
s.add_development_dependency 'logstash-devutils'
2626
s.add_development_dependency 'sinatra'
2727
s.add_development_dependency 'webrick'
28+
29+
# Pin to avoid using new Fiber-based implementation that breaks tests here
30+
s.add_development_dependency 'rackup', "< 2.1.0"
2831
end

spec/outputs/http_spec.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255
end
256256

257257
let(:last_request) { TestApp.last_request }
258-
let(:body) { last_request.body.read }
258+
let(:body) { read_last_request_body(last_request) }
259259
let(:content_type) { last_request.env["CONTENT_TYPE"] }
260260

261261
it "should receive the request" do
@@ -458,7 +458,7 @@
458458
after { subject.close }
459459

460460
let(:last_request) { TestApp.last_request }
461-
let(:last_request_body) { last_request.body.read }
461+
let(:last_request_body) { read_last_request_body(last_request) }
462462

463463
let(:event) { LogStash::Event.new("message" => "hello!") }
464464

@@ -530,3 +530,10 @@
530530
end if tls_version_enabled_by_default?('TLSv1.3') && JOpenSSL::VERSION > '0.12' # due WEBrick uses OpenSSL
531531

532532
end
533+
534+
# Pre-emptively rewind the retrieval of `last_request.body` - for form based endpoints, the body
535+
# is placed in params, and body is empty, requiring a `rewind` for the body to be available for comparison
536+
def read_last_request_body(last_request)
537+
last_request.body.rewind
538+
last_request.body.read
539+
end

0 commit comments

Comments
 (0)