|
275 | 275 | let(:event_fields) {{}}
|
276 | 276 | let(:event) { LogStash::Event.new(event_fields)}
|
277 | 277 |
|
| 278 | + context "when plugin's version is specified" do |
| 279 | + let(:options) { super().merge("version" => "123")} |
| 280 | + |
| 281 | + context "when the event contains an integration metadata version" do |
| 282 | + let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"version" => "456"}}}) } |
| 283 | + |
| 284 | + it "plugin's version is used" do |
| 285 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:version => "123") |
| 286 | + end |
| 287 | + end |
| 288 | + |
| 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 |
| 301 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:version => "456") |
| 302 | + end |
| 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_not include(:version) |
| 308 | + end |
| 309 | + end |
| 310 | + end |
| 311 | + |
| 312 | + context "when plugin's version_type is specified" do |
| 313 | + let(:options) { super().merge("version_type" => "internal")} |
| 314 | + |
| 315 | + context "when the event contains an integration metadata version_type" do |
| 316 | + let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"version_type" => "external"}}}) } |
| 317 | + |
| 318 | + it "plugin's version_type is used" do |
| 319 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:version_type => "internal") |
| 320 | + end |
| 321 | + end |
| 322 | + |
| 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 |
| 335 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:version_type => "external") |
| 336 | + end |
| 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_not include(:version_type) |
| 342 | + end |
| 343 | + end |
| 344 | + end |
| 345 | + |
| 346 | + context "when plugin's routing is specified" do |
| 347 | + let(:options) { super().merge("routing" => "settings_routing")} |
| 348 | + |
| 349 | + context "when the event contains an integration metadata routing" do |
| 350 | + let(:event) { LogStash::Event.new({"@metadata" => {"_ingest_document" => {"routing" => "meta-document-routing"}}}) } |
| 351 | + |
| 352 | + it "plugin's routing is used" do |
| 353 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => "settings_routing") |
| 354 | + end |
| 355 | + end |
| 356 | + |
| 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 |
| 369 | + expect(subject.send(:event_action_tuple, event)[1]).to include(:routing => "meta-document-routing") |
| 370 | + end |
| 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 |
| 378 | + end |
| 379 | + |
278 | 380 | context "when plugin's index is specified" do
|
279 | 381 | let(:options) { super().merge("index" => "index_from_settings")}
|
280 | 382 |
|
|
0 commit comments