Skip to content

Commit 4d459e2

Browse files
committed
Merge pull request #108 from talevy/fix/78
log about support for create_unless_exists in http protocol
2 parents c1dcdb7 + 4cdaee7 commit 4d459e2

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/logstash/outputs/elasticsearch.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ def register
257257
@protocol = LogStash::Environment.jruby? ? "node" : "http"
258258
end
259259

260+
if @protocol == "http" && @action == "create_unless_exists"
261+
raise(LogStash::ConfigurationError, "action => 'create_unless_exists' is not supported under the HTTP protocol");
262+
end
263+
260264
if ["node", "transport"].include?(@protocol)
261265
# Node or TransportClient; requires JRuby
262266
raise(LogStash::PluginLoadingError, "This configuration requires JRuby. If you are not using JRuby, you must set 'protocol' to 'http'. For example: output { elasticsearch { protocol => \"http\" } }") unless LogStash::Environment.jruby?

spec/outputs/elasticsearch_spec.rb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,20 @@
66

77
describe "outputs/elasticsearch" do
88

9-
it "should register" do
10-
output = LogStash::Plugin.lookup("output", "elasticsearch").new("embedded" => "false", "protocol" => "transport", "manage_template" => "false")
9+
context "registration" do
1110

12-
# register will try to load jars and raise if it cannot find jars
13-
expect {output.register}.to_not raise_error
11+
it "should register" do
12+
output = LogStash::Plugin.lookup("output", "elasticsearch").new("embedded" => "false", "protocol" => "transport", "manage_template" => "false")
13+
14+
# register will try to load jars and raise if it cannot find jars
15+
expect {output.register}.to_not raise_error
16+
end
17+
18+
it "should fail to register when protocol => http, action => create_unless_exists" do
19+
output = LogStash::Plugin.lookup("output", "elasticsearch").new("protocol" => "http", "action" => "create_unless_exists")
20+
21+
expect {output.register}.to raise_error
22+
end
1423
end
1524

1625
describe "ship lots of events w/ default index_type", :elasticsearch => true do

0 commit comments

Comments
 (0)