Skip to content

Commit

Permalink
Fix: hosts => "es_host:port" regression (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
kares authored Feb 21, 2022
1 parent 13b62c3 commit 8385b2e
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .ci/logstash-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ wait_for_es() {
}

if [[ "$INTEGRATION" != "true" ]]; then
bundle exec rspec -fd spec/inputs -t ~integration -t ~secure_integration
jruby -rbundler/setup -S rspec -fd --tag ~integration --tag ~secure_integration spec/inputs
else
if [[ "$SECURE_INTEGRATION" == "true" ]]; then
extra_tag_args="--tag secure_integration"
else
extra_tag_args="--tag ~secure_integration --tag integration"
fi
wait_for_es
bundle exec rspec -fd $extra_tag_args --tag es_version:$ELASTIC_STACK_VERSION spec/inputs/integration
jruby -rbundler/setup -S rspec -fd $extra_tag_args --tag es_version:$ELASTIC_STACK_VERSION spec/inputs/integration
fi
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ before_install:

env:
- INTEGRATION=false ELASTIC_STACK_VERSION=7.x
- INTEGRATION=false ELASTIC_STACK_VERSION=8.x
- INTEGRATION=false ELASTIC_STACK_VERSION=7.x SNAPSHOT=true
- INTEGRATION=false ELASTIC_STACK_VERSION=8.x SNAPSHOT=true
- INTEGRATION=false ELASTIC_STACK_VERSION=7.16.3 MANTICORE_VERSION=0.7.1 ELASTICSEARCH_VERSION=7.15.0
- INTEGRATION=true ELASTIC_STACK_VERSION=7.x
- INTEGRATION=true ELASTIC_STACK_VERSION=7.x SNAPSHOT=true
- INTEGRATION=true ELASTIC_STACK_VERSION=8.x SNAPSHOT=true
- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=7.x
- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=7.15.0
- INTEGRATION=true ELASTIC_STACK_VERSION=7.x SNAPSHOT=true LOG_LEVEL=info
- INTEGRATION=true ELASTIC_STACK_VERSION=8.x SNAPSHOT=true LOG_LEVEL=info
- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=7.x LOG_LEVEL=info
- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=7.15.0 MANTICORE_VERSION=0.7.1 ELASTICSEARCH_VERSION=7.14.1 LOG_LEVEL=info
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 4.12.2
- Fix: hosts => "es_host:port" regression [#168](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/168)

## 4.12.1
- Fixed too_long_frame_exception by passing scroll_id in the body [#159](https://github.com/logstash-plugins/logstash-input-elasticsearch/pull/159)

Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ if Dir.exist?(logstash_path) && use_logstash_source
gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
end

gem 'manticore', ENV['MANTICORE_VERSION'] if ENV['MANTICORE_VERSION']
gem 'elasticsearch', ENV['ELASTICSEARCH_VERSION'] if ENV['ELASTICSEARCH_VERSION']
12 changes: 6 additions & 6 deletions lib/logstash/inputs/elasticsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,13 @@ def setup_ssl

def setup_hosts
@hosts = Array(@hosts).map { |host| host.to_s } # potential SafeURI#to_s
if @ssl
@hosts.map do |h|
host, port = h.split(":")
{ :host => host, :scheme => 'https', :port => port }
@hosts.map do |h|
if h.start_with?('http:', 'https:')
h
else
host, port = h.split(':')
{ host: host, port: port, scheme: (@ssl ? 'https' : 'http') }
end
else
@hosts
end
end

Expand Down
2 changes: 1 addition & 1 deletion logstash-input-elasticsearch.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|

s.name = 'logstash-input-elasticsearch'
s.version = '4.12.1'
s.version = '4.12.2'
s.licenses = ['Apache License (2.0)']
s.summary = "Reads query results from an Elasticsearch cluster"
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"
Expand Down
39 changes: 33 additions & 6 deletions spec/inputs/integration/elasticsearch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@

describe LogStash::Inputs::Elasticsearch do

let(:config) { { 'hosts' => [ESHelper.get_host_port],
SECURE_INTEGRATION = ENV['SECURE_INTEGRATION'].eql? 'true'

let(:config) { { 'hosts' => ["http#{SECURE_INTEGRATION ? 's' : nil}://#{ESHelper.get_host_port}"],
'index' => 'logs',
'query' => '{ "query": { "match": { "message": "Not found"} }}' } }
let(:plugin) { described_class.new(config) }
let(:event) { LogStash::Event.new({}) }
let(:client_options) { Hash.new }

let(:user) { ENV['ELASTIC_USER'] || 'simpleuser' }
let(:password) { ENV['ELASTIC_PASSWORD'] || 'abc123' }
let(:ca_file) { "spec/fixtures/test_certs/ca.crt" }

before(:each) do
@es = ESHelper.get_client(client_options)
# Delete all templates first.
Expand Down Expand Up @@ -45,18 +51,15 @@
end
end

describe 'against an unsecured elasticsearch', :integration => true do
describe 'against an unsecured elasticsearch', integration: true do
before(:each) do
plugin.register
end

it_behaves_like 'an elasticsearch index plugin'
end

describe 'against a secured elasticsearch', :secure_integration => true do
let(:user) { ENV['ELASTIC_USER'] || 'simpleuser' }
let(:password) { ENV['ELASTIC_PASSWORD'] || 'abc123' }
let(:ca_file) { "spec/fixtures/test_certs/ca.crt" }
describe 'against a secured elasticsearch', secure_integration: true do

let(:client_options) { { :ca_file => ca_file, :user => user, :password => password } }

Expand All @@ -78,4 +81,28 @@
end

end

context 'setting host:port', integration: true do

let(:config) do
super().merge "hosts" => [ESHelper.get_host_port]
end

it_behaves_like 'an elasticsearch index plugin'

end

context 'setting host:port (and ssl)', secure_integration: true do

let(:client_options) { { :ca_file => ca_file, :user => user, :password => password } }

let(:config) do
config = super().merge "hosts" => [ESHelper.get_host_port]
config.merge('user' => user, 'password' => password, 'ssl' => true, 'ca_file' => ca_file)
end

it_behaves_like 'an elasticsearch index plugin'

end

end

0 comments on commit 8385b2e

Please sign in to comment.