fluent-plugin-elasticsearch 5.1.5 → 5.2.2
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/History.md +12 -0
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/elasticsearch_compat.rb +30 -0
- data/lib/fluent/plugin/elasticsearch_fallback_selector.rb +2 -2
- data/lib/fluent/plugin/elasticsearch_index_lifecycle_management.rb +18 -4
- data/lib/fluent/plugin/elasticsearch_index_template.rb +8 -4
- data/lib/fluent/plugin/elasticsearch_simple_sniffer.rb +2 -1
- data/lib/fluent/plugin/filter_elasticsearch_genid.rb +1 -1
- data/lib/fluent/plugin/in_elasticsearch.rb +2 -1
- data/lib/fluent/plugin/oj_serializer.rb +2 -1
- data/lib/fluent/plugin/out_elasticsearch.rb +9 -8
- data/lib/fluent/plugin/out_elasticsearch_data_stream.rb +30 -11
- data/lib/fluent/plugin/out_elasticsearch_dynamic.rb +3 -1
- data/test/plugin/test_elasticsearch_fallback_selector.rb +15 -7
- data/test/plugin/test_elasticsearch_index_lifecycle_management.rb +47 -17
- data/test/plugin/test_filter_elasticsearch_genid.rb +16 -16
- data/test/plugin/test_in_elasticsearch.rb +10 -2
- data/test/plugin/test_out_elasticsearch.rb +281 -122
- data/test/plugin/test_out_elasticsearch_data_stream.rb +122 -28
- data/test/plugin/test_out_elasticsearch_dynamic.rb +57 -20
- metadata +4 -3
@@ -19,7 +19,15 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
19
19
|
log.out.logs.slice!(0, log.out.logs.length)
|
20
20
|
end
|
21
21
|
|
22
|
-
def
|
22
|
+
def elasticsearch_version
|
23
|
+
if Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("7.14.0")
|
24
|
+
TRANSPORT_CLASS::VERSION.split(".")[0..1].join(".")
|
25
|
+
else
|
26
|
+
"7.17".freeze
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def driver(conf='', es_version=elasticsearch_version.to_i, client_version="\"#{elasticsearch_version}\"")
|
23
31
|
# For request stub to detect compatibility.
|
24
32
|
@es_version ||= es_version
|
25
33
|
@client_version ||= client_version
|
@@ -46,7 +54,11 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
46
54
|
end
|
47
55
|
|
48
56
|
def elasticsearch_transport_layer_decoupling?
|
49
|
-
Gem::Version.create(::
|
57
|
+
Gem::Version.create(::TRANSPORT_CLASS::VERSION) >= Gem::Version.new("7.14.0")
|
58
|
+
end
|
59
|
+
|
60
|
+
def elastic_transport_layer?
|
61
|
+
Gem::Version.create(::TRANSPORT_CLASS::VERSION) >= Gem::Version.new("8.0.0")
|
50
62
|
end
|
51
63
|
|
52
64
|
def default_type_name
|
@@ -63,9 +75,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
63
75
|
}
|
64
76
|
end
|
65
77
|
|
66
|
-
def stub_elastic_info(url="http://localhost:9200/", version=
|
78
|
+
def stub_elastic_info(url="http://localhost:9200/", version=elasticsearch_version)
|
67
79
|
body ="{\"version\":{\"number\":\"#{version}\", \"build_flavor\":\"default\"},\"tagline\" : \"You Know, for Search\"}"
|
68
|
-
stub_request(:get, url)
|
80
|
+
stub_request(:get, url)
|
81
|
+
.to_return({:status => 200, :body => body, :headers => { 'Content-Type' => 'json', 'X-elastic-product' => 'Elasticsearch' } })
|
69
82
|
end
|
70
83
|
|
71
84
|
def stub_elastic(url="http://localhost:9200/_bulk")
|
@@ -273,7 +286,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
273
286
|
end
|
274
287
|
|
275
288
|
test 'configure compression' do
|
276
|
-
omit "elastisearch-ruby v7.2.0 or later is needed." if Gem::Version.create(::
|
289
|
+
omit "elastisearch-ruby v7.2.0 or later is needed." if Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.2.0")
|
277
290
|
|
278
291
|
config = %{
|
279
292
|
compression_level best_compression
|
@@ -284,7 +297,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
284
297
|
end
|
285
298
|
|
286
299
|
test 'check compression strategy' do
|
287
|
-
omit "elastisearch-ruby v7.2.0 or later is needed." if Gem::Version.create(::
|
300
|
+
omit "elastisearch-ruby v7.2.0 or later is needed." if Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.2.0")
|
288
301
|
|
289
302
|
config = %{
|
290
303
|
compression_level best_speed
|
@@ -295,14 +308,16 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
295
308
|
end
|
296
309
|
|
297
310
|
test 'check content-encoding header with compression' do
|
298
|
-
omit "elastisearch-ruby v7.2.0 or later is needed." if Gem::Version.create(::
|
311
|
+
omit "elastisearch-ruby v7.2.0 or later is needed." if Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.2.0")
|
299
312
|
|
300
313
|
config = %{
|
301
314
|
compression_level best_compression
|
302
315
|
}
|
303
316
|
instance = driver(config).instance
|
304
317
|
|
305
|
-
if
|
318
|
+
if elastic_transport_layer?
|
319
|
+
assert_equal nil, instance.client.transport.options[:transport_options][:headers]["Content-Encoding"]
|
320
|
+
elsif elasticsearch_transport_layer_decoupling?
|
306
321
|
assert_equal nil, instance.client.transport.transport.options[:transport_options][:headers]["Content-Encoding"]
|
307
322
|
else
|
308
323
|
assert_equal nil, instance.client.transport.options[:transport_options][:headers]["Content-Encoding"]
|
@@ -316,7 +331,9 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
316
331
|
end
|
317
332
|
compressable = instance.compressable_connection
|
318
333
|
|
319
|
-
if
|
334
|
+
if elastic_transport_layer?
|
335
|
+
assert_equal "gzip", instance.client(nil, compressable).transport.options[:transport_options][:headers]["Content-Encoding"]
|
336
|
+
elsif elasticsearch_transport_layer_decoupling?
|
320
337
|
assert_equal "gzip", instance.client(nil, compressable).transport.transport.options[:transport_options][:headers]["Content-Encoding"]
|
321
338
|
else
|
322
339
|
assert_equal "gzip", instance.client(nil, compressable).transport.options[:transport_options][:headers]["Content-Encoding"]
|
@@ -324,14 +341,16 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
324
341
|
end
|
325
342
|
|
326
343
|
test 'check compression option is passed to transport' do
|
327
|
-
omit "elastisearch-ruby v7.2.0 or later is needed." if Gem::Version.create(::
|
344
|
+
omit "elastisearch-ruby v7.2.0 or later is needed." if Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.2.0")
|
328
345
|
|
329
346
|
config = %{
|
330
347
|
compression_level best_compression
|
331
348
|
}
|
332
349
|
instance = driver(config).instance
|
333
350
|
|
334
|
-
if
|
351
|
+
if elastic_transport_layer?
|
352
|
+
assert_equal false, instance.client.transport.options[:compression]
|
353
|
+
elsif elasticsearch_transport_layer_decoupling?
|
335
354
|
assert_equal false, instance.client.transport.transport.options[:compression]
|
336
355
|
else
|
337
356
|
assert_equal false, instance.client.transport.options[:compression]
|
@@ -345,7 +364,9 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
345
364
|
end
|
346
365
|
compressable = instance.compressable_connection
|
347
366
|
|
348
|
-
if
|
367
|
+
if elastic_transport_layer?
|
368
|
+
assert_equal true, instance.client(nil, compressable).transport.options[:compression]
|
369
|
+
elsif elasticsearch_transport_layer_decoupling?
|
349
370
|
assert_equal true, instance.client(nil, compressable).transport.transport.options[:compression]
|
350
371
|
else
|
351
372
|
assert_equal true, instance.client(nil, compressable).transport.options[:compression]
|
@@ -441,7 +462,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
441
462
|
end
|
442
463
|
|
443
464
|
test 'handle invalid client.info' do
|
444
|
-
stub_elastic_info_bad("https://logs.fluentd.com:24225/es//",
|
465
|
+
stub_elastic_info_bad("https://logs.fluentd.com:24225/es//", elasticsearch_version)
|
445
466
|
config = %{
|
446
467
|
host logs.fluentd.com
|
447
468
|
port 24225
|
@@ -453,7 +474,11 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
453
474
|
scheme https
|
454
475
|
@log_level info
|
455
476
|
}
|
456
|
-
if
|
477
|
+
if elastic_transport_layer?
|
478
|
+
assert_raise(NoMethodError) do
|
479
|
+
d = create_driver(config, 8, "\"8.0.0\"")
|
480
|
+
end
|
481
|
+
elsif elasticsearch_transport_layer_decoupling?
|
457
482
|
assert_raise(NoMethodError) do
|
458
483
|
d = create_driver(config, 7, "\"7.10.1\"")
|
459
484
|
end
|
@@ -481,21 +506,31 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
481
506
|
|
482
507
|
sub_test_case 'ILM default config' do
|
483
508
|
setup do
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
509
|
+
if Gem::Version.new(TRANSPORT_CLASS::VERSION) < Gem::Version.new("8.0.0")
|
510
|
+
begin
|
511
|
+
require "elasticsearch/xpack"
|
512
|
+
rescue LoadError
|
513
|
+
omit "ILM testcase needs elasticsearch-xpack gem."
|
514
|
+
end
|
515
|
+
end
|
516
|
+
end
|
517
|
+
|
518
|
+
def ilm_endpoint
|
519
|
+
if Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("8.0.0")
|
520
|
+
'_enrich'.freeze
|
521
|
+
else
|
522
|
+
'_ilm'.freeze
|
488
523
|
end
|
489
524
|
end
|
490
525
|
|
491
526
|
data("legacy_template" => [true, "_template"],
|
492
527
|
"new_template" => [false, "_index_template"])
|
493
528
|
test 'valid configuration of index lifecycle management' do |data|
|
494
|
-
if Gem::Version.create(::
|
529
|
+
if Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.4.0")
|
495
530
|
omit "elastisearch-ruby v7.4.0 or later is needed for ILM."
|
496
531
|
end
|
497
532
|
use_legacy_template_flag, endpoint = data
|
498
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
533
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
499
534
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
500
535
|
end
|
501
536
|
cwd = File.dirname(__FILE__)
|
@@ -519,9 +554,9 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
519
554
|
stub_request(:get, "http://localhost:9200/_xpack").
|
520
555
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}',
|
521
556
|
:headers => {"Content-Type"=> "application/json"})
|
522
|
-
stub_request(:get, "http://localhost:9200/
|
557
|
+
stub_request(:get, "http://localhost:9200/#{ilm_endpoint}/policy/logstash-policy").
|
523
558
|
to_return(status: 404, body: "", headers: {})
|
524
|
-
stub_request(:put, "http://localhost:9200/
|
559
|
+
stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/logstash-policy").
|
525
560
|
with(body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
526
561
|
to_return(status: 200, body: "", headers: {})
|
527
562
|
stub_elastic_info
|
@@ -534,11 +569,11 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
534
569
|
data("legacy_template" => [true, "_template"],
|
535
570
|
"new_template" => [false, "_index_template"])
|
536
571
|
test 'valid configuration of overwriting ilm_policy' do |data|
|
537
|
-
if Gem::Version.create(::
|
572
|
+
if Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.4.0")
|
538
573
|
omit "elastisearch-ruby v7.4.0 or later is needed for ILM."
|
539
574
|
end
|
540
575
|
use_legacy_template_flag, endpoint = data
|
541
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
576
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
542
577
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
543
578
|
end
|
544
579
|
cwd = File.dirname(__FILE__)
|
@@ -564,9 +599,9 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
564
599
|
stub_request(:get, "http://localhost:9200/_xpack").
|
565
600
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}',
|
566
601
|
:headers => {"Content-Type"=> "application/json"})
|
567
|
-
stub_request(:get, "http://localhost:9200/
|
602
|
+
stub_request(:get, "http://localhost:9200/#{ilm_endpoint}/policy/logstash-policy").
|
568
603
|
to_return(status: 200, body: "", headers: {})
|
569
|
-
stub_request(:put, "http://localhost:9200/
|
604
|
+
stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/logstash-policy").
|
570
605
|
with(body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"75gb\",\"max_age\":\"50d\"}}}}}}").
|
571
606
|
to_return(status: 200, body: "", headers: {})
|
572
607
|
stub_elastic_info
|
@@ -885,6 +920,67 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
885
920
|
end
|
886
921
|
end
|
887
922
|
|
923
|
+
class GetElasticsearchIncompatibleVersionTest < self
|
924
|
+
def create_driver(conf='', client_version="7.14")
|
925
|
+
# For request stub to detect compatibility.
|
926
|
+
@client_version ||= client_version
|
927
|
+
# Ensure original implementation existence.
|
928
|
+
Fluent::Plugin::ElasticsearchOutput.module_eval(<<-CODE)
|
929
|
+
def detect_es_major_version
|
930
|
+
begin
|
931
|
+
@_es_info ||= client.info
|
932
|
+
rescue ::Elasticsearch::UnsupportedProductError => e
|
933
|
+
raise Fluent::ConfigError, "Using Elasticsearch client #{@client_version} is not compatible for your Elasticsearch server. Please check your using elasticsearch gem version and Elasticsearch server."
|
934
|
+
end
|
935
|
+
begin
|
936
|
+
unless version = @_es_info.dig("version", "number")
|
937
|
+
version = @default_elasticsearch_version
|
938
|
+
end
|
939
|
+
rescue NoMethodError => e
|
940
|
+
log.warn "#{@_es_info} can not dig version information. Assuming Elasticsearch #{@default_elasticsearch_version}", error: e
|
941
|
+
version = @default_elasticsearch_version
|
942
|
+
end
|
943
|
+
version.to_i
|
944
|
+
end
|
945
|
+
CODE
|
946
|
+
Fluent::Plugin::ElasticsearchOutput.module_eval(<<-CODE)
|
947
|
+
def client_library_version
|
948
|
+
#{@client_version}
|
949
|
+
end
|
950
|
+
CODE
|
951
|
+
Fluent::Test::Driver::Output.new(Fluent::Plugin::ElasticsearchOutput).configure(conf)
|
952
|
+
end
|
953
|
+
|
954
|
+
def test_incompatible_es_version
|
955
|
+
if Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.14.0")
|
956
|
+
omit "This test is not effective before elasticsearch 7.14"
|
957
|
+
end
|
958
|
+
config = %{
|
959
|
+
host logs.google.com
|
960
|
+
port 778
|
961
|
+
scheme https
|
962
|
+
path /es/
|
963
|
+
user john
|
964
|
+
password doe
|
965
|
+
verify_es_version_at_startup true
|
966
|
+
max_retry_get_es_version 1
|
967
|
+
}
|
968
|
+
|
969
|
+
connection_resets = 0
|
970
|
+
stub_request(:get, "https://logs.google.com:778/es//").
|
971
|
+
with(basic_auth: ['john', 'doe']) do |req|
|
972
|
+
connection_resets += 1
|
973
|
+
raise ::Elasticsearch::UnsupportedProductError
|
974
|
+
end
|
975
|
+
|
976
|
+
assert_raise(Fluent::ConfigError) do
|
977
|
+
create_driver(config)
|
978
|
+
end
|
979
|
+
|
980
|
+
assert_equal(1, connection_resets)
|
981
|
+
end
|
982
|
+
end
|
983
|
+
|
888
984
|
class GetElasticsearchVersionWithFallbackTest < self
|
889
985
|
def create_driver(conf='', client_version="\"5.0\"")
|
890
986
|
# For request stub to detect compatibility.
|
@@ -946,7 +1042,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
946
1042
|
"new_template" => [false, "_index_template"])
|
947
1043
|
def test_template_already_present(data)
|
948
1044
|
use_legacy_template_flag, endpoint = data
|
949
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
1045
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
950
1046
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
951
1047
|
end
|
952
1048
|
config = %{
|
@@ -980,7 +1076,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
980
1076
|
"new_template" => [false, "_index_template"])
|
981
1077
|
def test_template_create(data)
|
982
1078
|
use_legacy_template_flag, endpoint = data
|
983
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
1079
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
984
1080
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
985
1081
|
end
|
986
1082
|
cwd = File.dirname(__FILE__)
|
@@ -1025,7 +1121,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1025
1121
|
"new_template" => [false, "_index_template"])
|
1026
1122
|
def test_template_create_with_rollover_index_and_template_related_placeholders(data)
|
1027
1123
|
use_legacy_template_flag, endpoint = data
|
1028
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
1124
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
1029
1125
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
1030
1126
|
end
|
1031
1127
|
cwd = File.dirname(__FILE__)
|
@@ -1094,7 +1190,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1094
1190
|
"new_template" => [false, "_index_template"])
|
1095
1191
|
def test_template_create_with_rollover_index_and_template_related_placeholders_with_truncating_caches(data)
|
1096
1192
|
use_legacy_template_flag, endpoint = data
|
1097
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
1193
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
1098
1194
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
1099
1195
|
end
|
1100
1196
|
cwd = File.dirname(__FILE__)
|
@@ -1168,21 +1264,31 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1168
1264
|
|
1169
1265
|
class TemplateIndexLifecycleManagementTest < self
|
1170
1266
|
def setup
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1267
|
+
if Gem::Version.new(Elasticsearch::VERSION) < Gem::Version.new("8.0.0")
|
1268
|
+
begin
|
1269
|
+
require "elasticsearch/xpack"
|
1270
|
+
rescue LoadError
|
1271
|
+
omit "ILM testcase needs elasticsearch-xpack gem."
|
1272
|
+
end
|
1175
1273
|
end
|
1176
|
-
if Gem::Version.create(::
|
1274
|
+
if Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.4.0")
|
1177
1275
|
omit "elastisearch-ruby v7.4.0 or later is needed for ILM."
|
1178
1276
|
end
|
1179
1277
|
end
|
1180
1278
|
|
1279
|
+
def ilm_endpoint
|
1280
|
+
if Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("8.0.0")
|
1281
|
+
'_enrich'.freeze
|
1282
|
+
else
|
1283
|
+
'_ilm'.freeze
|
1284
|
+
end
|
1285
|
+
end
|
1286
|
+
|
1181
1287
|
data("legacy_template" => [true, "_template"],
|
1182
1288
|
"new_template" => [false, "_index_template"])
|
1183
1289
|
def test_template_create_with_rollover_index_and_default_ilm(data)
|
1184
1290
|
use_legacy_template_flag, endpoint = data
|
1185
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
1291
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
1186
1292
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
1187
1293
|
end
|
1188
1294
|
cwd = File.dirname(__FILE__)
|
@@ -1248,10 +1354,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1248
1354
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
1249
1355
|
with(basic_auth: ['john', 'doe']).
|
1250
1356
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
1251
|
-
stub_request(:get, "https://logs.google.com:777/es
|
1357
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
1252
1358
|
with(basic_auth: ['john', 'doe']).
|
1253
1359
|
to_return(:status => 404, :body => "", :headers => {})
|
1254
|
-
stub_request(:put, "https://logs.google.com:777/es
|
1360
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
1255
1361
|
with(basic_auth: ['john', 'doe'],
|
1256
1362
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
1257
1363
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -1266,7 +1372,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1266
1372
|
"new_template" => [false, "_index_template"])
|
1267
1373
|
def test_template_create_with_rollover_index_and_default_ilm_on_logstash_format(data)
|
1268
1374
|
use_legacy_template_flag, endpoint = data
|
1269
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
1375
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
1270
1376
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
1271
1377
|
end
|
1272
1378
|
cwd = File.dirname(__FILE__)
|
@@ -1335,10 +1441,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1335
1441
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
1336
1442
|
with(basic_auth: ['john', 'doe']).
|
1337
1443
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
1338
|
-
stub_request(:get, "https://logs.google.com:777/es
|
1444
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
1339
1445
|
with(basic_auth: ['john', 'doe']).
|
1340
1446
|
to_return(:status => 404, :body => "", :headers => {})
|
1341
|
-
stub_request(:put, "https://logs.google.com:777/es
|
1447
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
1342
1448
|
with(basic_auth: ['john', 'doe'],
|
1343
1449
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
1344
1450
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -1359,7 +1465,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1359
1465
|
"new_template" => [false, "_index_template"])
|
1360
1466
|
def test_template_create_with_rollover_index_and_default_ilm_and_ilm_policy_overwrite(data)
|
1361
1467
|
use_legacy_template_flag, endpoint = data
|
1362
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
1468
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
1363
1469
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
1364
1470
|
end
|
1365
1471
|
cwd = File.dirname(__FILE__)
|
@@ -1427,10 +1533,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1427
1533
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
1428
1534
|
with(basic_auth: ['john', 'doe']).
|
1429
1535
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
1430
|
-
stub_request(:get, "https://logs.google.com:777/es
|
1536
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
1431
1537
|
with(basic_auth: ['john', 'doe']).
|
1432
1538
|
to_return(:status => 200, :body => "", :headers => {})
|
1433
|
-
stub_request(:put, "https://logs.google.com:777/es
|
1539
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
1434
1540
|
with(basic_auth: ['john', 'doe'],
|
1435
1541
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"60gb\",\"max_age\":\"45d\"}}}}}}").
|
1436
1542
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -1470,7 +1576,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1470
1576
|
"new_template" => [false, "_index_template"])
|
1471
1577
|
def test_template_create_with_rollover_index_and_default_ilm_with_empty_index_date_pattern(data)
|
1472
1578
|
use_legacy_template_flag, endpoint = data
|
1473
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
1579
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
1474
1580
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
1475
1581
|
end
|
1476
1582
|
cwd = File.dirname(__FILE__)
|
@@ -1536,10 +1642,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1536
1642
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
1537
1643
|
with(basic_auth: ['john', 'doe']).
|
1538
1644
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
1539
|
-
stub_request(:get, "https://logs.google.com:777/es
|
1645
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
1540
1646
|
with(basic_auth: ['john', 'doe']).
|
1541
1647
|
to_return(:status => 404, :body => "", :headers => {})
|
1542
|
-
stub_request(:put, "https://logs.google.com:777/es
|
1648
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
1543
1649
|
with(basic_auth: ['john', 'doe'],
|
1544
1650
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
1545
1651
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -1554,7 +1660,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1554
1660
|
"new_template" => [false, "_index_template"])
|
1555
1661
|
def test_template_create_with_rollover_index_and_custom_ilm(data)
|
1556
1662
|
use_legacy_template_flag, endpoint = data
|
1557
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
1663
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
1558
1664
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
1559
1665
|
end
|
1560
1666
|
cwd = File.dirname(__FILE__)
|
@@ -1621,10 +1727,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1621
1727
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
1622
1728
|
with(basic_auth: ['john', 'doe']).
|
1623
1729
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
1624
|
-
stub_request(:get, "https://logs.google.com:777/es
|
1730
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
1625
1731
|
with(basic_auth: ['john', 'doe']).
|
1626
1732
|
to_return(:status => 404, :body => "", :headers => {})
|
1627
|
-
stub_request(:put, "https://logs.google.com:777/es
|
1733
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
1628
1734
|
with(basic_auth: ['john', 'doe'],
|
1629
1735
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
|
1630
1736
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -1639,7 +1745,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1639
1745
|
"new_template" => [false, "_index_template"])
|
1640
1746
|
def test_template_create_with_rollover_index_and_ilm_policies_and_placeholderstest_template_create_with_rollover_index_and_ilm_policies_and_placeholders(data)
|
1641
1747
|
use_legacy_template_flag, endpoint = data
|
1642
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
1748
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
1643
1749
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
1644
1750
|
end
|
1645
1751
|
cwd = File.dirname(__FILE__)
|
@@ -1706,10 +1812,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1706
1812
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
1707
1813
|
with(basic_auth: ['john', 'doe']).
|
1708
1814
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
1709
|
-
stub_request(:get, "https://logs.google.com:777/es
|
1815
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
1710
1816
|
with(basic_auth: ['john', 'doe']).
|
1711
1817
|
to_return(:status => 404, :body => "", :headers => {})
|
1712
|
-
stub_request(:put, "https://logs.google.com:777/es
|
1818
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
1713
1819
|
with(basic_auth: ['john', 'doe'],
|
1714
1820
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
|
1715
1821
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -1731,7 +1837,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1731
1837
|
"new_template" => [false, "_index_template"])
|
1732
1838
|
def test_tag_placeholder(data)
|
1733
1839
|
use_legacy_template_flag, endpoint = data
|
1734
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
1840
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
1735
1841
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
1736
1842
|
end
|
1737
1843
|
cwd = File.dirname(__FILE__)
|
@@ -1798,10 +1904,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1798
1904
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
1799
1905
|
with(basic_auth: ['john', 'doe']).
|
1800
1906
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
1801
|
-
stub_request(:get, "https://logs.google.com:777/es
|
1907
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
1802
1908
|
with(basic_auth: ['john', 'doe']).
|
1803
1909
|
to_return(:status => 404, :body => "", :headers => {})
|
1804
|
-
stub_request(:put, "https://logs.google.com:777/es
|
1910
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
1805
1911
|
with(basic_auth: ['john', 'doe'],
|
1806
1912
|
body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
|
1807
1913
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -1822,7 +1928,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1822
1928
|
"new_template" => [false, "_index_template"])
|
1823
1929
|
def test_tag_placeholder_with_multiple_policies(data)
|
1824
1930
|
use_legacy_template_flag, endpoint = data
|
1825
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
1931
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
1826
1932
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
1827
1933
|
end
|
1828
1934
|
cwd = File.dirname(__FILE__)
|
@@ -1889,10 +1995,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1889
1995
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
1890
1996
|
with(basic_auth: ['john', 'doe']).
|
1891
1997
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
1892
|
-
stub_request(:get, "https://logs.google.com:777/es
|
1998
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy2").
|
1893
1999
|
with(basic_auth: ['john', 'doe']).
|
1894
2000
|
to_return(:status => 404, :body => "", :headers => {})
|
1895
|
-
stub_request(:put, "https://logs.google.com:777/es
|
2001
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy2").
|
1896
2002
|
with(basic_auth: ['john', 'doe'],
|
1897
2003
|
body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"80gb\",\"max_age\":\"20d\"}}}}}}").
|
1898
2004
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -1914,7 +2020,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1914
2020
|
"new_template" => [false, "_index_template"])
|
1915
2021
|
def test_template_create_with_rollover_index_and_default_ilm_and_placeholders(data)
|
1916
2022
|
use_legacy_template_flag, endpoint = data
|
1917
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
2023
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
1918
2024
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
1919
2025
|
end
|
1920
2026
|
cwd = File.dirname(__FILE__)
|
@@ -1980,10 +2086,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1980
2086
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
1981
2087
|
with(basic_auth: ['john', 'doe']).
|
1982
2088
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
1983
|
-
stub_request(:get, "https://logs.google.com:777/es
|
2089
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
1984
2090
|
with(basic_auth: ['john', 'doe']).
|
1985
2091
|
to_return(:status => 404, :body => "", :headers => {})
|
1986
|
-
stub_request(:put, "https://logs.google.com:777/es
|
2092
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
1987
2093
|
with(basic_auth: ['john', 'doe'],
|
1988
2094
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
1989
2095
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -2015,10 +2121,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2015
2121
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
2016
2122
|
with(basic_auth: ['john', 'doe']).
|
2017
2123
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
2018
|
-
stub_request(:get, "https://logs.google.com:777/es
|
2124
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
2019
2125
|
with(basic_auth: ['john', 'doe']).
|
2020
2126
|
to_return(:status => 404, :body => "", :headers => {})
|
2021
|
-
stub_request(:put, "https://logs.google.com:777/es
|
2127
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
2022
2128
|
with(basic_auth: ['john', 'doe'],
|
2023
2129
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
2024
2130
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -2045,7 +2151,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2045
2151
|
"new_template" => [false, "_index_template"])
|
2046
2152
|
def test_template_create_with_rollover_index_and_default_ilm_and_placeholders_and_index_separator(data)
|
2047
2153
|
use_legacy_template_flag, endpoint = data
|
2048
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
2154
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
2049
2155
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
2050
2156
|
end
|
2051
2157
|
cwd = File.dirname(__FILE__)
|
@@ -2112,10 +2218,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2112
2218
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
2113
2219
|
with(basic_auth: ['john', 'doe']).
|
2114
2220
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
2115
|
-
stub_request(:get, "https://logs.google.com:777/es
|
2221
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
2116
2222
|
with(basic_auth: ['john', 'doe']).
|
2117
2223
|
to_return(:status => 404, :body => "", :headers => {})
|
2118
|
-
stub_request(:put, "https://logs.google.com:777/es
|
2224
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
2119
2225
|
with(basic_auth: ['john', 'doe'],
|
2120
2226
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
2121
2227
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -2138,7 +2244,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2138
2244
|
"new_template" => [false, "_index_template"])
|
2139
2245
|
def test_template_create_with_rollover_index_and_default_ilm_and_custom_and_time_placeholders(data)
|
2140
2246
|
use_legacy_template_flag, endpoint = data
|
2141
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
2247
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
2142
2248
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
2143
2249
|
end
|
2144
2250
|
cwd = File.dirname(__FILE__)
|
@@ -2209,10 +2315,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2209
2315
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
2210
2316
|
with(basic_auth: ['john', 'doe']).
|
2211
2317
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
2212
|
-
stub_request(:get, "https://logs.google.com:777/es
|
2318
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
2213
2319
|
with(basic_auth: ['john', 'doe']).
|
2214
2320
|
to_return(:status => 404, :body => "", :headers => {})
|
2215
|
-
stub_request(:put, "https://logs.google.com:777/es
|
2321
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
|
2216
2322
|
with(basic_auth: ['john', 'doe'],
|
2217
2323
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
2218
2324
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -2237,7 +2343,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2237
2343
|
def test_custom_template_create(data)
|
2238
2344
|
use_legacy_template_flag, endpoint = data
|
2239
2345
|
|
2240
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
2346
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
2241
2347
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
2242
2348
|
end
|
2243
2349
|
cwd = File.dirname(__FILE__)
|
@@ -2283,7 +2389,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2283
2389
|
"new_template" => [false, "_index_template"])
|
2284
2390
|
def test_custom_template_create_with_customize_template_related_placeholders(data)
|
2285
2391
|
use_legacy_template_flag, endpoint = data
|
2286
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
2392
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
2287
2393
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
2288
2394
|
end
|
2289
2395
|
cwd = File.dirname(__FILE__)
|
@@ -2337,7 +2443,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2337
2443
|
"new_template" => [false, "_index_template"])
|
2338
2444
|
def test_custom_template_installation_for_host_placeholder(data)
|
2339
2445
|
use_legacy_template_flag, endpoint = data
|
2340
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
2446
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
2341
2447
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
2342
2448
|
end
|
2343
2449
|
cwd = File.dirname(__FILE__)
|
@@ -2387,7 +2493,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2387
2493
|
"new_template" => [false, "_index_template"])
|
2388
2494
|
def test_custom_template_with_rollover_index_create(data)
|
2389
2495
|
use_legacy_template_flag, endpoint = data
|
2390
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
2496
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
2391
2497
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
2392
2498
|
end
|
2393
2499
|
cwd = File.dirname(__FILE__)
|
@@ -2449,7 +2555,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2449
2555
|
"new_template" => [false, "_index_template"])
|
2450
2556
|
def test_custom_template_with_rollover_index_create_and_deflector_alias(data)
|
2451
2557
|
use_legacy_template_flag, endpoint = data
|
2452
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
2558
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
2453
2559
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
2454
2560
|
end
|
2455
2561
|
cwd = File.dirname(__FILE__)
|
@@ -2512,7 +2618,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2512
2618
|
"new_template" => [false, "_index_template"])
|
2513
2619
|
def test_custom_template_with_rollover_index_create_with_logstash_format(data)
|
2514
2620
|
use_legacy_template_flag, endpoint = data
|
2515
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
2621
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
2516
2622
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
2517
2623
|
end
|
2518
2624
|
cwd = File.dirname(__FILE__)
|
@@ -2579,21 +2685,32 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2579
2685
|
|
2580
2686
|
class CustomTemplateIndexLifecycleManagementTest < self
|
2581
2687
|
def setup
|
2582
|
-
|
2583
|
-
|
2584
|
-
|
2585
|
-
|
2688
|
+
if Gem::Version.new(TRANSPORT_CLASS::VERSION) < Gem::Version.new("8.0.0")
|
2689
|
+
begin
|
2690
|
+
require "elasticsearch/xpack"
|
2691
|
+
rescue LoadError
|
2692
|
+
omit "ILM testcase needs elasticsearch-xpack gem."
|
2693
|
+
end
|
2586
2694
|
end
|
2587
|
-
if Gem::Version.create(::
|
2695
|
+
if Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.4.0")
|
2588
2696
|
omit "elastisearch-ruby v7.4.0 or later is needed."
|
2589
2697
|
end
|
2590
2698
|
end
|
2591
2699
|
|
2700
|
+
|
2701
|
+
def ilm_endpoint
|
2702
|
+
if Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("8.0.0")
|
2703
|
+
'_enrich'.freeze
|
2704
|
+
else
|
2705
|
+
'_ilm'.freeze
|
2706
|
+
end
|
2707
|
+
end
|
2708
|
+
|
2592
2709
|
data("legacy_template" => [true, "_template"],
|
2593
2710
|
"new_template" => [false, "_index_template"])
|
2594
2711
|
def test_custom_template_with_rollover_index_create_and_default_ilm(data)
|
2595
2712
|
use_legacy_template_flag, endpoint = data
|
2596
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
2713
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
2597
2714
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
2598
2715
|
end
|
2599
2716
|
cwd = File.dirname(__FILE__)
|
@@ -2663,10 +2780,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2663
2780
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
2664
2781
|
with(basic_auth: ['john', 'doe']).
|
2665
2782
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
2666
|
-
stub_request(:get, "https://logs.google.com:777/es
|
2783
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
2667
2784
|
with(basic_auth: ['john', 'doe']).
|
2668
2785
|
to_return(:status => 404, :body => "", :headers => {})
|
2669
|
-
stub_request(:put, "https://logs.google.com:777/es
|
2786
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
2670
2787
|
with(basic_auth: ['john', 'doe'],
|
2671
2788
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
2672
2789
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -2680,7 +2797,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2680
2797
|
"new_template" => [false, "_index_template"])
|
2681
2798
|
def test_custom_template_with_rollover_index_create_and_default_ilm_and_ilm_policy_overwrite(data)
|
2682
2799
|
use_legacy_template_flag, endpoint = data
|
2683
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
2800
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
2684
2801
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
2685
2802
|
end
|
2686
2803
|
cwd = File.dirname(__FILE__)
|
@@ -2752,10 +2869,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2752
2869
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
2753
2870
|
with(basic_auth: ['john', 'doe']).
|
2754
2871
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
2755
|
-
stub_request(:get, "https://logs.google.com:777/es
|
2872
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
2756
2873
|
with(basic_auth: ['john', 'doe']).
|
2757
2874
|
to_return(:status => 200, :body => "", :headers => {})
|
2758
|
-
stub_request(:put, "https://logs.google.com:777/es
|
2875
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
2759
2876
|
with(basic_auth: ['john', 'doe'],
|
2760
2877
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"60gb\",\"max_age\":\"45d\"}}}}}}").
|
2761
2878
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -2799,7 +2916,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2799
2916
|
"new_template" => [false, "_index_template"])
|
2800
2917
|
def test_custom_template_with_rollover_index_create_and_default_ilm_and_placeholders(data)
|
2801
2918
|
use_legacy_template_flag, endpoint = data
|
2802
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
2919
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
2803
2920
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
2804
2921
|
end
|
2805
2922
|
cwd = File.dirname(__FILE__)
|
@@ -2871,10 +2988,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2871
2988
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
2872
2989
|
with(basic_auth: ['john', 'doe']).
|
2873
2990
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
2874
|
-
stub_request(:get, "https://logs.google.com:777/es
|
2991
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
2875
2992
|
with(basic_auth: ['john', 'doe']).
|
2876
2993
|
to_return(:status => 404, :body => "", :headers => {})
|
2877
|
-
stub_request(:put, "https://logs.google.com:777/es
|
2994
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
2878
2995
|
with(basic_auth: ['john', 'doe'],
|
2879
2996
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
2880
2997
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -2918,10 +3035,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2918
3035
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
2919
3036
|
with(basic_auth: ['john', 'doe']).
|
2920
3037
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
2921
|
-
stub_request(:get, "https://logs.google.com:777/es
|
3038
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
2922
3039
|
with(basic_auth: ['john', 'doe']).
|
2923
3040
|
to_return(:status => 404, :body => "", :headers => {})
|
2924
|
-
stub_request(:put, "https://logs.google.com:777/es
|
3041
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
2925
3042
|
with(basic_auth: ['john', 'doe'],
|
2926
3043
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
2927
3044
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -2946,7 +3063,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2946
3063
|
"new_template" => [false, "_index_template"])
|
2947
3064
|
def test_custom_template_with_rollover_index_create_and_custom_ilm(data)
|
2948
3065
|
use_legacy_template_flag, endpoint = data
|
2949
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
3066
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
2950
3067
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
2951
3068
|
end
|
2952
3069
|
cwd = File.dirname(__FILE__)
|
@@ -3009,10 +3126,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3009
3126
|
stub_request(:get, "https://logs.google.com:777/es//_xpack").
|
3010
3127
|
with(basic_auth: ['john', 'doe']).
|
3011
3128
|
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
3012
|
-
stub_request(:get, "https://logs.google.com:777/es
|
3129
|
+
stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
3013
3130
|
with(basic_auth: ['john', 'doe']).
|
3014
3131
|
to_return(:status => 404, :body => "", :headers => {})
|
3015
|
-
stub_request(:put, "https://logs.google.com:777/es
|
3132
|
+
stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
|
3016
3133
|
with(basic_auth: ['john', 'doe'],
|
3017
3134
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
|
3018
3135
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -3027,7 +3144,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3027
3144
|
"new_template" => [false, "_index_template"])
|
3028
3145
|
def test_template_overwrite(data)
|
3029
3146
|
use_legacy_template_flag, endpoint = data
|
3030
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
3147
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
3031
3148
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
3032
3149
|
end
|
3033
3150
|
cwd = File.dirname(__FILE__)
|
@@ -3073,7 +3190,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3073
3190
|
"new_template" => [false, "_index_template"])
|
3074
3191
|
def test_custom_template_overwrite(data)
|
3075
3192
|
use_legacy_template_flag, endpoint = data
|
3076
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
3193
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
3077
3194
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
3078
3195
|
end
|
3079
3196
|
cwd = File.dirname(__FILE__)
|
@@ -3120,7 +3237,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3120
3237
|
"new_template" => [false, "_index_template"])
|
3121
3238
|
def test_custom_template_with_rollover_index_overwrite(data)
|
3122
3239
|
use_legacy_template_flag, endpoint = data
|
3123
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
3240
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
3124
3241
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
3125
3242
|
end
|
3126
3243
|
cwd = File.dirname(__FILE__)
|
@@ -3210,7 +3327,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3210
3327
|
"new_template" => [false, "_index_template"])
|
3211
3328
|
def test_template_create_for_host_placeholder(data)
|
3212
3329
|
use_legacy_template_flag, endpoint = data
|
3213
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
3330
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
3214
3331
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
3215
3332
|
end
|
3216
3333
|
cwd = File.dirname(__FILE__)
|
@@ -3262,7 +3379,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3262
3379
|
"new_template" => [false, "_index_template"])
|
3263
3380
|
def test_template_retry_install_fails(data)
|
3264
3381
|
use_legacy_template_flag, endpoint = data
|
3265
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
3382
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
3266
3383
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
3267
3384
|
end
|
3268
3385
|
cwd = File.dirname(__FILE__)
|
@@ -3301,13 +3418,13 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3301
3418
|
assert_equal(4, connection_resets)
|
3302
3419
|
end
|
3303
3420
|
|
3304
|
-
transport_errors_handled_separately = [
|
3305
|
-
transport_errors =
|
3421
|
+
transport_errors_handled_separately = [TRANSPORT_CLASS::Transport::Errors::NotFound]
|
3422
|
+
transport_errors = TRANSPORT_CLASS::Transport::Errors.constants.map { |err| [err, TRANSPORT_CLASS::Transport::Errors.const_get(err)] }
|
3306
3423
|
transport_errors_hash = Hash[transport_errors.select { |err| !transport_errors_handled_separately.include?(err[1]) } ]
|
3307
3424
|
|
3308
3425
|
data(transport_errors_hash)
|
3309
3426
|
def test_template_retry_transport_errors(error)
|
3310
|
-
endpoint, use_legacy_template_flag = if Gem::Version.create(::
|
3427
|
+
endpoint, use_legacy_template_flag = if Gem::Version.create(::TRANSPORT_CLASS::VERSION) >= Gem::Version.create("7.8.0")
|
3311
3428
|
["_index_template".freeze, false]
|
3312
3429
|
else
|
3313
3430
|
["_template".freeze, true]
|
@@ -3347,7 +3464,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3347
3464
|
"new_template" => [false, "_index_template"])
|
3348
3465
|
def test_template_retry_install_does_not_fail(data)
|
3349
3466
|
use_legacy_template_flag, endpoint = data
|
3350
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
3467
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
3351
3468
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
3352
3469
|
end
|
3353
3470
|
cwd = File.dirname(__FILE__)
|
@@ -3389,7 +3506,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3389
3506
|
"new_template" => [false, "_index_template"])
|
3390
3507
|
def test_templates_create(data)
|
3391
3508
|
use_legacy_template_flag, endpoint = data
|
3392
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
3509
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
3393
3510
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
3394
3511
|
end
|
3395
3512
|
cwd = File.dirname(__FILE__)
|
@@ -3447,7 +3564,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3447
3564
|
"new_template" => [false, "_index_template"])
|
3448
3565
|
def test_templates_overwrite(data)
|
3449
3566
|
use_legacy_template_flag, endpoint = data
|
3450
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
3567
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
3451
3568
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
3452
3569
|
end
|
3453
3570
|
cwd = File.dirname(__FILE__)
|
@@ -3505,7 +3622,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3505
3622
|
"new_template" => [false, "_index_template"])
|
3506
3623
|
def test_templates_are_also_used(data)
|
3507
3624
|
use_legacy_template_flag, endpoint = data
|
3508
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
3625
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
3509
3626
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
3510
3627
|
end
|
3511
3628
|
cwd = File.dirname(__FILE__)
|
@@ -3565,7 +3682,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3565
3682
|
"new_template" => [false, "_index_template"])
|
3566
3683
|
def test_templates_can_be_partially_created_if_error_occurs(data)
|
3567
3684
|
use_legacy_template_flag, endpoint = data
|
3568
|
-
if !use_legacy_template_flag && Gem::Version.create(::
|
3685
|
+
if !use_legacy_template_flag && Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.8.0")
|
3569
3686
|
omit "elastisearch-ruby v7.8.0 or later is needed."
|
3570
3687
|
end
|
3571
3688
|
cwd = File.dirname(__FILE__)
|
@@ -3946,7 +4063,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3946
4063
|
|
3947
4064
|
|
3948
4065
|
def test_writes_to_default_index_with_compression
|
3949
|
-
omit "elastisearch-ruby v7.2.0 or later is needed." if Gem::Version.create(::
|
4066
|
+
omit "elastisearch-ruby v7.2.0 or later is needed." if Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.2.0")
|
3950
4067
|
|
3951
4068
|
config = %[
|
3952
4069
|
compression_level default_compression
|
@@ -4037,9 +4154,16 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4037
4154
|
}, [])
|
4038
4155
|
]
|
4039
4156
|
))
|
4157
|
+
index_part = if Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("8.0.0")
|
4158
|
+
'{"index":{"_index":"fluentd"}}'
|
4159
|
+
elsif Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("7.0.0")
|
4160
|
+
'{"index":{"_index":"fluentd","_type":"_doc"}}'
|
4161
|
+
else
|
4162
|
+
'{"index":{"_index":"fluentd","_type":"fluentd"}}'
|
4163
|
+
end
|
4040
4164
|
stub_request(:post, "http://localhost:9200/_bulk").
|
4041
4165
|
with(
|
4042
|
-
body:
|
4166
|
+
body: /#{index_part}\n{"age":26,"request_id":"42","parent_id":"parent","routing_id":"routing","#{chunk_id_key}":".*"}\n/) do |req|
|
4043
4167
|
@index_cmds = req.body.split("\n").map {|r| JSON.parse(r) }
|
4044
4168
|
end
|
4045
4169
|
stub_elastic_info
|
@@ -4524,7 +4648,13 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4524
4648
|
driver.run(default_tag: 'test') do
|
4525
4649
|
driver.feed(sample_record)
|
4526
4650
|
end
|
4527
|
-
|
4651
|
+
if Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("8.0.0")
|
4652
|
+
assert_nil(index_cmds.first['index']['_type'])
|
4653
|
+
elsif Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("7.0.0")
|
4654
|
+
assert_equal("_doc", index_cmds.first['index']['_type'])
|
4655
|
+
else
|
4656
|
+
assert_equal("fluentd", index_cmds.first['index']['_type'])
|
4657
|
+
end
|
4528
4658
|
end
|
4529
4659
|
|
4530
4660
|
def test_writes_to_target_type_key_fallack_to_type_name
|
@@ -4535,7 +4665,13 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4535
4665
|
driver.run(default_tag: 'test') do
|
4536
4666
|
driver.feed(sample_record)
|
4537
4667
|
end
|
4538
|
-
|
4668
|
+
if Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("8.0.0")
|
4669
|
+
assert_nil(index_cmds.first['index']['_type'])
|
4670
|
+
elsif Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("7.0.0")
|
4671
|
+
assert_equal("_doc", index_cmds.first['index']['_type'])
|
4672
|
+
else
|
4673
|
+
assert_equal("fluentd", index_cmds.first['index']['_type'])
|
4674
|
+
end
|
4539
4675
|
end
|
4540
4676
|
|
4541
4677
|
data("old" => {"es_version" => 2, "_type" => "local-override"},
|
@@ -4569,7 +4705,13 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4569
4705
|
}
|
4570
4706
|
}))
|
4571
4707
|
end
|
4572
|
-
|
4708
|
+
if Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("8.0.0")
|
4709
|
+
assert_nil(index_cmds.first['index']['_type'])
|
4710
|
+
elsif Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("7.0.0")
|
4711
|
+
assert_equal("_doc", index_cmds.first['index']['_type'])
|
4712
|
+
else
|
4713
|
+
assert_equal("fluentd", index_cmds.first['index']['_type'])
|
4714
|
+
end
|
4573
4715
|
end
|
4574
4716
|
|
4575
4717
|
def test_writes_to_speficied_host
|
@@ -5410,7 +5552,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5410
5552
|
driver.run(default_tag: 'test') do
|
5411
5553
|
driver.feed(sample_record)
|
5412
5554
|
end
|
5413
|
-
|
5555
|
+
routing_key = driver.instance.instance_variable_get(:@routing_key_name)
|
5556
|
+
assert_equal('routing', index_cmds[0]['index'][routing_key])
|
5414
5557
|
end
|
5415
5558
|
|
5416
5559
|
def test_es7
|
@@ -5420,7 +5563,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5420
5563
|
driver.run(default_tag: 'test') do
|
5421
5564
|
driver.feed(sample_record)
|
5422
5565
|
end
|
5423
|
-
|
5566
|
+
routing_key = driver.instance.instance_variable_get(:@routing_key_name)
|
5567
|
+
assert_equal('routing', index_cmds[0]['index'][routing_key])
|
5424
5568
|
end
|
5425
5569
|
end
|
5426
5570
|
|
@@ -5432,7 +5576,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5432
5576
|
driver.run(default_tag: 'test') do
|
5433
5577
|
driver.feed(nested_sample_record)
|
5434
5578
|
end
|
5435
|
-
|
5579
|
+
routing_key = driver.instance.instance_variable_get(:@routing_key_name)
|
5580
|
+
assert_equal('routing', index_cmds[0]['index'][routing_key])
|
5436
5581
|
end
|
5437
5582
|
|
5438
5583
|
def test_adds_nested_routing_key_with_dollar_dot
|
@@ -5442,7 +5587,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5442
5587
|
driver.run(default_tag: 'test') do
|
5443
5588
|
driver.feed(nested_sample_record)
|
5444
5589
|
end
|
5445
|
-
|
5590
|
+
routing_key = driver.instance.instance_variable_get(:@routing_key_name)
|
5591
|
+
assert_equal('routing', index_cmds[0]['index'][routing_key])
|
5446
5592
|
end
|
5447
5593
|
|
5448
5594
|
def test_adds_nested_routing_key_with_bracket
|
@@ -5452,7 +5598,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5452
5598
|
driver.run(default_tag: 'test') do
|
5453
5599
|
driver.feed(nested_sample_record)
|
5454
5600
|
end
|
5455
|
-
|
5601
|
+
routing_key = driver.instance.instance_variable_get(:@routing_key_name)
|
5602
|
+
assert_equal('routing', index_cmds[0]['index'][routing_key])
|
5456
5603
|
end
|
5457
5604
|
end
|
5458
5605
|
|
@@ -5463,7 +5610,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5463
5610
|
driver.run(default_tag: 'test') do
|
5464
5611
|
driver.feed(sample_record)
|
5465
5612
|
end
|
5466
|
-
|
5613
|
+
routing_key = driver.instance.instance_variable_get(:@routing_key_name)
|
5614
|
+
assert(!index_cmds[0]['index'].has_key?(routing_key))
|
5467
5615
|
end
|
5468
5616
|
|
5469
5617
|
def test_adds_routing_key_when_not_configured
|
@@ -5472,7 +5620,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5472
5620
|
driver.run(default_tag: 'test') do
|
5473
5621
|
driver.feed(sample_record)
|
5474
5622
|
end
|
5475
|
-
|
5623
|
+
routing_key = driver.instance.instance_variable_get(:@routing_key_name)
|
5624
|
+
assert(!index_cmds[0]['index'].has_key?(routing_key))
|
5476
5625
|
end
|
5477
5626
|
|
5478
5627
|
def test_remove_one_key
|
@@ -6157,7 +6306,12 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
6157
6306
|
end
|
6158
6307
|
|
6159
6308
|
def test_ignore_exception
|
6160
|
-
|
6309
|
+
ignore_classes = if Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("8.0.0")
|
6310
|
+
["Elastic::Transport::Transport::Errors::ServiceUnavailable"]
|
6311
|
+
else
|
6312
|
+
["Elasticsearch::Transport::Transport::Errors::ServiceUnavailable"]
|
6313
|
+
end
|
6314
|
+
driver.configure("ignore_exceptions #{ignore_classes}")
|
6161
6315
|
stub_elastic_unavailable
|
6162
6316
|
stub_elastic_info
|
6163
6317
|
|
@@ -6167,7 +6321,12 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
6167
6321
|
end
|
6168
6322
|
|
6169
6323
|
def test_ignore_exception_with_superclass
|
6170
|
-
|
6324
|
+
ignore_classes = if Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("8.0.0")
|
6325
|
+
["Elastic::Transport::Transport::Errors::ServiceUnavailable"]
|
6326
|
+
else
|
6327
|
+
["Elasticsearch::Transport::Transport::Errors::ServiceUnavailable"]
|
6328
|
+
end
|
6329
|
+
driver.configure("ignore_exceptions #{ignore_classes}")
|
6171
6330
|
stub_elastic_unavailable
|
6172
6331
|
stub_elastic_info
|
6173
6332
|
|