fluent-plugin-elasticsearch 5.0.3 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,6 +34,10 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
34
34
  }.configure(conf)
35
35
  end
36
36
 
37
+ def elasticsearch_transport_layer_decoupling?
38
+ Gem::Version.create(::Elasticsearch::Transport::VERSION) >= Gem::Version.new("7.14.0")
39
+ end
40
+
37
41
  def default_type_name
38
42
  Fluent::Plugin::ElasticsearchOutput::DEFAULT_TYPE_NAME
39
43
  end
@@ -54,6 +58,11 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
54
58
  end
55
59
  end
56
60
 
61
+ def stub_elastic_info(url="http://localhost:9200/", version="6.4.2")
62
+ body ="{\"version\":{\"number\":\"#{version}\", \"build_flavor\":\"default\"},\"tagline\" : \"You Know, for Search\"}"
63
+ stub_request(:get, url).to_return({:status => 200, :body => body, :headers => { 'Content-Type' => 'json' } })
64
+ end
65
+
57
66
  def stub_elastic_unavailable(url="http://localhost:9200/_bulk")
58
67
  stub_request(:post, url).to_return(:status => [503, "Service Unavailable"])
59
68
  end
@@ -152,16 +161,25 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
152
161
  }
153
162
  instance = driver(config).instance
154
163
 
155
- assert_equal nil, instance.client.transport.options[:transport_options][:headers]["Content-Encoding"]
164
+ if elasticsearch_transport_layer_decoupling?
165
+ assert_equal nil, instance.client.transport.transport.options[:transport_options][:headers]["Content-Encoding"]
166
+ else
167
+ assert_equal nil, instance.client.transport.options[:transport_options][:headers]["Content-Encoding"]
168
+ end
156
169
 
157
170
  stub_request(:post, "http://localhost:9200/_bulk").
158
171
  to_return(status: 200, body: "", headers: {})
172
+ stub_elastic_info
159
173
  driver.run(default_tag: 'test') do
160
174
  driver.feed(sample_record)
161
175
  end
162
176
  compressable = instance.compressable_connection
163
177
 
164
- assert_equal "gzip", instance.client(nil, compressable).transport.options[:transport_options][:headers]["Content-Encoding"]
178
+ if elasticsearch_transport_layer_decoupling?
179
+ assert_equal "gzip", instance.client(nil, compressable).transport.transport.options[:transport_options][:headers]["Content-Encoding"]
180
+ else
181
+ assert_equal "gzip", instance.client(nil, compressable).transport.options[:transport_options][:headers]["Content-Encoding"]
182
+ end
165
183
  end
166
184
 
167
185
  test 'check compression option is passed to transport' do
@@ -172,16 +190,25 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
172
190
  }
173
191
  instance = driver(config).instance
174
192
 
175
- assert_equal false, instance.client.transport.options[:compression]
193
+ if elasticsearch_transport_layer_decoupling?
194
+ assert_equal false, instance.client.transport.transport.options[:compression]
195
+ else
196
+ assert_equal false, instance.client.transport.options[:compression]
197
+ end
176
198
 
177
199
  stub_request(:post, "http://localhost:9200/_bulk").
178
200
  to_return(status: 200, body: "", headers: {})
201
+ stub_elastic_info
179
202
  driver.run(default_tag: 'test') do
180
203
  driver.feed(sample_record)
181
204
  end
182
205
  compressable = instance.compressable_connection
183
206
 
184
- assert_equal true, instance.client(nil, compressable).transport.options[:compression]
207
+ if elasticsearch_transport_layer_decoupling?
208
+ assert_equal true, instance.client(nil, compressable).transport.transport.options[:compression]
209
+ else
210
+ assert_equal true, instance.client(nil, compressable).transport.options[:compression]
211
+ end
185
212
  end
186
213
 
187
214
  test 'configure Content-Type' do
@@ -348,6 +375,8 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
348
375
  elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
349
376
  with(headers: { "Content-Type" => "application/json" })
350
377
  end
378
+ stub_elastic_info('http://localhost:9200')
379
+
351
380
  driver.run(default_tag: 'test') do
352
381
  driver.feed(sample_record)
353
382
  end
@@ -356,6 +385,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
356
385
 
357
386
  def test_writes_to_default_index
358
387
  stub_elastic
388
+ stub_elastic_info
359
389
  driver.run(default_tag: 'test') do
360
390
  driver.feed(sample_record)
361
391
  end
@@ -395,6 +425,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
395
425
 
396
426
  elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
397
427
  to_return(:status => 200, :headers => {'Content-Type' => 'Application/json'}, :body => compressed_body)
428
+ stub_elastic_info
398
429
 
399
430
  driver(config)
400
431
  driver.run(default_tag: 'test') do
@@ -406,6 +437,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
406
437
 
407
438
  def test_writes_to_default_type
408
439
  stub_elastic
440
+ stub_elastic_info
409
441
  driver.run(default_tag: 'test') do
410
442
  driver.feed(sample_record)
411
443
  end
@@ -415,6 +447,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
415
447
  def test_writes_to_specified_index
416
448
  driver.configure("index_name myindex\n")
417
449
  stub_elastic
450
+ stub_elastic_info
418
451
  driver.run(default_tag: 'test') do
419
452
  driver.feed(sample_record)
420
453
  end
@@ -424,6 +457,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
424
457
  def test_writes_to_specified_index_uppercase
425
458
  driver.configure("index_name MyIndex\n")
426
459
  stub_elastic
460
+ stub_elastic_info
427
461
  driver.run(default_tag: 'test') do
428
462
  driver.feed(sample_record)
429
463
  end
@@ -433,6 +467,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
433
467
  def test_writes_to_specified_type
434
468
  driver.configure("type_name mytype\n")
435
469
  stub_elastic
470
+ stub_elastic_info
436
471
  driver.run(default_tag: 'test') do
437
472
  driver.feed(sample_record)
438
473
  end
@@ -442,6 +477,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
442
477
  def test_writes_to_specified_host
443
478
  driver.configure("host 192.168.33.50\n")
444
479
  elastic_request = stub_elastic("http://192.168.33.50:9200/_bulk")
480
+ stub_elastic_info("http://192.168.33.50:9200/")
445
481
  driver.run(default_tag: 'test') do
446
482
  driver.feed(sample_record)
447
483
  end
@@ -451,6 +487,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
451
487
  def test_writes_to_specified_port
452
488
  driver.configure("port 9201\n")
453
489
  elastic_request = stub_elastic("http://localhost:9201/_bulk")
490
+ stub_elastic_info("http://localhost:9201/")
454
491
  driver.run(default_tag: 'test') do
455
492
  driver.feed(sample_record)
456
493
  end
@@ -466,6 +503,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
466
503
  hosts.each do |host_info|
467
504
  host, port = host_info
468
505
  stub_elastic_with_store_index_command_counts("http://#{host}:#{port}/_bulk")
506
+ stub_elastic_info("http://#{host}:#{port}/")
469
507
  end
470
508
 
471
509
  driver.run(default_tag: 'test') do
@@ -501,6 +539,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
501
539
  ]}
502
540
 
503
541
  stub_elastic
542
+ stub_elastic_info
504
543
  driver.run(default_tag: 'test') do
505
544
  driver.feed(original_hash)
506
545
  end
@@ -514,6 +553,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
514
553
  expected_output = {"foo" => {"bar" => "baz"}}
515
554
 
516
555
  stub_elastic
556
+ stub_elastic_info
517
557
  driver.run(default_tag: 'test') do
518
558
  driver.feed(original_hash)
519
559
  end
@@ -522,6 +562,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
522
562
 
523
563
  def test_makes_bulk_request
524
564
  stub_elastic
565
+ stub_elastic_info
525
566
  driver.run(default_tag: 'test') do
526
567
  driver.feed(sample_record)
527
568
  driver.feed(sample_record.merge('age' => 27))
@@ -531,6 +572,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
531
572
 
532
573
  def test_all_records_are_preserved_in_bulk
533
574
  stub_elastic
575
+ stub_elastic_info
534
576
  driver.run(default_tag: 'test') do
535
577
  driver.feed(sample_record)
536
578
  driver.feed(sample_record.merge('age' => 27))
@@ -544,6 +586,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
544
586
  time = Time.parse Date.today.iso8601
545
587
  logstash_index = "logstash-#{time.getutc.strftime("%Y.%m.%d")}"
546
588
  stub_elastic
589
+ stub_elastic_info
547
590
  driver.run(default_tag: 'test') do
548
591
  driver.feed(time.to_i, sample_record)
549
592
  end
@@ -556,6 +599,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
556
599
  time = Time.parse Date.today.iso8601
557
600
  utc_index = "logstash-#{time.strftime("%Y.%m.%d")}"
558
601
  stub_elastic
602
+ stub_elastic_info
559
603
  driver.run(default_tag: 'test') do
560
604
  driver.feed(time.to_i, sample_record)
561
605
  end
@@ -568,6 +612,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
568
612
  time = Time.parse Date.today.iso8601
569
613
  logstash_index = "myprefix-#{time.getutc.strftime("%Y.%m.%d")}"
570
614
  stub_elastic
615
+ stub_elastic_info
571
616
  driver.run(default_tag: 'test') do
572
617
  driver.feed(time.to_i, sample_record)
573
618
  end
@@ -582,6 +627,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
582
627
  time = Time.parse Date.today.iso8601
583
628
  logstash_index = "myprefix#{separator}#{time.getutc.strftime("%Y.%m.%d")}"
584
629
  stub_elastic
630
+ stub_elastic_info
585
631
  driver.run(default_tag: 'test') do
586
632
  driver.feed(time.to_i, sample_record)
587
633
  end
@@ -594,18 +640,20 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
594
640
  time = Time.parse Date.today.iso8601
595
641
  logstash_index = "myprefix-#{time.getutc.strftime("%Y.%m.%d")}"
596
642
  stub_elastic
643
+ stub_elastic_info
597
644
  driver.run(default_tag: 'test') do
598
645
  driver.feed(time.to_i, sample_record)
599
646
  end
600
647
  assert_equal(logstash_index, index_cmds.first['index']['_index'])
601
648
  end
602
649
 
603
- def test_writes_to_logstash_index_with_specified_dateformat
650
+ def test_writes_to_logstash_index_with_specified_dateformat
604
651
  driver.configure("logstash_format true
605
652
  logstash_dateformat %Y.%m")
606
653
  time = Time.parse Date.today.iso8601
607
654
  logstash_index = "logstash-#{time.getutc.strftime("%Y.%m")}"
608
655
  stub_elastic
656
+ stub_elastic_info
609
657
  driver.run(default_tag: 'test') do
610
658
  driver.feed(time.to_i, sample_record)
611
659
  end
@@ -619,6 +667,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
619
667
  time = Time.parse Date.today.iso8601
620
668
  logstash_index = "myprefix-#{time.getutc.strftime("%Y.%m")}"
621
669
  stub_elastic
670
+ stub_elastic_info
622
671
  driver.run(default_tag: 'test') do
623
672
  driver.feed(time.to_i, sample_record)
624
673
  end
@@ -627,6 +676,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
627
676
 
628
677
  def test_doesnt_add_logstash_timestamp_by_default
629
678
  stub_elastic
679
+ stub_elastic_info
630
680
  driver.run(default_tag: 'test') do
631
681
  driver.feed(sample_record)
632
682
  end
@@ -636,6 +686,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
636
686
  def test_adds_logstash_timestamp_when_configured
637
687
  driver.configure("logstash_format true\n")
638
688
  stub_elastic
689
+ stub_elastic_info
639
690
  time = Fluent::EventTime.new(Time.now.to_i, 123456789)
640
691
  driver.run(default_tag: 'test') do
641
692
  driver.feed(time, sample_record)
@@ -648,6 +699,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
648
699
  driver.configure("logstash_format true
649
700
  time_precision 3\n")
650
701
  stub_elastic
702
+ stub_elastic_info
651
703
  time = Fluent::EventTime.new(Time.now.to_i, 123456789)
652
704
  driver.run(default_tag: 'test') do
653
705
  driver.feed(time, sample_record)
@@ -659,6 +711,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
659
711
  def test_uses_custom_timestamp_when_included_in_record
660
712
  driver.configure("include_timestamp true\n")
661
713
  stub_elastic
714
+ stub_elastic_info
662
715
  ts = DateTime.new(2001,2,3).iso8601
663
716
  driver.run(default_tag: 'test') do
664
717
  driver.feed(sample_record.merge!('@timestamp' => ts))
@@ -670,6 +723,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
670
723
  def test_uses_custom_timestamp_when_included_in_record_logstash
671
724
  driver.configure("logstash_format true\n")
672
725
  stub_elastic
726
+ stub_elastic_info
673
727
  ts = DateTime.new(2001,2,3).iso8601
674
728
  driver.run(default_tag: 'test') do
675
729
  driver.feed(sample_record.merge!('@timestamp' => ts))
@@ -682,6 +736,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
682
736
  driver.configure("logstash_format true
683
737
  time_key vtm\n")
684
738
  stub_elastic
739
+ stub_elastic_info
685
740
  ts = DateTime.new(2001,2,3).iso8601
686
741
  driver.run(default_tag: 'test') do
687
742
  driver.feed(sample_record.merge!('vtm' => ts))
@@ -694,6 +749,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
694
749
  driver.configure("include_timestamp true
695
750
  time_key vtm\n")
696
751
  stub_elastic
752
+ stub_elastic_info
697
753
  ts = DateTime.new(2001,2,3).iso8601
698
754
  driver.run(default_tag: 'test') do
699
755
  driver.feed(sample_record.merge!('vtm' => ts))
@@ -707,6 +763,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
707
763
  index_name test
708
764
  time_key vtm\n")
709
765
  stub_elastic
766
+ stub_elastic_info
710
767
  ts = DateTime.new(2001,2,3).iso8601
711
768
  driver.run(default_tag: 'test') do
712
769
  driver.feed(sample_record.merge!('vtm' => ts))
@@ -721,6 +778,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
721
778
  time_key vtm
722
779
  time_key_exclude_timestamp true\n")
723
780
  stub_elastic
781
+ stub_elastic_info
724
782
  ts = DateTime.new(2001,2,3).iso8601
725
783
  driver.run(default_tag: 'test') do
726
784
  driver.feed(sample_record.merge!('vtm' => ts))
@@ -733,6 +791,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
733
791
  time_key vtm
734
792
  time_key_exclude_timestamp true\n")
735
793
  stub_elastic
794
+ stub_elastic_info
736
795
  ts = DateTime.new(2001,2,3).iso8601
737
796
  driver.run(default_tag: 'test') do
738
797
  driver.feed(sample_record.merge!('vtm' => ts))
@@ -742,6 +801,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
742
801
 
743
802
  def test_doesnt_add_tag_key_by_default
744
803
  stub_elastic
804
+ stub_elastic_info
745
805
  driver.run(default_tag: 'test') do
746
806
  driver.feed(sample_record)
747
807
  end
@@ -751,6 +811,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
751
811
  def test_adds_tag_key_when_configured
752
812
  driver.configure("include_tag_key true\n")
753
813
  stub_elastic
814
+ stub_elastic_info
754
815
  driver.run(default_tag: 'mytag') do
755
816
  driver.feed(sample_record)
756
817
  end
@@ -761,6 +822,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
761
822
  def test_adds_id_key_when_configured
762
823
  driver.configure("id_key request_id\n")
763
824
  stub_elastic
825
+ stub_elastic_info
764
826
  driver.run(default_tag: 'test') do
765
827
  driver.feed(sample_record)
766
828
  end
@@ -771,6 +833,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
771
833
  def test_adds_nested_id_key_with_dot
772
834
  driver.configure("id_key nested.request_id\n")
773
835
  stub_elastic
836
+ stub_elastic_info
774
837
  driver.run(default_tag: 'test') do
775
838
  driver.feed(nested_sample_record)
776
839
  end
@@ -780,6 +843,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
780
843
  def test_adds_nested_id_key_with_dollar_dot
781
844
  driver.configure("id_key $.nested.request_id\n")
782
845
  stub_elastic
846
+ stub_elastic_info
783
847
  driver.run(default_tag: 'test') do
784
848
  driver.feed(nested_sample_record)
785
849
  end
@@ -789,6 +853,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
789
853
  def test_adds_nested_id_key_with_bracket
790
854
  driver.configure("id_key $['nested']['request_id']\n")
791
855
  stub_elastic
856
+ stub_elastic_info
792
857
  driver.run(default_tag: 'test') do
793
858
  driver.feed(nested_sample_record)
794
859
  end
@@ -799,6 +864,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
799
864
  def test_doesnt_add_id_key_if_missing_when_configured
800
865
  driver.configure("id_key another_request_id\n")
801
866
  stub_elastic
867
+ stub_elastic_info
802
868
  driver.run(default_tag: 'test') do
803
869
  driver.feed(sample_record)
804
870
  end
@@ -807,6 +873,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
807
873
 
808
874
  def test_adds_id_key_when_not_configured
809
875
  stub_elastic
876
+ stub_elastic_info
810
877
  driver.run(default_tag: 'test') do
811
878
  driver.feed(sample_record)
812
879
  end
@@ -816,6 +883,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
816
883
  def test_adds_parent_key_when_configured
817
884
  driver.configure("parent_key parent_id\n")
818
885
  stub_elastic
886
+ stub_elastic_info
819
887
  driver.run(default_tag: 'test') do
820
888
  driver.feed(sample_record)
821
889
  end
@@ -826,6 +894,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
826
894
  def test_adds_nested_parent_key_with_dot
827
895
  driver.configure("parent_key nested.parent_id\n")
828
896
  stub_elastic
897
+ stub_elastic_info
829
898
  driver.run(default_tag: 'test') do
830
899
  driver.feed(nested_sample_record)
831
900
  end
@@ -835,6 +904,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
835
904
  def test_adds_nested_parent_key_with_dollar_dot
836
905
  driver.configure("parent_key $.nested.parent_id\n")
837
906
  stub_elastic
907
+ stub_elastic_info
838
908
  driver.run(default_tag: 'test') do
839
909
  driver.feed(nested_sample_record)
840
910
  end
@@ -844,6 +914,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
844
914
  def test_adds_nested_parent_key_with_bracket
845
915
  driver.configure("parent_key $['nested']['parent_id']\n")
846
916
  stub_elastic
917
+ stub_elastic_info
847
918
  driver.run(default_tag: 'test') do
848
919
  driver.feed(nested_sample_record)
849
920
  end
@@ -854,6 +925,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
854
925
  def test_doesnt_add_parent_key_if_missing_when_configured
855
926
  driver.configure("parent_key another_parent_id\n")
856
927
  stub_elastic
928
+ stub_elastic_info
857
929
  driver.run(default_tag: 'test') do
858
930
  driver.feed(sample_record)
859
931
  end
@@ -862,6 +934,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
862
934
 
863
935
  def test_adds_parent_key_when_not_configured
864
936
  stub_elastic
937
+ stub_elastic_info
865
938
  driver.run(default_tag: 'test') do
866
939
  driver.feed(sample_record)
867
940
  end
@@ -872,6 +945,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
872
945
  def test_es6
873
946
  driver("routing_key routing_id\n", 6)
874
947
  stub_elastic
948
+ stub_elastic_info
875
949
  driver.run(default_tag: 'test') do
876
950
  driver.feed(sample_record)
877
951
  end
@@ -881,6 +955,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
881
955
  def test_es7
882
956
  driver("routing_key routing_id\n", 7)
883
957
  stub_elastic
958
+ stub_elastic_info
884
959
  driver.run(default_tag: 'test') do
885
960
  driver.feed(sample_record)
886
961
  end
@@ -892,6 +967,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
892
967
  def test_adds_nested_routing_key_with_dot
893
968
  driver.configure("routing_key nested.routing_id\n")
894
969
  stub_elastic
970
+ stub_elastic_info
895
971
  driver.run(default_tag: 'test') do
896
972
  driver.feed(nested_sample_record)
897
973
  end
@@ -901,6 +977,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
901
977
  def test_adds_nested_routing_key_with_dollar_dot
902
978
  driver.configure("routing_key $.nested.routing_id\n")
903
979
  stub_elastic
980
+ stub_elastic_info
904
981
  driver.run(default_tag: 'test') do
905
982
  driver.feed(nested_sample_record)
906
983
  end
@@ -910,6 +987,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
910
987
  def test_adds_nested_routing_key_with_bracket
911
988
  driver.configure("routing_key $['nested']['routing_id']\n")
912
989
  stub_elastic
990
+ stub_elastic_info
913
991
  driver.run(default_tag: 'test') do
914
992
  driver.feed(nested_sample_record)
915
993
  end
@@ -920,6 +998,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
920
998
  def test_doesnt_add_routing_key_if_missing_when_configured
921
999
  driver.configure("routing_key another_routing_id\n")
922
1000
  stub_elastic
1001
+ stub_elastic_info
923
1002
  driver.run(default_tag: 'test') do
924
1003
  driver.feed(sample_record)
925
1004
  end
@@ -928,6 +1007,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
928
1007
 
929
1008
  def test_adds_routing_key_when_not_configured
930
1009
  stub_elastic
1010
+ stub_elastic_info
931
1011
  driver.run(default_tag: 'test') do
932
1012
  driver.feed(sample_record)
933
1013
  end
@@ -937,6 +1017,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
937
1017
  def test_remove_one_key
938
1018
  driver.configure("remove_keys key1\n")
939
1019
  stub_elastic
1020
+ stub_elastic_info
940
1021
  driver.run(default_tag: 'test') do
941
1022
  driver.feed(sample_record.merge('key1' => 'v1', 'key2' => 'v2'))
942
1023
  end
@@ -947,6 +1028,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
947
1028
  def test_remove_multi_keys
948
1029
  driver.configure("remove_keys key1, key2\n")
949
1030
  stub_elastic
1031
+ stub_elastic_info
950
1032
  driver.run(default_tag: 'test') do
951
1033
  driver.feed(sample_record.merge('key1' => 'v1', 'key2' => 'v2'))
952
1034
  end
@@ -956,6 +1038,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
956
1038
 
957
1039
  def test_request_error
958
1040
  stub_elastic_unavailable
1041
+ stub_elastic_info
959
1042
  assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) {
960
1043
  driver.run(default_tag: 'test', shutdown: false) do
961
1044
  driver.feed(sample_record)
@@ -967,6 +1050,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
967
1050
  omit("retry_forever test is unstable.") if ENV["CI"]
968
1051
 
969
1052
  stub_elastic
1053
+ stub_elastic_info
970
1054
  driver.configure(Fluent::Config::Element.new(
971
1055
  'ROOT', '', {
972
1056
  '@type' => 'elasticsearch',
@@ -986,6 +1070,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
986
1070
 
987
1071
  def test_tag_parts_index_error_event
988
1072
  stub_elastic
1073
+ stub_elastic_info
989
1074
  driver.configure("logstash_prefix ${tag_parts[1]}\n")
990
1075
  flexmock(driver.instance.router).should_receive(:emit_error_event)
991
1076
  .with('test', Fluent::EventTime, Hash, TypeError).once
@@ -1001,6 +1086,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
1001
1086
  connection_resets += 1
1002
1087
  raise Faraday::ConnectionFailed, "Test message"
1003
1088
  end
1089
+ stub_elastic_info
1004
1090
 
1005
1091
  assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) {
1006
1092
  driver.run(default_tag: 'test', shutdown: false) do
@@ -1017,6 +1103,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
1017
1103
  connection_resets += 1
1018
1104
  raise ZeroDivisionError, "any not host_unreachable_exceptions exception"
1019
1105
  end
1106
+ stub_elastic_info
1020
1107
 
1021
1108
  driver.configure("reconnect_on_error true\n")
1022
1109
 
@@ -1043,6 +1130,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
1043
1130
  connection_resets += 1
1044
1131
  raise ZeroDivisionError, "any not host_unreachable_exceptions exception"
1045
1132
  end
1133
+ stub_elastic_info
1046
1134
 
1047
1135
  driver.configure("reconnect_on_error false\n")
1048
1136
 
@@ -1063,6 +1151,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
1063
1151
  def test_update_should_not_write_if_theres_no_id
1064
1152
  driver.configure("write_operation update\n")
1065
1153
  stub_elastic
1154
+ stub_elastic_info
1066
1155
  driver.run(default_tag: 'test') do
1067
1156
  driver.feed(sample_record)
1068
1157
  end
@@ -1072,6 +1161,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
1072
1161
  def test_upsert_should_not_write_if_theres_no_id
1073
1162
  driver.configure("write_operation upsert\n")
1074
1163
  stub_elastic
1164
+ stub_elastic_info
1075
1165
  driver.run(default_tag: 'test') do
1076
1166
  driver.feed(sample_record)
1077
1167
  end
@@ -1081,6 +1171,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
1081
1171
  def test_create_should_not_write_if_theres_no_id
1082
1172
  driver.configure("write_operation create\n")
1083
1173
  stub_elastic
1174
+ stub_elastic_info
1084
1175
  driver.run(default_tag: 'test') do
1085
1176
  driver.feed(sample_record)
1086
1177
  end
@@ -1091,6 +1182,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
1091
1182
  driver.configure("write_operation update
1092
1183
  id_key request_id")
1093
1184
  stub_elastic
1185
+ stub_elastic_info
1094
1186
  driver.run(default_tag: 'test') do
1095
1187
  driver.feed(sample_record)
1096
1188
  end
@@ -1102,6 +1194,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
1102
1194
  driver.configure("write_operation upsert
1103
1195
  id_key request_id")
1104
1196
  stub_elastic
1197
+ stub_elastic_info
1105
1198
  driver.run(default_tag: 'test') do
1106
1199
  driver.feed(sample_record)
1107
1200
  end
@@ -1113,6 +1206,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
1113
1206
  driver.configure("write_operation create
1114
1207
  id_key request_id")
1115
1208
  stub_elastic
1209
+ stub_elastic_info
1116
1210
  driver.run(default_tag: 'test') do
1117
1211
  driver.feed(sample_record)
1118
1212
  end
@@ -1121,6 +1215,7 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
1121
1215
 
1122
1216
  def test_include_index_in_url
1123
1217
  stub_elastic('http://localhost:9200/logstash-2018.01.01/_bulk')
1218
+ stub_elastic_info('http://localhost:9200/')
1124
1219
 
1125
1220
  driver.configure("index_name logstash-2018.01.01
1126
1221
  include_index_in_url true")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.3
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - diogo
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-04-20 00:00:00.000000000 Z
13
+ date: 2021-10-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fluentd
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  - !ruby/object:Gem::Version
224
224
  version: '0'
225
225
  requirements: []
226
- rubygems_version: 3.2.3
226
+ rubygems_version: 3.2.22
227
227
  signing_key:
228
228
  specification_version: 4
229
229
  summary: Elasticsearch output plugin for Fluent event collector