|
262 | 262 | end
|
263 | 263 | end
|
264 | 264 |
|
| 265 | + describe "remove empty params from action params" do |
| 266 | + let(:options) { {"parent" => "%{myparent}", "document_id" => "%{myid}"} } |
| 267 | + subject(:eso) {LogStash::Outputs::ElasticSearch.new(options)} |
| 268 | + |
| 269 | + let(:event_full) { LogStash::Event.new("message" => "blah", "myid" => "mytestid", "myparent" => "mytestparent") } |
| 270 | + let(:event_partial_missing) { LogStash::Event.new("message" => "blah") } |
| 271 | + let(:event_partial_empty) { LogStash::Event.new("message" => "blah", "myid" => "", "myparent" => "") } |
| 272 | + |
| 273 | + context "when remove_empty_action_params enabled" do |
| 274 | + let(:options) { super.merge("remove_empty_action_params" => true) } |
| 275 | + |
| 276 | + it "should interpolate the requested id and parent values" do |
| 277 | + params = eso.event_action_params(event_full) |
| 278 | + expect(params).to include(:_id => "mytestid", :parent => "mytestparent") |
| 279 | + end |
| 280 | + |
| 281 | + it "should interpolate the requested id and parent values and remove them when they missing" do |
| 282 | + params = eso.event_action_params(event_partial_missing) |
| 283 | + expect(params).not_to include(:_id, :parent) |
| 284 | + end |
| 285 | + |
| 286 | + it "should interpolate the requested id and parent values and remove them when they empty" do |
| 287 | + params = eso.event_action_params(event_partial_empty) |
| 288 | + expect(params).not_to include(:_id, :parent) |
| 289 | + end |
| 290 | + end |
| 291 | + |
| 292 | + context "when remove_empty_action_params disabled" do |
| 293 | + let(:options) { super.merge("remove_empty_action_params" => false) } |
| 294 | + |
| 295 | + it "should interpolate the requested id and parent values" do |
| 296 | + params = eso.event_action_params(event_full) |
| 297 | + expect(params).to include({:_id => "mytestid", :parent => "mytestparent"}) |
| 298 | + end |
| 299 | + |
| 300 | + it "should interpolate the requested id and parent values and not remove them when they missing" do |
| 301 | + params = eso.event_action_params(event_partial_missing) |
| 302 | + expect(params).to include(:_id => nil, :parent => nil) |
| 303 | + end |
| 304 | + |
| 305 | + it "should interpolate the requested id and parent values and not remove them when they empty" do |
| 306 | + params = eso.event_action_params(event_partial_missing) |
| 307 | + expect(params).to include(:_id => "", :parent => "") |
| 308 | + end |
| 309 | + end |
| 310 | + end |
| 311 | + |
265 | 312 | describe "sleep interval calculation" do
|
266 | 313 | let(:retry_max_interval) { 64 }
|
267 | 314 | subject(:eso) { LogStash::Outputs::ElasticSearch.new("retry_max_interval" => retry_max_interval) }
|
|
0 commit comments