|
275 | 275 | let(:event_fields) {{}} |
276 | 276 | let(:event) { LogStash::Event.new(event_fields)} |
277 | 277 |
|
278 | | - context "which contains version field" do |
279 | | - # defines an event with version in the integration metadata section |
280 | | - let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"version" => "456"}}}) } |
| 278 | + context "when plugin's version is specified" do |
| 279 | + let(:options) { super().merge("version" => "123")} |
281 | 280 |
|
282 | | - context "when version is also specified in plugin settings" do |
283 | | - let(:options) { super().merge("version" => "123")} |
| 281 | + context "when the event contains an integration metadata version" do |
| 282 | + let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"version" => "456"}}}) } |
284 | 283 |
|
285 | | - it "takes precedence over the integration one" do |
| 284 | + it "plugin's version is used" do |
286 | 285 | expect(subject.send(:event_action_tuple, event)[1]).to include(:version => "123") |
287 | 286 | end |
288 | 287 | end |
289 | 288 |
|
290 | | - context "when version is not defined in plugin settings" do |
291 | | - it "must use the value from the integration's metadata" do |
| 289 | + context "when the event DOESN'T contains an integration metadata version" do |
| 290 | + it "plugin's version is used" do |
| 291 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:version => "123") |
| 292 | + end |
| 293 | + end |
| 294 | + end |
| 295 | + |
| 296 | + context "when plugin's version is NOT specified" do |
| 297 | + context "when the event contains an integration metadata version" do |
| 298 | + let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"version" => "456"}}}) } |
| 299 | + |
| 300 | + it "event's metadata version is used" do |
292 | 301 | expect(subject.send(:event_action_tuple, event)[1]).to include(:version => "456") |
293 | 302 | end |
294 | 303 | end |
| 304 | + |
| 305 | + context "when the event DOESN'T contain an integration metadata version" do |
| 306 | + it "plugin's default id mechanism is used" do |
| 307 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:version => nil) |
| 308 | + end |
| 309 | + end |
295 | 310 | end |
296 | 311 |
|
297 | | - context "which contains version_type field" do |
298 | | - # defines an event with version_type in the integration metadata section |
299 | | - let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"version_type" => "external"}}}) } |
| 312 | + context "when plugin's version_type is specified" do |
| 313 | + let(:options) { super().merge("version_type" => "internal")} |
300 | 314 |
|
301 | | - context "when version_type is also specified in plugin settings" do |
302 | | - let(:options) { super().merge("version_type" => "internal")} |
| 315 | + context "when the event contains an integration metadata version_type" do |
| 316 | + let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"version_type" => "external"}}}) } |
303 | 317 |
|
304 | | - it "takes precedence over the integration one" do |
| 318 | + it "plugin's version_type is used" do |
305 | 319 | expect(subject.send(:event_action_tuple, event)[1]).to include(:version_type => "internal") |
306 | 320 | end |
307 | 321 | end |
308 | 322 |
|
309 | | - context "when version_type is not defined in plugin settings" do |
310 | | - it "must use the value from the integration's metadata" do |
| 323 | + context "when the event DOESN'T contains an integration metadata version_type" do |
| 324 | + it "plugin's version_type is used" do |
| 325 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:version_type => "internal") |
| 326 | + end |
| 327 | + end |
| 328 | + end |
| 329 | + |
| 330 | + context "when plugin's version_type is NOT specified" do |
| 331 | + context "when the event contains an integration metadata version_type" do |
| 332 | + let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"version_type" => "external"}}}) } |
| 333 | + |
| 334 | + it "event's metadata version_type is used" do |
311 | 335 | expect(subject.send(:event_action_tuple, event)[1]).to include(:version_type => "external") |
312 | 336 | end |
313 | 337 | end |
| 338 | + |
| 339 | + context "when the event DOESN'T contain an integration metadata version_type" do |
| 340 | + it "plugin's default id mechanism is used" do |
| 341 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:version_type => nil) |
| 342 | + end |
| 343 | + end |
314 | 344 | end |
315 | 345 |
|
316 | | - context "which contains routing field in its metadata" do |
317 | | - # defines an event with routing in the integration metadata section |
318 | | - let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"routing" => "meta-document-routing"}}}) } |
| 346 | + context "when plugin's routing is specified" do |
| 347 | + let(:options) { super().merge("routing" => "settings_routing")} |
319 | 348 |
|
320 | | - context "when routing is specified in plugin settings" do |
321 | | - let(:options) { super().merge("routing" => "settings_routing")} |
| 349 | + context "when the event contains an integration metadata routing" do |
| 350 | + let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"routing" => "meta-document-routing"}}}) } |
322 | 351 |
|
323 | | - it "takes precedence over the integration one" do |
| 352 | + it "plugin's routing is used" do |
324 | 353 | expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => "settings_routing") |
325 | 354 | end |
326 | 355 | end |
327 | 356 |
|
328 | | - context "when routing is not defined in plugin settings" do |
329 | | - it "must use the value from the integration's metadata" do |
| 357 | + context "when the event DOESN'T contains an integration metadata routing" do |
| 358 | + it "plugin's routing is used" do |
| 359 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => "settings_routing") |
| 360 | + end |
| 361 | + end |
| 362 | + end |
| 363 | + |
| 364 | + context "when plugin's routing is NOT specified" do |
| 365 | + context "when the event contains an integration metadata routing" do |
| 366 | + let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"routing" => "meta-document-routing"}}}) } |
| 367 | + |
| 368 | + it "event's metadata routing is used" do |
330 | 369 | expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => "meta-document-routing") |
331 | 370 | end |
332 | 371 | end |
| 372 | + |
| 373 | + context "when the event DOESN'T contain an integration metadata routing" do |
| 374 | + it "plugin's default id mechanism is used" do |
| 375 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => nil) |
| 376 | + end |
| 377 | + end |
333 | 378 | end |
334 | 379 |
|
335 | 380 | context "when plugin's index is specified" do |
|
0 commit comments