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.
- checksums.yaml +4 -4
- data/.github/workflows/linux.yml +1 -1
- data/.github/workflows/macos.yml +1 -1
- data/.github/workflows/windows.yml +1 -1
- data/History.md +19 -0
- data/README.md +84 -2
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/elasticsearch_error_handler.rb +13 -2
- data/lib/fluent/plugin/elasticsearch_index_template.rb +13 -1
- data/lib/fluent/plugin/out_elasticsearch.rb +52 -4
- data/lib/fluent/plugin/out_elasticsearch_data_stream.rb +81 -49
- data/test/plugin/test_elasticsearch_error_handler.rb +25 -8
- data/test/plugin/test_elasticsearch_fallback_selector.rb +1 -1
- data/test/plugin/test_elasticsearch_index_lifecycle_management.rb +10 -0
- data/test/plugin/test_in_elasticsearch.rb +12 -0
- data/test/plugin/test_out_elasticsearch.rb +412 -18
- data/test/plugin/test_out_elasticsearch_data_stream.rb +348 -98
- data/test/plugin/test_out_elasticsearch_dynamic.rb +100 -5
- metadata +3 -3
@@ -10,7 +10,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
10
10
|
include FlexMock::TestCase
|
11
11
|
include Fluent::Test::Helpers
|
12
12
|
|
13
|
-
attr_accessor :index_cmds, :index_command_counts
|
13
|
+
attr_accessor :index_cmds, :index_command_counts, :index_cmds_all_requests
|
14
14
|
|
15
15
|
def setup
|
16
16
|
Fluent::Test.setup
|
@@ -45,6 +45,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
45
45
|
}.configure(conf)
|
46
46
|
end
|
47
47
|
|
48
|
+
def elasticsearch_transport_layer_decoupling?
|
49
|
+
Gem::Version.create(::Elasticsearch::Transport::VERSION) >= Gem::Version.new("7.14.0")
|
50
|
+
end
|
51
|
+
|
48
52
|
def default_type_name
|
49
53
|
Fluent::Plugin::ElasticsearchOutput::DEFAULT_TYPE_NAME
|
50
54
|
end
|
@@ -60,7 +64,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
60
64
|
end
|
61
65
|
|
62
66
|
def stub_elastic_info(url="http://localhost:9200/", version="6.4.2")
|
63
|
-
body ="{\"version\":{\"number\":\"#{version}\"}}"
|
67
|
+
body ="{\"version\":{\"number\":\"#{version}\", \"build_flavor\":\"default\"},\"tagline\" : \"You Know, for Search\"}"
|
64
68
|
stub_request(:get, url).to_return({:status => 200, :body => body, :headers => { 'Content-Type' => 'json' } })
|
65
69
|
end
|
66
70
|
|
@@ -70,6 +74,14 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
70
74
|
end
|
71
75
|
end
|
72
76
|
|
77
|
+
def stub_elastic_all_requests(url="http://localhost:9200/_bulk")
|
78
|
+
@index_cmds_all_requests = Array.new
|
79
|
+
stub_request(:post, url).with do |req|
|
80
|
+
@index_cmds = req.body.split("\n").map {|r| JSON.parse(r) }
|
81
|
+
@index_cmds_all_requests << @index_cmds
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
73
85
|
def stub_elastic_unavailable(url="http://localhost:9200/_bulk")
|
74
86
|
stub_request(:post, url).to_return(:status => [503, "Service Unavailable"])
|
75
87
|
end
|
@@ -253,7 +265,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
253
265
|
assert_true instance.verify_es_version_at_startup
|
254
266
|
assert_equal Fluent::Plugin::ElasticsearchOutput::DEFAULT_ELASTICSEARCH_VERSION, instance.default_elasticsearch_version
|
255
267
|
assert_false instance.log_es_400_reason
|
256
|
-
assert_equal
|
268
|
+
assert_equal -1, Fluent::Plugin::ElasticsearchOutput::DEFAULT_TARGET_BULK_BYTES
|
257
269
|
assert_false instance.compression
|
258
270
|
assert_equal :no_compression, instance.compression_level
|
259
271
|
assert_true instance.http_backend_excon_nonblock
|
@@ -290,16 +302,25 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
290
302
|
}
|
291
303
|
instance = driver(config).instance
|
292
304
|
|
293
|
-
|
305
|
+
if elasticsearch_transport_layer_decoupling?
|
306
|
+
assert_equal nil, instance.client.transport.transport.options[:transport_options][:headers]["Content-Encoding"]
|
307
|
+
else
|
308
|
+
assert_equal nil, instance.client.transport.options[:transport_options][:headers]["Content-Encoding"]
|
309
|
+
end
|
294
310
|
|
295
311
|
stub_request(:post, "http://localhost:9200/_bulk").
|
296
312
|
to_return(status: 200, body: "", headers: {})
|
313
|
+
stub_elastic_info
|
297
314
|
driver.run(default_tag: 'test') do
|
298
315
|
driver.feed(sample_record)
|
299
316
|
end
|
300
317
|
compressable = instance.compressable_connection
|
301
318
|
|
302
|
-
|
319
|
+
if elasticsearch_transport_layer_decoupling?
|
320
|
+
assert_equal "gzip", instance.client(nil, compressable).transport.transport.options[:transport_options][:headers]["Content-Encoding"]
|
321
|
+
else
|
322
|
+
assert_equal "gzip", instance.client(nil, compressable).transport.options[:transport_options][:headers]["Content-Encoding"]
|
323
|
+
end
|
303
324
|
end
|
304
325
|
|
305
326
|
test 'check compression option is passed to transport' do
|
@@ -310,16 +331,25 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
310
331
|
}
|
311
332
|
instance = driver(config).instance
|
312
333
|
|
313
|
-
|
334
|
+
if elasticsearch_transport_layer_decoupling?
|
335
|
+
assert_equal false, instance.client.transport.transport.options[:compression]
|
336
|
+
else
|
337
|
+
assert_equal false, instance.client.transport.options[:compression]
|
338
|
+
end
|
314
339
|
|
315
340
|
stub_request(:post, "http://localhost:9200/_bulk").
|
316
341
|
to_return(status: 200, body: "", headers: {})
|
342
|
+
stub_elastic_info
|
317
343
|
driver.run(default_tag: 'test') do
|
318
344
|
driver.feed(sample_record)
|
319
345
|
end
|
320
346
|
compressable = instance.compressable_connection
|
321
347
|
|
322
|
-
|
348
|
+
if elasticsearch_transport_layer_decoupling?
|
349
|
+
assert_equal true, instance.client(nil, compressable).transport.transport.options[:compression]
|
350
|
+
else
|
351
|
+
assert_equal true, instance.client(nil, compressable).transport.options[:compression]
|
352
|
+
end
|
323
353
|
end
|
324
354
|
|
325
355
|
test 'check configure cloud_id based client' do
|
@@ -406,7 +436,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
406
436
|
end
|
407
437
|
|
408
438
|
def stub_elastic_info_bad(url="http://localhost:9200/", version="6.4.2")
|
409
|
-
body ="{\"version\":{\"number\":\"#{version}\"}}"
|
439
|
+
body ="{\"version\":{\"number\":\"#{version}\",\"build_flavor\":\"default\"},\"tagline\":\"You Know, for Search\"}"
|
410
440
|
stub_request(:get, url).to_return({:status => 200, :body => body, :headers => { 'Content-Type' => 'text/plain' } })
|
411
441
|
end
|
412
442
|
|
@@ -423,9 +453,15 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
423
453
|
scheme https
|
424
454
|
@log_level info
|
425
455
|
}
|
426
|
-
|
427
|
-
|
428
|
-
|
456
|
+
if elasticsearch_transport_layer_decoupling?
|
457
|
+
assert_raise(NoMethodError) do
|
458
|
+
d = create_driver(config, 7, "\"7.10.1\"")
|
459
|
+
end
|
460
|
+
else
|
461
|
+
d = create_driver(config, 7, "\"7.10.1\"")
|
462
|
+
logs = d.logs
|
463
|
+
assert_logs_include(logs, /can not dig version information. Assuming Elasticsearch 7/)
|
464
|
+
end
|
429
465
|
end
|
430
466
|
end
|
431
467
|
|
@@ -488,6 +524,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
488
524
|
stub_request(:put, "http://localhost:9200/_ilm/policy/logstash-policy").
|
489
525
|
with(body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
490
526
|
to_return(status: 200, body: "", headers: {})
|
527
|
+
stub_elastic_info
|
491
528
|
|
492
529
|
assert_nothing_raised {
|
493
530
|
driver(config)
|
@@ -532,6 +569,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
532
569
|
stub_request(:put, "http://localhost:9200/_ilm/policy/logstash-policy").
|
533
570
|
with(body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"75gb\",\"max_age\":\"50d\"}}}}}}").
|
534
571
|
to_return(status: 200, body: "", headers: {})
|
572
|
+
stub_elastic_info
|
535
573
|
|
536
574
|
assert_nothing_raised {
|
537
575
|
driver(config)
|
@@ -548,6 +586,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
548
586
|
template_file #{template_file}
|
549
587
|
ilm_policy_overwrite true
|
550
588
|
}
|
589
|
+
stub_elastic_info
|
551
590
|
|
552
591
|
assert_raise(Fluent::ConfigError) {
|
553
592
|
driver(config)
|
@@ -930,6 +969,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
930
969
|
stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
|
931
970
|
with(basic_auth: ['john', 'doe']).
|
932
971
|
to_return(:status => 200, :body => "", :headers => {})
|
972
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
933
973
|
|
934
974
|
driver(config)
|
935
975
|
|
@@ -974,6 +1014,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
974
1014
|
stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
|
975
1015
|
with(basic_auth: ['john', 'doe']).
|
976
1016
|
to_return(:status => 200, :body => "", :headers => {})
|
1017
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
977
1018
|
|
978
1019
|
driver(config)
|
979
1020
|
|
@@ -1037,6 +1078,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1037
1078
|
driver(config)
|
1038
1079
|
|
1039
1080
|
elastic_request = stub_elastic("https://logs.google.com:777/es//_bulk")
|
1081
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
1040
1082
|
driver.run(default_tag: 'test.template') do
|
1041
1083
|
driver.feed(sample_record)
|
1042
1084
|
end
|
@@ -1102,6 +1144,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1102
1144
|
with(basic_auth: ['john', 'doe'],
|
1103
1145
|
body: "{\"aliases\":{\"myapp_deflector-test.template\":{\"is_write_index\":true}}}").
|
1104
1146
|
to_return(:status => 200, :body => "", :headers => {})
|
1147
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
1105
1148
|
|
1106
1149
|
driver(config)
|
1107
1150
|
|
@@ -1212,6 +1255,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1212
1255
|
with(basic_auth: ['john', 'doe'],
|
1213
1256
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
1214
1257
|
to_return(:status => 200, :body => "", :headers => {})
|
1258
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
1215
1259
|
|
1216
1260
|
driver(config)
|
1217
1261
|
|
@@ -1298,6 +1342,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1298
1342
|
with(basic_auth: ['john', 'doe'],
|
1299
1343
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
1300
1344
|
to_return(:status => 200, :body => "", :headers => {})
|
1345
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
1301
1346
|
|
1302
1347
|
driver(config)
|
1303
1348
|
|
@@ -1389,6 +1434,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1389
1434
|
with(basic_auth: ['john', 'doe'],
|
1390
1435
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"60gb\",\"max_age\":\"45d\"}}}}}}").
|
1391
1436
|
to_return(:status => 200, :body => "", :headers => {})
|
1437
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
1392
1438
|
|
1393
1439
|
driver(config)
|
1394
1440
|
|
@@ -1497,6 +1543,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1497
1543
|
with(basic_auth: ['john', 'doe'],
|
1498
1544
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
1499
1545
|
to_return(:status => 200, :body => "", :headers => {})
|
1546
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
1500
1547
|
|
1501
1548
|
driver(config)
|
1502
1549
|
|
@@ -1581,6 +1628,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1581
1628
|
with(basic_auth: ['john', 'doe'],
|
1582
1629
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
|
1583
1630
|
to_return(:status => 200, :body => "", :headers => {})
|
1631
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
1584
1632
|
|
1585
1633
|
driver(config)
|
1586
1634
|
|
@@ -1665,6 +1713,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1665
1713
|
with(basic_auth: ['john', 'doe'],
|
1666
1714
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
|
1667
1715
|
to_return(:status => 200, :body => "", :headers => {})
|
1716
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
1668
1717
|
|
1669
1718
|
driver(config)
|
1670
1719
|
|
@@ -1756,6 +1805,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1756
1805
|
with(basic_auth: ['john', 'doe'],
|
1757
1806
|
body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
|
1758
1807
|
to_return(:status => 200, :body => "", :headers => {})
|
1808
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
1759
1809
|
|
1760
1810
|
driver(config)
|
1761
1811
|
|
@@ -1846,6 +1896,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1846
1896
|
with(basic_auth: ['john', 'doe'],
|
1847
1897
|
body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"80gb\",\"max_age\":\"20d\"}}}}}}").
|
1848
1898
|
to_return(:status => 200, :body => "", :headers => {})
|
1899
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
1849
1900
|
|
1850
1901
|
driver(config)
|
1851
1902
|
|
@@ -1971,6 +2022,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
1971
2022
|
with(basic_auth: ['john', 'doe'],
|
1972
2023
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
1973
2024
|
to_return(:status => 200, :body => "", :headers => {})
|
2025
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
1974
2026
|
|
1975
2027
|
driver(config)
|
1976
2028
|
|
@@ -2067,6 +2119,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2067
2119
|
with(basic_auth: ['john', 'doe'],
|
2068
2120
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
2069
2121
|
to_return(:status => 200, :body => "", :headers => {})
|
2122
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
2070
2123
|
|
2071
2124
|
driver(config)
|
2072
2125
|
|
@@ -2163,6 +2216,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2163
2216
|
with(basic_auth: ['john', 'doe'],
|
2164
2217
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
2165
2218
|
to_return(:status => 200, :body => "", :headers => {})
|
2219
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
2166
2220
|
|
2167
2221
|
driver(config)
|
2168
2222
|
|
@@ -2218,6 +2272,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2218
2272
|
stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
|
2219
2273
|
with(basic_auth: ['john', 'doe']).
|
2220
2274
|
to_return(:status => 200, :body => "", :headers => {})
|
2275
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
2221
2276
|
|
2222
2277
|
driver(config)
|
2223
2278
|
|
@@ -2270,6 +2325,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2270
2325
|
driver(config)
|
2271
2326
|
|
2272
2327
|
stub_elastic("https://logs.google.com:777/es//_bulk")
|
2328
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
2273
2329
|
driver.run(default_tag: 'test.template') do
|
2274
2330
|
driver.feed(sample_record)
|
2275
2331
|
end
|
@@ -2321,6 +2377,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2321
2377
|
driver(config)
|
2322
2378
|
|
2323
2379
|
stub_elastic("https://logs-test.google.com:777/es//_bulk")
|
2380
|
+
stub_elastic_info("https://logs-test.google.com:777/es//")
|
2324
2381
|
driver.run(default_tag: 'test') do
|
2325
2382
|
driver.feed(sample_record)
|
2326
2383
|
end
|
@@ -2381,6 +2438,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2381
2438
|
stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/mylogs").
|
2382
2439
|
with(basic_auth: ['john', 'doe']).
|
2383
2440
|
to_return(:status => 200, :body => "", :headers => {})
|
2441
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
2384
2442
|
|
2385
2443
|
driver(config)
|
2386
2444
|
|
@@ -2443,6 +2501,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2443
2501
|
stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/myapp_deflector").
|
2444
2502
|
with(basic_auth: ['john', 'doe']).
|
2445
2503
|
to_return(:status => 200, :body => "", :headers => {})
|
2504
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
2446
2505
|
|
2447
2506
|
driver(config)
|
2448
2507
|
|
@@ -2511,6 +2570,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2511
2570
|
driver(config)
|
2512
2571
|
|
2513
2572
|
elastic_request = stub_elastic("https://logs.google.com:777/es//_bulk")
|
2573
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
2514
2574
|
driver.run(default_tag: 'custom-test') do
|
2515
2575
|
driver.feed(sample_record)
|
2516
2576
|
end
|
@@ -2610,7 +2670,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2610
2670
|
with(basic_auth: ['john', 'doe'],
|
2611
2671
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
2612
2672
|
to_return(:status => 200, :body => "", :headers => {})
|
2613
|
-
|
2673
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
2614
2674
|
driver(config)
|
2615
2675
|
|
2616
2676
|
assert_requested(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs", times: 1)
|
@@ -2699,6 +2759,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2699
2759
|
with(basic_auth: ['john', 'doe'],
|
2700
2760
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"60gb\",\"max_age\":\"45d\"}}}}}}").
|
2701
2761
|
to_return(:status => 200, :body => "", :headers => {})
|
2762
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
2702
2763
|
|
2703
2764
|
driver(config)
|
2704
2765
|
|
@@ -2728,6 +2789,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2728
2789
|
}
|
2729
2790
|
|
2730
2791
|
# Should raise error because multiple alias indices IllegalArgument Error on executing ILM feature
|
2792
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
2731
2793
|
assert_raise(Fluent::ConfigError) do
|
2732
2794
|
driver(config)
|
2733
2795
|
end
|
@@ -2863,6 +2925,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2863
2925
|
with(basic_auth: ['john', 'doe'],
|
2864
2926
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
|
2865
2927
|
to_return(:status => 200, :body => "", :headers => {})
|
2928
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
2866
2929
|
|
2867
2930
|
driver(config)
|
2868
2931
|
|
@@ -2953,7 +3016,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2953
3016
|
with(basic_auth: ['john', 'doe'],
|
2954
3017
|
:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
|
2955
3018
|
to_return(:status => 200, :body => "", :headers => {})
|
2956
|
-
|
3019
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
2957
3020
|
driver(config)
|
2958
3021
|
|
2959
3022
|
assert_requested(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs", times: 1)
|
@@ -2999,6 +3062,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
2999
3062
|
stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
|
3000
3063
|
with(basic_auth: ['john', 'doe']).
|
3001
3064
|
to_return(:status => 200, :body => "", :headers => {})
|
3065
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
3002
3066
|
|
3003
3067
|
driver(config)
|
3004
3068
|
|
@@ -3045,6 +3109,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3045
3109
|
stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
|
3046
3110
|
with(basic_auth: ['john', 'doe']).
|
3047
3111
|
to_return(:status => 200, :body => "", :headers => {})
|
3112
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
3048
3113
|
|
3049
3114
|
driver(config)
|
3050
3115
|
|
@@ -3107,6 +3172,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3107
3172
|
stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fd%7D-000001%3E/#{alias_endpoint}/myapp_deflector").
|
3108
3173
|
with(basic_auth: ['john', 'doe']).
|
3109
3174
|
to_return(:status => 200, :body => "", :headers => {})
|
3175
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
3110
3176
|
|
3111
3177
|
driver(config)
|
3112
3178
|
|
@@ -3133,7 +3199,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3133
3199
|
stub_request(:get, "https://logs.google.com:777/es//_template/logstash").
|
3134
3200
|
with(basic_auth: ['john', 'doe']).
|
3135
3201
|
to_return(:status => 404, :body => "", :headers => {})
|
3136
|
-
|
3202
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
3137
3203
|
|
3138
3204
|
assert_raise(RuntimeError) {
|
3139
3205
|
driver(config)
|
@@ -3185,7 +3251,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3185
3251
|
|
3186
3252
|
driver(config)
|
3187
3253
|
|
3188
|
-
stub_elastic("https://logs.google.com:777/es//_bulk")
|
3254
|
+
stub_elastic("https://logs-test.google.com:777/es//_bulk")
|
3255
|
+
stub_elastic_info("https://logs-test.google.com:777/es//")
|
3189
3256
|
driver.run(default_tag: 'test') do
|
3190
3257
|
driver.feed(sample_record)
|
3191
3258
|
end
|
@@ -3225,6 +3292,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3225
3292
|
connection_resets += 1
|
3226
3293
|
raise Faraday::ConnectionFailed, "Test message"
|
3227
3294
|
end
|
3295
|
+
stub_elastic_info("https://logs.google.com:778/es//")
|
3228
3296
|
|
3229
3297
|
assert_raise(Fluent::Plugin::ElasticsearchError::RetryableOperationExhaustedFailure) do
|
3230
3298
|
driver(config)
|
@@ -3266,6 +3334,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3266
3334
|
retries += 1
|
3267
3335
|
raise error
|
3268
3336
|
end
|
3337
|
+
stub_elastic_info("https://logs.google.com:778/es//")
|
3269
3338
|
|
3270
3339
|
assert_raise(Fluent::Plugin::ElasticsearchError::RetryableOperationExhaustedFailure) do
|
3271
3340
|
driver(config)
|
@@ -3309,6 +3378,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3309
3378
|
connection_resets += 1
|
3310
3379
|
raise Faraday::ConnectionFailed, "Test message"
|
3311
3380
|
end
|
3381
|
+
stub_elastic_info("https://logs.google.com:778/es//")
|
3312
3382
|
|
3313
3383
|
driver(config)
|
3314
3384
|
|
@@ -3364,6 +3434,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3364
3434
|
stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash3").
|
3365
3435
|
with(basic_auth: ['john', 'doe']).
|
3366
3436
|
to_return(:status => 200, :body => "", :headers => {})
|
3437
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
3367
3438
|
|
3368
3439
|
driver(config)
|
3369
3440
|
|
@@ -3421,6 +3492,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3421
3492
|
stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash3").
|
3422
3493
|
with(basic_auth: ['john', 'doe']).
|
3423
3494
|
to_return(:status => 200, :body => "", :headers => {})
|
3495
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
3424
3496
|
|
3425
3497
|
driver(config)
|
3426
3498
|
|
@@ -3479,6 +3551,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3479
3551
|
stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash2").
|
3480
3552
|
with(basic_auth: ['john', 'doe']).
|
3481
3553
|
to_return(:status => 200, :body => "", :headers => {})
|
3554
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
3482
3555
|
|
3483
3556
|
driver(config)
|
3484
3557
|
|
@@ -3529,6 +3602,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3529
3602
|
stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash2").
|
3530
3603
|
with(basic_auth: ['john', 'doe']).
|
3531
3604
|
to_return(:status => 200, :body => "", :headers => {})
|
3605
|
+
stub_elastic_info("https://logs.google.com:777/es//")
|
3532
3606
|
|
3533
3607
|
assert_raise(RuntimeError) {
|
3534
3608
|
driver(config)
|
@@ -3545,6 +3619,9 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3545
3619
|
path /es/
|
3546
3620
|
port 123
|
3547
3621
|
}
|
3622
|
+
stub_elastic_info("https://host1:50")
|
3623
|
+
stub_elastic_info("https://host2:100")
|
3624
|
+
stub_elastic_info("https://host3:123")
|
3548
3625
|
instance = driver(config).instance
|
3549
3626
|
|
3550
3627
|
assert_equal 3, instance.get_connection_options[:hosts].length
|
@@ -3567,6 +3644,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3567
3644
|
user default_user
|
3568
3645
|
password default_password
|
3569
3646
|
}
|
3647
|
+
stub_elastic_info("https://john:password@host1:443/elastic/")
|
3648
|
+
stub_elastic_info("http://host2")
|
3570
3649
|
instance = driver(config).instance
|
3571
3650
|
|
3572
3651
|
assert_equal 2, instance.get_connection_options[:hosts].length
|
@@ -3593,6 +3672,9 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3593
3672
|
user default_user
|
3594
3673
|
password default_password
|
3595
3674
|
}
|
3675
|
+
stub_elastic_info("https://j%2Bhn:passw%40rd@host1:443/elastic/")
|
3676
|
+
stub_elastic_info("http://host2")
|
3677
|
+
|
3596
3678
|
instance = driver(config).instance
|
3597
3679
|
|
3598
3680
|
assert_equal 2, instance.get_connection_options[:hosts].length
|
@@ -3793,6 +3875,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3793
3875
|
elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
|
3794
3876
|
with(headers: { "Content-Type" => "application/json" })
|
3795
3877
|
end
|
3878
|
+
stub_elastic_info
|
3796
3879
|
driver.run(default_tag: 'test') do
|
3797
3880
|
driver.feed(sample_record)
|
3798
3881
|
end
|
@@ -3804,6 +3887,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3804
3887
|
to_return(:status => 200, :body => "", :headers => {})
|
3805
3888
|
elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
|
3806
3889
|
with(headers: {'custom' => 'header1','and_others' => 'header2' })
|
3890
|
+
stub_elastic_info
|
3807
3891
|
driver.configure(%[custom_headers {"custom":"header1", "and_others":"header2"}])
|
3808
3892
|
driver.run(default_tag: 'test') do
|
3809
3893
|
driver.feed(sample_record)
|
@@ -3816,6 +3900,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3816
3900
|
to_return(:status => 200, :body => "", :headers => {})
|
3817
3901
|
elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
|
3818
3902
|
with(headers: {'Authorization'=>'ApiKey dGVzdGF1dGhoZWFkZXI='})
|
3903
|
+
stub_elastic_info
|
3819
3904
|
driver.configure(%[api_key testauthheader])
|
3820
3905
|
driver.run(default_tag: 'test') do
|
3821
3906
|
driver.feed(sample_record)
|
@@ -3826,6 +3911,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3826
3911
|
def test_write_message_with_bad_chunk
|
3827
3912
|
driver.configure("target_index_key bad_value\n@log_level debug\n")
|
3828
3913
|
stub_elastic
|
3914
|
+
stub_elastic_info
|
3829
3915
|
driver.run(default_tag: 'test') do
|
3830
3916
|
driver.feed({'bad_value'=>"\255"})
|
3831
3917
|
end
|
@@ -3841,6 +3927,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3841
3927
|
def test_writes_to_default_index(data)
|
3842
3928
|
version, index_name = data
|
3843
3929
|
stub_elastic
|
3930
|
+
stub_elastic_info
|
3844
3931
|
driver("", version)
|
3845
3932
|
driver.run(default_tag: 'test') do
|
3846
3933
|
driver.feed(sample_record)
|
@@ -3882,6 +3969,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3882
3969
|
|
3883
3970
|
elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
|
3884
3971
|
to_return(:status => 200, :headers => {'Content-Type' => 'Application/json'}, :body => compressed_body)
|
3972
|
+
stub_elastic_info("http://localhost:9200/")
|
3885
3973
|
|
3886
3974
|
driver(config)
|
3887
3975
|
driver.run(default_tag: 'test') do
|
@@ -3898,6 +3986,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3898
3986
|
def test_writes_to_default_type(data)
|
3899
3987
|
version, index_type = data
|
3900
3988
|
stub_elastic
|
3989
|
+
stub_elastic_info
|
3901
3990
|
driver("", version)
|
3902
3991
|
driver.run(default_tag: 'test') do
|
3903
3992
|
driver.feed(sample_record)
|
@@ -3908,6 +3997,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3908
3997
|
def test_writes_to_speficied_index
|
3909
3998
|
driver.configure("index_name myindex\n")
|
3910
3999
|
stub_elastic
|
4000
|
+
stub_elastic_info
|
3911
4001
|
driver.run(default_tag: 'test') do
|
3912
4002
|
driver.feed(sample_record)
|
3913
4003
|
end
|
@@ -3927,6 +4017,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3927
4017
|
]
|
3928
4018
|
))
|
3929
4019
|
request = stub_elastic
|
4020
|
+
stub_elastic_info
|
3930
4021
|
driver.run(default_tag: 'test') do
|
3931
4022
|
driver.feed(sample_record('huge_record' => ("a" * 20 * 1024 * 1024)))
|
3932
4023
|
driver.feed(sample_record('huge_record' => ("a" * 20 * 1024 * 1024)))
|
@@ -3951,6 +4042,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3951
4042
|
body: /{"index":{"_index":"fluentd","_type":"fluentd"}}\n{"age":26,"request_id":"42","parent_id":"parent","routing_id":"routing","#{chunk_id_key}":".*"}\n/) do |req|
|
3952
4043
|
@index_cmds = req.body.split("\n").map {|r| JSON.parse(r) }
|
3953
4044
|
end
|
4045
|
+
stub_elastic_info
|
3954
4046
|
driver.run(default_tag: 'test', shutdown: false) do
|
3955
4047
|
driver.feed(sample_record)
|
3956
4048
|
end
|
@@ -3980,6 +4072,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3980
4072
|
]
|
3981
4073
|
))
|
3982
4074
|
request = stub_elastic
|
4075
|
+
stub_elastic_info
|
3983
4076
|
driver.run(default_tag: 'test') do
|
3984
4077
|
driver.feed(sample_record('huge_record' => ("a" * 20 * 1024 * 1024)))
|
3985
4078
|
driver.feed(sample_record('huge_record' => ("a" * 20 * 1024 * 1024)))
|
@@ -3992,6 +4085,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
3992
4085
|
def test_writes_to_speficied_index_with_tag_placeholder
|
3993
4086
|
driver.configure("index_name myindex.${tag}\n")
|
3994
4087
|
stub_elastic
|
4088
|
+
stub_elastic_info
|
3995
4089
|
driver.run(default_tag: 'test') do
|
3996
4090
|
driver.feed(sample_record)
|
3997
4091
|
end
|
@@ -4011,6 +4105,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4011
4105
|
]
|
4012
4106
|
))
|
4013
4107
|
stub_elastic
|
4108
|
+
stub_elastic_info
|
4014
4109
|
time = Time.parse Date.today.iso8601
|
4015
4110
|
driver.run(default_tag: 'test') do
|
4016
4111
|
driver.feed(time.to_i, sample_record)
|
@@ -4031,6 +4126,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4031
4126
|
pipeline_id = "mypipeline"
|
4032
4127
|
logstash_index = "myindex.#{pipeline_id}"
|
4033
4128
|
stub_elastic
|
4129
|
+
stub_elastic_info
|
4034
4130
|
driver.run(default_tag: 'test') do
|
4035
4131
|
driver.feed(time.to_i, sample_record.merge({"pipeline_id" => pipeline_id}))
|
4036
4132
|
end
|
@@ -4041,6 +4137,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4041
4137
|
def test_writes_to_speficied_index_uppercase
|
4042
4138
|
driver.configure("index_name MyIndex\n")
|
4043
4139
|
stub_elastic
|
4140
|
+
stub_elastic_info
|
4044
4141
|
driver.run(default_tag: 'test') do
|
4045
4142
|
driver.feed(sample_record)
|
4046
4143
|
end
|
@@ -4052,6 +4149,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4052
4149
|
def test_writes_to_target_index_key
|
4053
4150
|
driver.configure("target_index_key @target_index\n")
|
4054
4151
|
stub_elastic
|
4152
|
+
stub_elastic_info
|
4055
4153
|
record = sample_record.clone
|
4056
4154
|
driver.run(default_tag: 'test') do
|
4057
4155
|
driver.feed(sample_record.merge('@target_index' => 'local-override'))
|
@@ -4065,17 +4163,19 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4065
4163
|
logstash_format true")
|
4066
4164
|
time = Time.parse Date.today.iso8601
|
4067
4165
|
stub_elastic
|
4166
|
+
stub_elastic_info
|
4068
4167
|
driver.run(default_tag: 'test') do
|
4069
4168
|
driver.feed(time.to_i, sample_record.merge('@target_index' => 'local-override'))
|
4070
4169
|
end
|
4071
4170
|
assert_equal('local-override', index_cmds.first['index']['_index'])
|
4072
4171
|
end
|
4073
4172
|
|
4074
|
-
|
4173
|
+
def test_writes_to_target_index_key_logstash_uppercase
|
4075
4174
|
driver.configure("target_index_key @target_index
|
4076
4175
|
logstash_format true")
|
4077
4176
|
time = Time.parse Date.today.iso8601
|
4078
4177
|
stub_elastic
|
4178
|
+
stub_elastic_info
|
4079
4179
|
driver.run(default_tag: 'test') do
|
4080
4180
|
driver.feed(time.to_i, sample_record.merge('@target_index' => 'LOCAL-OVERRIDE'))
|
4081
4181
|
end
|
@@ -4088,17 +4188,203 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4088
4188
|
pipeline = "fluentd"
|
4089
4189
|
driver.configure("pipeline #{pipeline}")
|
4090
4190
|
stub_elastic
|
4191
|
+
stub_elastic_info
|
4091
4192
|
driver.run(default_tag: 'test') do
|
4092
4193
|
driver.feed(sample_record)
|
4093
4194
|
end
|
4094
4195
|
assert_equal(pipeline, index_cmds.first['index']['pipeline'])
|
4095
4196
|
end
|
4096
4197
|
|
4198
|
+
def stub_elastic_affinity_target_index_search_with_body(url="http://localhost:9200/logstash-*/_search", ids, return_body_str)
|
4199
|
+
# Note: ids used in query is unique list of ids
|
4200
|
+
stub_request(:post, url)
|
4201
|
+
.with(
|
4202
|
+
body: "{\"query\":{\"ids\":{\"values\":#{ids.uniq.to_json}}},\"_source\":false,\"sort\":[{\"_index\":{\"order\":\"desc\"}}]}",
|
4203
|
+
)
|
4204
|
+
.to_return(lambda do |req|
|
4205
|
+
{ :status => 200,
|
4206
|
+
:headers => { 'Content-Type' => 'json' },
|
4207
|
+
:body => return_body_str
|
4208
|
+
}
|
4209
|
+
end)
|
4210
|
+
end
|
4211
|
+
|
4212
|
+
def stub_elastic_affinity_target_index_search(url="http://localhost:9200/logstash-*/_search", ids, indices)
|
4213
|
+
# Example ids and indices arrays.
|
4214
|
+
# [ "3408a2c8eecd4fbfb82e45012b54fa82", "2816fc6ef4524b3f8f7e869002005433"]
|
4215
|
+
# [ "logstash-2021.04.28", "logstash-2021.04.29"]
|
4216
|
+
body = %({
|
4217
|
+
"took" : 31,
|
4218
|
+
"timed_out" : false,
|
4219
|
+
"_shards" : {
|
4220
|
+
"total" : 52,
|
4221
|
+
"successful" : 52,
|
4222
|
+
"skipped" : 48,
|
4223
|
+
"failed" : 0
|
4224
|
+
},
|
4225
|
+
"hits" : {
|
4226
|
+
"total" : {
|
4227
|
+
"value" : 356,
|
4228
|
+
"relation" : "eq"
|
4229
|
+
},
|
4230
|
+
"max_score" : null,
|
4231
|
+
"hits" : [
|
4232
|
+
{
|
4233
|
+
"_index" : "#{indices[0]}",
|
4234
|
+
"_type" : "_doc",
|
4235
|
+
"_id" : "#{ids[0]}",
|
4236
|
+
"_score" : null,
|
4237
|
+
"sort" : [
|
4238
|
+
"#{indices[0]}"
|
4239
|
+
]
|
4240
|
+
},
|
4241
|
+
{
|
4242
|
+
"_index" : "#{indices[1]}",
|
4243
|
+
"_type" : "_doc",
|
4244
|
+
"_id" : "#{ids[1]}",
|
4245
|
+
"_score" : null,
|
4246
|
+
"sort" : [
|
4247
|
+
"#{indices[1]}"
|
4248
|
+
]
|
4249
|
+
}
|
4250
|
+
]
|
4251
|
+
}
|
4252
|
+
})
|
4253
|
+
stub_elastic_affinity_target_index_search_with_body(ids, body)
|
4254
|
+
end
|
4255
|
+
|
4256
|
+
def stub_elastic_affinity_target_index_search_return_empty(url="http://localhost:9200/logstash-*/_search", ids)
|
4257
|
+
empty_body = %({
|
4258
|
+
"took" : 5,
|
4259
|
+
"timed_out" : false,
|
4260
|
+
"_shards" : {
|
4261
|
+
"total" : 54,
|
4262
|
+
"successful" : 54,
|
4263
|
+
"skipped" : 53,
|
4264
|
+
"failed" : 0
|
4265
|
+
},
|
4266
|
+
"hits" : {
|
4267
|
+
"total" : {
|
4268
|
+
"value" : 0,
|
4269
|
+
"relation" : "eq"
|
4270
|
+
},
|
4271
|
+
"max_score" : null,
|
4272
|
+
"hits" : [ ]
|
4273
|
+
}
|
4274
|
+
})
|
4275
|
+
stub_elastic_affinity_target_index_search_with_body(ids, empty_body)
|
4276
|
+
end
|
4277
|
+
|
4278
|
+
def test_writes_to_affinity_target_index
|
4279
|
+
driver.configure("target_index_affinity true
|
4280
|
+
logstash_format true
|
4281
|
+
id_key my_id
|
4282
|
+
write_operation update")
|
4283
|
+
|
4284
|
+
my_id_value = "3408a2c8eecd4fbfb82e45012b54fa82"
|
4285
|
+
ids = [my_id_value]
|
4286
|
+
indices = ["logstash-2021.04.28"]
|
4287
|
+
stub_elastic
|
4288
|
+
stub_elastic_info
|
4289
|
+
stub_elastic_affinity_target_index_search(ids, indices)
|
4290
|
+
driver.run(default_tag: 'test') do
|
4291
|
+
driver.feed(sample_record('my_id' => my_id_value))
|
4292
|
+
end
|
4293
|
+
assert_equal('logstash-2021.04.28', index_cmds.first['update']['_index'])
|
4294
|
+
end
|
4295
|
+
|
4296
|
+
def test_writes_to_affinity_target_index_write_operation_upsert
|
4297
|
+
driver.configure("target_index_affinity true
|
4298
|
+
logstash_format true
|
4299
|
+
id_key my_id
|
4300
|
+
write_operation upsert")
|
4301
|
+
|
4302
|
+
my_id_value = "3408a2c8eecd4fbfb82e45012b54fa82"
|
4303
|
+
ids = [my_id_value]
|
4304
|
+
indices = ["logstash-2021.04.28"]
|
4305
|
+
stub_elastic
|
4306
|
+
stub_elastic_info
|
4307
|
+
stub_elastic_affinity_target_index_search(ids, indices)
|
4308
|
+
driver.run(default_tag: 'test') do
|
4309
|
+
driver.feed(sample_record('my_id' => my_id_value))
|
4310
|
+
end
|
4311
|
+
assert_equal('logstash-2021.04.28', index_cmds.first['update']['_index'])
|
4312
|
+
end
|
4313
|
+
|
4314
|
+
def test_writes_to_affinity_target_index_index_not_exists_yet
|
4315
|
+
driver.configure("target_index_affinity true
|
4316
|
+
logstash_format true
|
4317
|
+
id_key my_id
|
4318
|
+
write_operation update")
|
4319
|
+
|
4320
|
+
my_id_value = "3408a2c8eecd4fbfb82e45012b54fa82"
|
4321
|
+
ids = [my_id_value]
|
4322
|
+
stub_elastic
|
4323
|
+
stub_elastic_info
|
4324
|
+
stub_elastic_affinity_target_index_search_return_empty(ids)
|
4325
|
+
time = Time.parse Date.today.iso8601
|
4326
|
+
driver.run(default_tag: 'test') do
|
4327
|
+
driver.feed(time.to_i, sample_record('my_id' => my_id_value))
|
4328
|
+
end
|
4329
|
+
assert_equal("logstash-#{time.utc.strftime("%Y.%m.%d")}", index_cmds.first['update']['_index'])
|
4330
|
+
end
|
4331
|
+
|
4332
|
+
def test_writes_to_affinity_target_index_multiple_indices
|
4333
|
+
driver.configure("target_index_affinity true
|
4334
|
+
logstash_format true
|
4335
|
+
id_key my_id
|
4336
|
+
write_operation update")
|
4337
|
+
|
4338
|
+
my_id_value = "2816fc6ef4524b3f8f7e869002005433"
|
4339
|
+
my_id_value2 = "3408a2c8eecd4fbfb82e45012b54fa82"
|
4340
|
+
ids = [my_id_value, my_id_value2]
|
4341
|
+
indices = ["logstash-2021.04.29", "logstash-2021.04.28"]
|
4342
|
+
stub_elastic_info
|
4343
|
+
stub_elastic_all_requests
|
4344
|
+
stub_elastic_affinity_target_index_search(ids, indices)
|
4345
|
+
driver.run(default_tag: 'test') do
|
4346
|
+
driver.feed(sample_record('my_id' => my_id_value))
|
4347
|
+
driver.feed(sample_record('my_id' => my_id_value2))
|
4348
|
+
end
|
4349
|
+
assert_equal(2, index_cmds_all_requests.count)
|
4350
|
+
assert_equal('logstash-2021.04.29', index_cmds_all_requests[0].first['update']['_index'])
|
4351
|
+
assert_equal(my_id_value, index_cmds_all_requests[0].first['update']['_id'])
|
4352
|
+
assert_equal('logstash-2021.04.28', index_cmds_all_requests[1].first['update']['_index'])
|
4353
|
+
assert_equal(my_id_value2, index_cmds_all_requests[1].first['update']['_id'])
|
4354
|
+
end
|
4355
|
+
|
4356
|
+
def test_writes_to_affinity_target_index_same_id_dublicated_write_to_oldest_index
|
4357
|
+
driver.configure("target_index_affinity true
|
4358
|
+
logstash_format true
|
4359
|
+
id_key my_id
|
4360
|
+
write_operation update")
|
4361
|
+
|
4362
|
+
my_id_value = "2816fc6ef4524b3f8f7e869002005433"
|
4363
|
+
# It may happen than same id has inserted to two index while data inserted during rollover period
|
4364
|
+
ids = [my_id_value, my_id_value]
|
4365
|
+
# Simulate the used sorting here, as search sorts indices in DESC order to pick only oldest index per single _id
|
4366
|
+
indices = ["logstash-2021.04.29", "logstash-2021.04.28"]
|
4367
|
+
|
4368
|
+
stub_elastic_info
|
4369
|
+
stub_elastic_all_requests
|
4370
|
+
stub_elastic_affinity_target_index_search(ids, indices)
|
4371
|
+
driver.run(default_tag: 'test') do
|
4372
|
+
driver.feed(sample_record('my_id' => my_id_value))
|
4373
|
+
driver.feed(sample_record('my_id' => my_id_value))
|
4374
|
+
end
|
4375
|
+
assert_equal('logstash-2021.04.28', index_cmds.first['update']['_index'])
|
4376
|
+
|
4377
|
+
assert_equal(1, index_cmds_all_requests.count)
|
4378
|
+
assert_equal('logstash-2021.04.28', index_cmds_all_requests[0].first['update']['_index'])
|
4379
|
+
assert_equal(my_id_value, index_cmds_all_requests[0].first['update']['_id'])
|
4380
|
+
end
|
4381
|
+
|
4097
4382
|
class PipelinePlaceholdersTest < self
|
4098
4383
|
def test_writes_to_default_index_with_pipeline_tag_placeholder
|
4099
4384
|
pipeline = "fluentd-${tag}"
|
4100
4385
|
driver.configure("pipeline #{pipeline}")
|
4101
4386
|
stub_elastic
|
4387
|
+
stub_elastic_info
|
4102
4388
|
driver.run(default_tag: 'test.builtin.placeholder') do
|
4103
4389
|
driver.feed(sample_record)
|
4104
4390
|
end
|
@@ -4120,6 +4406,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4120
4406
|
time = Time.parse Date.today.iso8601
|
4121
4407
|
pipeline = "fluentd-#{time.getutc.strftime("%Y%m%d")}"
|
4122
4408
|
stub_elastic
|
4409
|
+
stub_elastic_info
|
4123
4410
|
driver.run(default_tag: 'test') do
|
4124
4411
|
driver.feed(time.to_i, sample_record)
|
4125
4412
|
end
|
@@ -4139,6 +4426,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4139
4426
|
pipeline_id = "mypipeline"
|
4140
4427
|
logstash_index = "fluentd-#{pipeline_id}"
|
4141
4428
|
stub_elastic
|
4429
|
+
stub_elastic_info
|
4142
4430
|
driver.run(default_tag: 'test') do
|
4143
4431
|
driver.feed(time.to_i, sample_record.merge({"pipeline_id" => pipeline_id}))
|
4144
4432
|
end
|
@@ -4149,6 +4437,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4149
4437
|
def test_writes_to_target_index_key_fallack
|
4150
4438
|
driver.configure("target_index_key @target_index\n")
|
4151
4439
|
stub_elastic
|
4440
|
+
stub_elastic_info
|
4152
4441
|
driver.run(default_tag: 'test') do
|
4153
4442
|
driver.feed(sample_record)
|
4154
4443
|
end
|
@@ -4161,6 +4450,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4161
4450
|
time = Time.parse Date.today.iso8601
|
4162
4451
|
logstash_index = "logstash-#{time.getutc.strftime("%Y.%m.%d")}"
|
4163
4452
|
stub_elastic
|
4453
|
+
stub_elastic_info
|
4164
4454
|
driver.run(default_tag: 'test') do
|
4165
4455
|
driver.feed(time.to_i, sample_record)
|
4166
4456
|
end
|
@@ -4174,6 +4464,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4174
4464
|
def test_writes_to_speficied_type(data)
|
4175
4465
|
driver('', data["es_version"]).configure("type_name mytype\n")
|
4176
4466
|
stub_elastic
|
4467
|
+
stub_elastic_info
|
4177
4468
|
driver.run(default_tag: 'test') do
|
4178
4469
|
driver.feed(sample_record)
|
4179
4470
|
end
|
@@ -4187,6 +4478,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4187
4478
|
def test_writes_to_speficied_type_with_placeholders(data)
|
4188
4479
|
driver('', data["es_version"]).configure("type_name mytype.${tag}\n")
|
4189
4480
|
stub_elastic
|
4481
|
+
stub_elastic_info
|
4190
4482
|
driver.run(default_tag: 'test') do
|
4191
4483
|
driver.feed(sample_record)
|
4192
4484
|
end
|
@@ -4201,6 +4493,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4201
4493
|
driver('', data["es_version"])
|
4202
4494
|
.configure("type_name mytype.${tag}\nsuppress_type_name true")
|
4203
4495
|
stub_elastic
|
4496
|
+
stub_elastic_info
|
4204
4497
|
driver.run(default_tag: 'test') do
|
4205
4498
|
driver.feed(sample_record)
|
4206
4499
|
end
|
@@ -4215,6 +4508,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4215
4508
|
def test_writes_to_target_type_key(data)
|
4216
4509
|
driver('', data["es_version"]).configure("target_type_key @target_type\n")
|
4217
4510
|
stub_elastic
|
4511
|
+
stub_elastic_info
|
4218
4512
|
record = sample_record.clone
|
4219
4513
|
driver.run(default_tag: 'test') do
|
4220
4514
|
driver.feed(sample_record.merge('@target_type' => 'local-override'))
|
@@ -4226,6 +4520,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4226
4520
|
def test_writes_to_target_type_key_fallack_to_default
|
4227
4521
|
driver.configure("target_type_key @target_type\n")
|
4228
4522
|
stub_elastic
|
4523
|
+
stub_elastic_info
|
4229
4524
|
driver.run(default_tag: 'test') do
|
4230
4525
|
driver.feed(sample_record)
|
4231
4526
|
end
|
@@ -4236,6 +4531,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4236
4531
|
driver.configure("target_type_key @target_type
|
4237
4532
|
type_name mytype")
|
4238
4533
|
stub_elastic
|
4534
|
+
stub_elastic_info
|
4239
4535
|
driver.run(default_tag: 'test') do
|
4240
4536
|
driver.feed(sample_record)
|
4241
4537
|
end
|
@@ -4250,6 +4546,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4250
4546
|
def test_writes_to_target_type_key_nested(data)
|
4251
4547
|
driver('', data["es_version"]).configure("target_type_key kubernetes.labels.log_type\n")
|
4252
4548
|
stub_elastic
|
4549
|
+
stub_elastic_info
|
4253
4550
|
driver.run(default_tag: 'test') do
|
4254
4551
|
driver.feed(sample_record.merge('kubernetes' => {
|
4255
4552
|
'labels' => {
|
@@ -4264,6 +4561,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4264
4561
|
def test_writes_to_target_type_key_fallack_to_default_nested
|
4265
4562
|
driver.configure("target_type_key kubernetes.labels.log_type\n")
|
4266
4563
|
stub_elastic
|
4564
|
+
stub_elastic_info
|
4267
4565
|
driver.run(default_tag: 'test') do
|
4268
4566
|
driver.feed(sample_record.merge('kubernetes' => {
|
4269
4567
|
'labels' => {
|
@@ -4277,6 +4575,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4277
4575
|
def test_writes_to_speficied_host
|
4278
4576
|
driver.configure("host 192.168.33.50\n")
|
4279
4577
|
elastic_request = stub_elastic("http://192.168.33.50:9200/_bulk")
|
4578
|
+
stub_elastic_info("http://192.168.33.50:9200/")
|
4280
4579
|
driver.run(default_tag: 'test') do
|
4281
4580
|
driver.feed(sample_record)
|
4282
4581
|
end
|
@@ -4286,6 +4585,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4286
4585
|
def test_writes_to_speficied_port
|
4287
4586
|
driver.configure("port 9201\n")
|
4288
4587
|
elastic_request = stub_elastic("http://localhost:9201/_bulk")
|
4588
|
+
stub_elastic_info("http://localhost:9201")
|
4289
4589
|
driver.run(default_tag: 'test') do
|
4290
4590
|
driver.feed(sample_record)
|
4291
4591
|
end
|
@@ -4301,6 +4601,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4301
4601
|
hosts.each do |host_info|
|
4302
4602
|
host, port = host_info
|
4303
4603
|
stub_elastic_with_store_index_command_counts("http://#{host}:#{port}/_bulk")
|
4604
|
+
stub_elastic_info("http://#{host}:#{port}/")
|
4304
4605
|
end
|
4305
4606
|
|
4306
4607
|
driver.run(default_tag: 'test') do
|
@@ -4337,6 +4638,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4337
4638
|
]}
|
4338
4639
|
|
4339
4640
|
stub_elastic
|
4641
|
+
stub_elastic_info
|
4340
4642
|
driver.run(default_tag: 'test') do
|
4341
4643
|
driver.feed(original_hash)
|
4342
4644
|
end
|
@@ -4350,6 +4652,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4350
4652
|
expected_output = {"foo" => {"bar" => "baz"}}
|
4351
4653
|
|
4352
4654
|
stub_elastic
|
4655
|
+
stub_elastic_info
|
4353
4656
|
driver.run(default_tag: 'test') do
|
4354
4657
|
driver.feed(original_hash)
|
4355
4658
|
end
|
@@ -4358,6 +4661,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4358
4661
|
|
4359
4662
|
def test_makes_bulk_request
|
4360
4663
|
stub_elastic
|
4664
|
+
stub_elastic_info
|
4361
4665
|
driver.run(default_tag: 'test') do
|
4362
4666
|
driver.feed(sample_record)
|
4363
4667
|
driver.feed(sample_record.merge('age' => 27))
|
@@ -4365,8 +4669,9 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4365
4669
|
assert_equal(4, index_cmds.count)
|
4366
4670
|
end
|
4367
4671
|
|
4368
|
-
def
|
4672
|
+
def test_all_re
|
4369
4673
|
stub_elastic
|
4674
|
+
stub_elastic_info
|
4370
4675
|
driver.run(default_tag: 'test') do
|
4371
4676
|
driver.feed(sample_record)
|
4372
4677
|
driver.feed(sample_record.merge('age' => 27))
|
@@ -4382,6 +4687,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4382
4687
|
dt = DateTime.new(2015, 6, 1, 0, 0, 1, "+01:00")
|
4383
4688
|
logstash_index = "logstash-2015.05.31"
|
4384
4689
|
stub_elastic
|
4690
|
+
stub_elastic_info
|
4385
4691
|
driver.run(default_tag: 'test') do
|
4386
4692
|
driver.feed(dt.to_time.to_i, sample_record)
|
4387
4693
|
end
|
@@ -4396,6 +4702,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4396
4702
|
time = Date.today.to_time
|
4397
4703
|
index = "logstash-#{time.strftime("%Y.%m.%d")}"
|
4398
4704
|
stub_elastic
|
4705
|
+
stub_elastic_info
|
4399
4706
|
driver.run(default_tag: 'test') do
|
4400
4707
|
driver.feed(time.to_i, sample_record)
|
4401
4708
|
end
|
@@ -4408,6 +4715,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4408
4715
|
time = Time.parse Date.today.iso8601
|
4409
4716
|
logstash_index = "myprefix-#{time.getutc.strftime("%Y.%m.%d")}"
|
4410
4717
|
stub_elastic
|
4718
|
+
stub_elastic_info
|
4411
4719
|
driver.run(default_tag: 'test') do
|
4412
4720
|
driver.feed(time.to_i, sample_record)
|
4413
4721
|
end
|
@@ -4422,6 +4730,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4422
4730
|
time = Time.parse Date.today.iso8601
|
4423
4731
|
logstash_index = "myprefix#{separator}#{time.getutc.strftime("%Y.%m.%d")}"
|
4424
4732
|
stub_elastic
|
4733
|
+
stub_elastic_info
|
4425
4734
|
driver.run(default_tag: 'test') do
|
4426
4735
|
driver.feed(time.to_i, sample_record)
|
4427
4736
|
end
|
@@ -4435,6 +4744,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4435
4744
|
time = Time.parse Date.today.iso8601
|
4436
4745
|
logstash_index = "myprefix-test-#{time.getutc.strftime("%Y.%m.%d")}"
|
4437
4746
|
stub_elastic
|
4747
|
+
stub_elastic_info
|
4438
4748
|
driver.run(default_tag: 'test') do
|
4439
4749
|
driver.feed(time.to_i, sample_record)
|
4440
4750
|
end
|
@@ -4457,6 +4767,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4457
4767
|
time = Time.parse Date.today.iso8601
|
4458
4768
|
logstash_index = "myprefix-#{time.getutc.strftime("%H")}-#{time.getutc.strftime("%Y.%m.%d")}"
|
4459
4769
|
stub_elastic
|
4770
|
+
stub_elastic_info
|
4460
4771
|
driver.run(default_tag: 'test') do
|
4461
4772
|
driver.feed(time.to_i, sample_record)
|
4462
4773
|
end
|
@@ -4477,6 +4788,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4477
4788
|
pipeline_id = "mypipeline"
|
4478
4789
|
logstash_index = "myprefix-#{pipeline_id}-#{time.getutc.strftime("%Y.%m.%d")}"
|
4479
4790
|
stub_elastic
|
4791
|
+
stub_elastic_info
|
4480
4792
|
driver.run(default_tag: 'test') do
|
4481
4793
|
driver.feed(time.to_i, sample_record.merge({"pipeline_id" => pipeline_id}))
|
4482
4794
|
end
|
@@ -4502,6 +4814,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4502
4814
|
time = Time.parse Date.today.iso8601
|
4503
4815
|
logstash_index = "myprefix-#{time.getutc.strftime("%Y.%m.%d")}"
|
4504
4816
|
stub_elastic
|
4817
|
+
stub_elastic_info
|
4505
4818
|
driver.run(default_tag: 'test') do
|
4506
4819
|
driver.feed(time.to_i, sample_record.merge('indexformat' => '%Y.%m.%d'))
|
4507
4820
|
end
|
@@ -4525,6 +4838,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4525
4838
|
time = Time.parse Date.today.iso8601
|
4526
4839
|
logstash_index = "myprefix-#{time.getutc.strftime("%Y.%m")}"
|
4527
4840
|
stub_elastic
|
4841
|
+
stub_elastic_info
|
4528
4842
|
driver.run(default_tag: 'test') do
|
4529
4843
|
driver.feed(time.to_i, sample_record.merge('indexformat' => '%Y.%m'))
|
4530
4844
|
end
|
@@ -4537,6 +4851,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4537
4851
|
driver.configure("host ${tag}\n")
|
4538
4852
|
time = Time.parse Date.today.iso8601
|
4539
4853
|
elastic_request = stub_elastic("http://extracted-host:9200/_bulk")
|
4854
|
+
stub_elastic_info("http://extracted-host:9200/")
|
4540
4855
|
driver.run(default_tag: 'extracted-host') do
|
4541
4856
|
driver.feed(time.to_i, sample_record)
|
4542
4857
|
end
|
@@ -4553,6 +4868,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4553
4868
|
host, port = host_info
|
4554
4869
|
host = "extracted-host" if host == '${tag}'
|
4555
4870
|
stub_elastic_with_store_index_command_counts("http://#{host}:#{port}/_bulk")
|
4871
|
+
stub_elastic_info("http://#{host}:#{port}")
|
4556
4872
|
end
|
4557
4873
|
|
4558
4874
|
driver.run(default_tag: 'extracted-host') do
|
@@ -4587,8 +4903,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4587
4903
|
]
|
4588
4904
|
))
|
4589
4905
|
stub_elastic
|
4906
|
+
stub_elastic_info
|
4590
4907
|
time = Time.parse Date.today.iso8601
|
4591
4908
|
elastic_request = stub_elastic("http://host-#{time.utc.strftime('%Y%m%d')}:9200/_bulk")
|
4909
|
+
stub_elastic_info("http://host-#{time.utc.strftime('%Y%m%d')}:9200/")
|
4592
4910
|
driver.run(default_tag: 'test') do
|
4593
4911
|
driver.feed(time.to_i, sample_record)
|
4594
4912
|
end
|
@@ -4609,6 +4927,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4609
4927
|
second_pipeline_id = "2"
|
4610
4928
|
first_request = stub_elastic("http://myhost-1:9200/_bulk")
|
4611
4929
|
second_request = stub_elastic("http://myhost-2:9200/_bulk")
|
4930
|
+
stub_elastic_info("http://myhost-1:9200/")
|
4931
|
+
stub_elastic_info("http://myhost-2:9200/")
|
4612
4932
|
driver.run(default_tag: 'test') do
|
4613
4933
|
driver.feed(time.to_i, sample_record.merge({"pipeline_id" => first_pipeline_id}))
|
4614
4934
|
driver.feed(time.to_i, sample_record.merge({"pipeline_id" => second_pipeline_id}))
|
@@ -4629,6 +4949,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4629
4949
|
time = Time.parse Date.today.iso8601
|
4630
4950
|
pipeline_id = "1"
|
4631
4951
|
request = stub_elastic_unavailable("http://myhost-1:9200/_bulk")
|
4952
|
+
stub_elastic_info("http://myhost-1:9200/")
|
4632
4953
|
exception = assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) {
|
4633
4954
|
driver.run(default_tag: 'test') do
|
4634
4955
|
driver.feed(time.to_i, sample_record.merge({"pipeline_id" => pipeline_id}))
|
@@ -4644,6 +4965,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4644
4965
|
time = Time.parse Date.today.iso8601
|
4645
4966
|
logstash_index = "myprefix-#{time.getutc.strftime("%Y.%m.%d")}"
|
4646
4967
|
stub_elastic
|
4968
|
+
stub_elastic_info
|
4647
4969
|
driver.run(default_tag: 'test') do
|
4648
4970
|
driver.feed(time.to_i, sample_record)
|
4649
4971
|
end
|
@@ -4658,6 +4980,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4658
4980
|
time = Time.parse Date.today.iso8601
|
4659
4981
|
logstash_index = "logstash-#{time.getutc.strftime("%Y.%m")}"
|
4660
4982
|
stub_elastic
|
4983
|
+
stub_elastic_info
|
4661
4984
|
driver.run(default_tag: 'test') do
|
4662
4985
|
driver.feed(time.to_i, sample_record)
|
4663
4986
|
end
|
@@ -4671,6 +4994,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4671
4994
|
time = Time.parse Date.today.iso8601
|
4672
4995
|
logstash_index = "myprefix-#{time.getutc.strftime("%Y.%m")}"
|
4673
4996
|
stub_elastic
|
4997
|
+
stub_elastic_info
|
4674
4998
|
driver.run(default_tag: 'test') do
|
4675
4999
|
driver.feed(time.to_i, sample_record)
|
4676
5000
|
end
|
@@ -4697,6 +5021,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4697
5021
|
|
4698
5022
|
def test_doesnt_add_logstash_timestamp_by_default
|
4699
5023
|
stub_elastic
|
5024
|
+
stub_elastic_info
|
4700
5025
|
driver.run(default_tag: 'test') do
|
4701
5026
|
driver.feed(sample_record)
|
4702
5027
|
end
|
@@ -4706,6 +5031,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4706
5031
|
def test_adds_timestamp_when_logstash
|
4707
5032
|
driver.configure("logstash_format true\n")
|
4708
5033
|
stub_elastic
|
5034
|
+
stub_elastic_info
|
4709
5035
|
ts = DateTime.now
|
4710
5036
|
time = Fluent::EventTime.from_time(ts.to_time)
|
4711
5037
|
driver.run(default_tag: 'test') do
|
@@ -4718,6 +5044,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4718
5044
|
def test_adds_timestamp_when_include_timestamp
|
4719
5045
|
driver.configure("include_timestamp true\n")
|
4720
5046
|
stub_elastic
|
5047
|
+
stub_elastic_info
|
4721
5048
|
ts = DateTime.now
|
4722
5049
|
time = Fluent::EventTime.from_time(ts.to_time)
|
4723
5050
|
driver.run(default_tag: 'test') do
|
@@ -4730,6 +5057,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4730
5057
|
def test_uses_custom_timestamp_when_included_in_record
|
4731
5058
|
driver.configure("logstash_format true\n")
|
4732
5059
|
stub_elastic
|
5060
|
+
stub_elastic_info
|
4733
5061
|
ts = DateTime.new(2001,2,3).iso8601
|
4734
5062
|
driver.run(default_tag: 'test') do
|
4735
5063
|
driver.feed(sample_record.merge!('@timestamp' => ts))
|
@@ -4741,6 +5069,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4741
5069
|
def test_uses_custom_timestamp_when_included_in_record_without_logstash
|
4742
5070
|
driver.configure("include_timestamp true\n")
|
4743
5071
|
stub_elastic
|
5072
|
+
stub_elastic_info
|
4744
5073
|
ts = DateTime.new(2001,2,3).iso8601
|
4745
5074
|
driver.run(default_tag: 'test') do
|
4746
5075
|
driver.feed(sample_record.merge!('@timestamp' => ts))
|
@@ -4753,6 +5082,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4753
5082
|
driver.configure("logstash_format true
|
4754
5083
|
time_key vtm\n")
|
4755
5084
|
stub_elastic
|
5085
|
+
stub_elastic_info
|
4756
5086
|
ts = DateTime.new(2001,2,3).iso8601(9)
|
4757
5087
|
driver.run(default_tag: 'test') do
|
4758
5088
|
driver.feed(sample_record.merge!('vtm' => ts))
|
@@ -4766,6 +5096,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4766
5096
|
time_precision 3
|
4767
5097
|
time_key vtm\n")
|
4768
5098
|
stub_elastic
|
5099
|
+
stub_elastic_info
|
4769
5100
|
time = Time.now
|
4770
5101
|
float_time = time.to_f
|
4771
5102
|
driver.run(default_tag: 'test') do
|
@@ -4780,6 +5111,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4780
5111
|
time_key_format %Y-%m-%d %H:%M:%S.%N%z
|
4781
5112
|
time_key vtm\n")
|
4782
5113
|
stub_elastic
|
5114
|
+
stub_elastic_info
|
4783
5115
|
ts = "2001-02-03 13:14:01.673+02:00"
|
4784
5116
|
driver.run(default_tag: 'test') do
|
4785
5117
|
driver.feed(sample_record.merge!('vtm' => ts))
|
@@ -4794,6 +5126,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4794
5126
|
time_key_format %Y-%m-%d %H:%M:%S.%N%z
|
4795
5127
|
time_key vtm\n")
|
4796
5128
|
stub_elastic
|
5129
|
+
stub_elastic_info
|
4797
5130
|
ts = "2001-02-03 13:14:01.673+02:00"
|
4798
5131
|
time = Time.parse(ts)
|
4799
5132
|
current_zone_offset = Time.new(2001, 02, 03).to_datetime.offset
|
@@ -4811,6 +5144,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4811
5144
|
time_key_format %Y-%m-%d %H:%M:%S.%N%z
|
4812
5145
|
time_key vtm\n")
|
4813
5146
|
stub_elastic
|
5147
|
+
stub_elastic_info
|
4814
5148
|
ts = "2001-02-03 13:14:01.673+02:00"
|
4815
5149
|
driver.run(default_tag: 'test') do
|
4816
5150
|
driver.feed(sample_record.merge!('vtm' => ts))
|
@@ -4825,6 +5159,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4825
5159
|
time_key vtm
|
4826
5160
|
time_key_exclude_timestamp true\n")
|
4827
5161
|
stub_elastic
|
5162
|
+
stub_elastic_info
|
4828
5163
|
ts = DateTime.new(2001,2,3).iso8601
|
4829
5164
|
driver.run(default_tag: 'test') do
|
4830
5165
|
driver.feed(sample_record.merge!('vtm' => ts))
|
@@ -4836,6 +5171,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4836
5171
|
driver.configure("logstash_format true
|
4837
5172
|
time_key_format %Y-%m-%dT%H:%M:%S.%N%z\n")
|
4838
5173
|
stub_elastic
|
5174
|
+
stub_elastic_info
|
4839
5175
|
ts = "2001-02-03T13:14:01.673+02:00"
|
4840
5176
|
driver.run(default_tag: 'test') do
|
4841
5177
|
driver.feed(sample_record.merge!('@timestamp' => ts))
|
@@ -4850,6 +5186,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4850
5186
|
index_name test
|
4851
5187
|
time_key_format %Y-%m-%dT%H:%M:%S.%N%z\n")
|
4852
5188
|
stub_elastic
|
5189
|
+
stub_elastic_info
|
4853
5190
|
ts = "2001-02-03T13:14:01.673+02:00"
|
4854
5191
|
driver.run(default_tag: 'test') do
|
4855
5192
|
driver.feed(sample_record.merge!('@timestamp' => ts))
|
@@ -4867,6 +5204,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4867
5204
|
driver.configure("logstash_format true
|
4868
5205
|
time_key_format %Y-%m-%dT%H:%M:%S.%N%z\n#{tag_config}\n")
|
4869
5206
|
stub_elastic
|
5207
|
+
stub_elastic_info
|
4870
5208
|
|
4871
5209
|
ts = "2001/02/03 13:14:01,673+02:00"
|
4872
5210
|
index = "logstash-#{Time.now.getutc.strftime("%Y.%m.%d")}"
|
@@ -4887,6 +5225,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4887
5225
|
driver.configure("logstash_format true
|
4888
5226
|
time_key_format %a %b %d %H:%M:%S %Z %Y\n")
|
4889
5227
|
stub_elastic
|
5228
|
+
stub_elastic_info
|
4890
5229
|
ts = "Thu Nov 29 14:33:20 GMT 2001"
|
4891
5230
|
driver.run(default_tag: 'test') do
|
4892
5231
|
driver.feed(sample_record.merge!('@timestamp' => ts))
|
@@ -4899,6 +5238,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4899
5238
|
def test_uses_nanosecond_precision_by_default
|
4900
5239
|
driver.configure("logstash_format true\n")
|
4901
5240
|
stub_elastic
|
5241
|
+
stub_elastic_info
|
4902
5242
|
time = Fluent::EventTime.new(Time.now.to_i, 123456789)
|
4903
5243
|
driver.run(default_tag: 'test') do
|
4904
5244
|
driver.feed(time, sample_record)
|
@@ -4911,6 +5251,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4911
5251
|
driver.configure("logstash_format true
|
4912
5252
|
time_precision 3\n")
|
4913
5253
|
stub_elastic
|
5254
|
+
stub_elastic_info
|
4914
5255
|
time = Fluent::EventTime.new(Time.now.to_i, 123456789)
|
4915
5256
|
driver.run(default_tag: 'test') do
|
4916
5257
|
driver.feed(time, sample_record)
|
@@ -4921,6 +5262,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4921
5262
|
|
4922
5263
|
def test_doesnt_add_tag_key_by_default
|
4923
5264
|
stub_elastic
|
5265
|
+
stub_elastic_info
|
4924
5266
|
driver.run(default_tag: 'test') do
|
4925
5267
|
driver.feed(sample_record)
|
4926
5268
|
end
|
@@ -4930,6 +5272,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4930
5272
|
def test_adds_tag_key_when_configured
|
4931
5273
|
driver.configure("include_tag_key true\n")
|
4932
5274
|
stub_elastic
|
5275
|
+
stub_elastic_info
|
4933
5276
|
driver.run(default_tag: 'mytag') do
|
4934
5277
|
driver.feed(sample_record)
|
4935
5278
|
end
|
@@ -4940,6 +5283,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4940
5283
|
def test_adds_id_key_when_configured
|
4941
5284
|
driver.configure("id_key request_id\n")
|
4942
5285
|
stub_elastic
|
5286
|
+
stub_elastic_info
|
4943
5287
|
driver.run(default_tag: 'test') do
|
4944
5288
|
driver.feed(sample_record)
|
4945
5289
|
end
|
@@ -4950,6 +5294,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4950
5294
|
def test_adds_nested_id_key_with_dot
|
4951
5295
|
driver.configure("id_key nested.request_id\n")
|
4952
5296
|
stub_elastic
|
5297
|
+
stub_elastic_info
|
4953
5298
|
driver.run(default_tag: 'test') do
|
4954
5299
|
driver.feed(nested_sample_record)
|
4955
5300
|
end
|
@@ -4959,6 +5304,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4959
5304
|
def test_adds_nested_id_key_with_dollar_dot
|
4960
5305
|
driver.configure("id_key $.nested.request_id\n")
|
4961
5306
|
stub_elastic
|
5307
|
+
stub_elastic_info
|
4962
5308
|
driver.run(default_tag: 'test') do
|
4963
5309
|
driver.feed(nested_sample_record)
|
4964
5310
|
end
|
@@ -4968,6 +5314,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4968
5314
|
def test_adds_nested_id_key_with_bracket
|
4969
5315
|
driver.configure("id_key $['nested']['request_id']\n")
|
4970
5316
|
stub_elastic
|
5317
|
+
stub_elastic_info
|
4971
5318
|
driver.run(default_tag: 'test') do
|
4972
5319
|
driver.feed(nested_sample_record)
|
4973
5320
|
end
|
@@ -4978,6 +5325,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4978
5325
|
def test_doesnt_add_id_key_if_missing_when_configured
|
4979
5326
|
driver.configure("id_key another_request_id\n")
|
4980
5327
|
stub_elastic
|
5328
|
+
stub_elastic_info
|
4981
5329
|
driver.run(default_tag: 'test') do
|
4982
5330
|
driver.feed(sample_record)
|
4983
5331
|
end
|
@@ -4986,6 +5334,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4986
5334
|
|
4987
5335
|
def test_adds_id_key_when_not_configured
|
4988
5336
|
stub_elastic
|
5337
|
+
stub_elastic_info
|
4989
5338
|
driver.run(default_tag: 'test') do
|
4990
5339
|
driver.feed(sample_record)
|
4991
5340
|
end
|
@@ -4995,6 +5344,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
4995
5344
|
def test_adds_parent_key_when_configured
|
4996
5345
|
driver.configure("parent_key parent_id\n")
|
4997
5346
|
stub_elastic
|
5347
|
+
stub_elastic_info
|
4998
5348
|
driver.run(default_tag: 'test') do
|
4999
5349
|
driver.feed(sample_record)
|
5000
5350
|
end
|
@@ -5005,6 +5355,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5005
5355
|
def test_adds_nested_parent_key_with_dot
|
5006
5356
|
driver.configure("parent_key nested.parent_id\n")
|
5007
5357
|
stub_elastic
|
5358
|
+
stub_elastic_info
|
5008
5359
|
driver.run(default_tag: 'test') do
|
5009
5360
|
driver.feed(nested_sample_record)
|
5010
5361
|
end
|
@@ -5014,6 +5365,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5014
5365
|
def test_adds_nested_parent_key_with_dollar_dot
|
5015
5366
|
driver.configure("parent_key $.nested.parent_id\n")
|
5016
5367
|
stub_elastic
|
5368
|
+
stub_elastic_info
|
5017
5369
|
driver.run(default_tag: 'test') do
|
5018
5370
|
driver.feed(nested_sample_record)
|
5019
5371
|
end
|
@@ -5023,6 +5375,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5023
5375
|
def test_adds_nested_parent_key_with_bracket
|
5024
5376
|
driver.configure("parent_key $['nested']['parent_id']\n")
|
5025
5377
|
stub_elastic
|
5378
|
+
stub_elastic_info
|
5026
5379
|
driver.run(default_tag: 'test') do
|
5027
5380
|
driver.feed(nested_sample_record)
|
5028
5381
|
end
|
@@ -5033,6 +5386,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5033
5386
|
def test_doesnt_add_parent_key_if_missing_when_configured
|
5034
5387
|
driver.configure("parent_key another_parent_id\n")
|
5035
5388
|
stub_elastic
|
5389
|
+
stub_elastic_info
|
5036
5390
|
driver.run(default_tag: 'test') do
|
5037
5391
|
driver.feed(sample_record)
|
5038
5392
|
end
|
@@ -5041,6 +5395,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5041
5395
|
|
5042
5396
|
def test_adds_parent_key_when_not_configured
|
5043
5397
|
stub_elastic
|
5398
|
+
stub_elastic_info
|
5044
5399
|
driver.run(default_tag: 'test') do
|
5045
5400
|
driver.feed(sample_record)
|
5046
5401
|
end
|
@@ -5051,6 +5406,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5051
5406
|
def test_es6
|
5052
5407
|
driver("routing_key routing_id\n", 6)
|
5053
5408
|
stub_elastic
|
5409
|
+
stub_elastic_info
|
5054
5410
|
driver.run(default_tag: 'test') do
|
5055
5411
|
driver.feed(sample_record)
|
5056
5412
|
end
|
@@ -5060,6 +5416,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5060
5416
|
def test_es7
|
5061
5417
|
driver("routing_key routing_id\n", 7)
|
5062
5418
|
stub_elastic
|
5419
|
+
stub_elastic_info
|
5063
5420
|
driver.run(default_tag: 'test') do
|
5064
5421
|
driver.feed(sample_record)
|
5065
5422
|
end
|
@@ -5071,6 +5428,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5071
5428
|
def test_adds_nested_routing_key_with_dot
|
5072
5429
|
driver.configure("routing_key nested.routing_id\n")
|
5073
5430
|
stub_elastic
|
5431
|
+
stub_elastic_info
|
5074
5432
|
driver.run(default_tag: 'test') do
|
5075
5433
|
driver.feed(nested_sample_record)
|
5076
5434
|
end
|
@@ -5080,6 +5438,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5080
5438
|
def test_adds_nested_routing_key_with_dollar_dot
|
5081
5439
|
driver.configure("routing_key $.nested.routing_id\n")
|
5082
5440
|
stub_elastic
|
5441
|
+
stub_elastic_info
|
5083
5442
|
driver.run(default_tag: 'test') do
|
5084
5443
|
driver.feed(nested_sample_record)
|
5085
5444
|
end
|
@@ -5089,6 +5448,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5089
5448
|
def test_adds_nested_routing_key_with_bracket
|
5090
5449
|
driver.configure("routing_key $['nested']['routing_id']\n")
|
5091
5450
|
stub_elastic
|
5451
|
+
stub_elastic_info
|
5092
5452
|
driver.run(default_tag: 'test') do
|
5093
5453
|
driver.feed(nested_sample_record)
|
5094
5454
|
end
|
@@ -5099,6 +5459,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5099
5459
|
def test_doesnt_add_routing_key_if_missing_when_configured
|
5100
5460
|
driver.configure("routing_key another_routing_id\n")
|
5101
5461
|
stub_elastic
|
5462
|
+
stub_elastic_info
|
5102
5463
|
driver.run(default_tag: 'test') do
|
5103
5464
|
driver.feed(sample_record)
|
5104
5465
|
end
|
@@ -5107,6 +5468,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5107
5468
|
|
5108
5469
|
def test_adds_routing_key_when_not_configured
|
5109
5470
|
stub_elastic
|
5471
|
+
stub_elastic_info
|
5110
5472
|
driver.run(default_tag: 'test') do
|
5111
5473
|
driver.feed(sample_record)
|
5112
5474
|
end
|
@@ -5116,6 +5478,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5116
5478
|
def test_remove_one_key
|
5117
5479
|
driver.configure("remove_keys key1\n")
|
5118
5480
|
stub_elastic
|
5481
|
+
stub_elastic_info
|
5119
5482
|
driver.run(default_tag: 'test') do
|
5120
5483
|
driver.feed(sample_record.merge('key1' => 'v1', 'key2' => 'v2'))
|
5121
5484
|
end
|
@@ -5126,6 +5489,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5126
5489
|
def test_remove_multi_keys
|
5127
5490
|
driver.configure("remove_keys key1, key2\n")
|
5128
5491
|
stub_elastic
|
5492
|
+
stub_elastic_info
|
5129
5493
|
driver.run(default_tag: 'test') do
|
5130
5494
|
driver.feed(sample_record.merge('key1' => 'v1', 'key2' => 'v2'))
|
5131
5495
|
end
|
@@ -5134,6 +5498,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5134
5498
|
end
|
5135
5499
|
|
5136
5500
|
def test_request_error
|
5501
|
+
stub_elastic_info
|
5137
5502
|
stub_elastic_unavailable
|
5138
5503
|
assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) {
|
5139
5504
|
driver.run(default_tag: 'test', shutdown: false) do
|
@@ -5145,6 +5510,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5145
5510
|
def test_request_forever
|
5146
5511
|
omit("retry_forever test is unstable.") if ENV["CI"]
|
5147
5512
|
stub_elastic
|
5513
|
+
stub_elastic_info
|
5148
5514
|
driver.configure(Fluent::Config::Element.new(
|
5149
5515
|
'ROOT', '', {
|
5150
5516
|
'@type' => 'elasticsearch',
|
@@ -5169,6 +5535,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5169
5535
|
connection_resets += 1
|
5170
5536
|
raise Faraday::ConnectionFailed, "Test message"
|
5171
5537
|
end
|
5538
|
+
stub_elastic_info
|
5172
5539
|
|
5173
5540
|
assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) {
|
5174
5541
|
driver.run(default_tag: 'test', shutdown: false) do
|
@@ -5185,6 +5552,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5185
5552
|
connection_resets += 1
|
5186
5553
|
raise ZeroDivisionError, "any not host_unreachable_exceptions exception"
|
5187
5554
|
end
|
5555
|
+
stub_elastic_info
|
5188
5556
|
|
5189
5557
|
driver.configure("reconnect_on_error true\n")
|
5190
5558
|
|
@@ -5211,6 +5579,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5211
5579
|
connection_resets += 1
|
5212
5580
|
raise ZeroDivisionError, "any not host_unreachable_exceptions exception"
|
5213
5581
|
end
|
5582
|
+
stub_elastic_info
|
5214
5583
|
|
5215
5584
|
driver.configure("reconnect_on_error false\n")
|
5216
5585
|
|
@@ -5254,6 +5623,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5254
5623
|
})
|
5255
5624
|
}
|
5256
5625
|
end)
|
5626
|
+
stub_elastic_info
|
5257
5627
|
|
5258
5628
|
driver.run(default_tag: 'test') do
|
5259
5629
|
driver.feed(1, sample_record)
|
@@ -5325,6 +5695,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5325
5695
|
})
|
5326
5696
|
}
|
5327
5697
|
end)
|
5698
|
+
stub_elastic_info
|
5328
5699
|
|
5329
5700
|
# Check buffer fulfillment condition
|
5330
5701
|
assert_raise(Fluent::Plugin::ElasticsearchOutput::RetryStreamEmitFailure) do
|
@@ -5371,6 +5742,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5371
5742
|
})
|
5372
5743
|
}
|
5373
5744
|
end)
|
5745
|
+
stub_elastic_info
|
5746
|
+
|
5374
5747
|
sample_record1 = sample_record('my_id' => 'abc')
|
5375
5748
|
sample_record4 = sample_record('my_id' => 'xyz')
|
5376
5749
|
|
@@ -5420,6 +5793,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5420
5793
|
})
|
5421
5794
|
}
|
5422
5795
|
end)
|
5796
|
+
stub_elastic_info
|
5797
|
+
|
5423
5798
|
sample_record1 = sample_record('my_id' => 'abc')
|
5424
5799
|
sample_record4 = sample_record('my_id' => 'xyz')
|
5425
5800
|
|
@@ -5490,6 +5865,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5490
5865
|
})
|
5491
5866
|
}
|
5492
5867
|
end)
|
5868
|
+
stub_elastic_info
|
5493
5869
|
|
5494
5870
|
driver.run(default_tag: 'test') do
|
5495
5871
|
driver.feed(1, sample_record)
|
@@ -5506,6 +5882,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5506
5882
|
def test_update_should_not_write_if_theres_no_id
|
5507
5883
|
driver.configure("write_operation update\n")
|
5508
5884
|
stub_elastic
|
5885
|
+
stub_elastic_info
|
5509
5886
|
driver.run(default_tag: 'test') do
|
5510
5887
|
driver.feed(sample_record)
|
5511
5888
|
end
|
@@ -5515,6 +5892,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5515
5892
|
def test_upsert_should_not_write_if_theres_no_id
|
5516
5893
|
driver.configure("write_operation upsert\n")
|
5517
5894
|
stub_elastic
|
5895
|
+
stub_elastic_info
|
5518
5896
|
driver.run(default_tag: 'test') do
|
5519
5897
|
driver.feed(sample_record)
|
5520
5898
|
end
|
@@ -5524,6 +5902,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5524
5902
|
def test_create_should_not_write_if_theres_no_id
|
5525
5903
|
driver.configure("write_operation create\n")
|
5526
5904
|
stub_elastic
|
5905
|
+
stub_elastic_info
|
5527
5906
|
driver.run(default_tag: 'test') do
|
5528
5907
|
driver.feed(sample_record)
|
5529
5908
|
end
|
@@ -5534,6 +5913,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5534
5913
|
driver.configure("write_operation update
|
5535
5914
|
id_key request_id")
|
5536
5915
|
stub_elastic
|
5916
|
+
stub_elastic_info
|
5537
5917
|
driver.run(default_tag: 'test') do
|
5538
5918
|
driver.feed(sample_record)
|
5539
5919
|
end
|
@@ -5547,6 +5927,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5547
5927
|
id_key request_id
|
5548
5928
|
remove_keys_on_update parent_id")
|
5549
5929
|
stub_elastic
|
5930
|
+
stub_elastic_info
|
5550
5931
|
driver.run(default_tag: 'test') do
|
5551
5932
|
driver.feed(sample_record)
|
5552
5933
|
end
|
@@ -5558,6 +5939,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5558
5939
|
driver.configure("write_operation upsert
|
5559
5940
|
id_key request_id")
|
5560
5941
|
stub_elastic
|
5942
|
+
stub_elastic_info
|
5561
5943
|
driver.run(default_tag: 'test') do
|
5562
5944
|
driver.feed(sample_record)
|
5563
5945
|
end
|
@@ -5571,6 +5953,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5571
5953
|
id_key request_id
|
5572
5954
|
remove_keys_on_update parent_id")
|
5573
5955
|
stub_elastic
|
5956
|
+
stub_elastic_info
|
5574
5957
|
driver.run(default_tag: 'test') do
|
5575
5958
|
driver.feed(sample_record)
|
5576
5959
|
end
|
@@ -5585,6 +5968,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5585
5968
|
id_key request_id
|
5586
5969
|
remove_keys_on_update parent_id")
|
5587
5970
|
stub_elastic
|
5971
|
+
stub_elastic_info
|
5588
5972
|
driver.run(default_tag: 'test') do
|
5589
5973
|
driver.feed(sample_record)
|
5590
5974
|
end
|
@@ -5598,6 +5982,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5598
5982
|
id_key id
|
5599
5983
|
remove_keys_on_update foo,baz")
|
5600
5984
|
stub_elastic
|
5985
|
+
stub_elastic_info
|
5601
5986
|
driver.run(default_tag: 'test') do
|
5602
5987
|
driver.feed("id" => 1, "foo" => "bar", "baz" => "quix", "zip" => "zam")
|
5603
5988
|
end
|
@@ -5622,6 +6007,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5622
6007
|
id_key id
|
5623
6008
|
remove_keys_on_update_key keys_to_skip")
|
5624
6009
|
stub_elastic
|
6010
|
+
stub_elastic_info
|
5625
6011
|
driver.run(default_tag: 'test') do
|
5626
6012
|
driver.feed("id" => 1, "foo" => "bar", "baz" => "quix", "keys_to_skip" => ["baz"])
|
5627
6013
|
end
|
@@ -5646,6 +6032,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5646
6032
|
remove_keys_on_update foo,bar
|
5647
6033
|
remove_keys_on_update_key keys_to_skip")
|
5648
6034
|
stub_elastic
|
6035
|
+
stub_elastic_info
|
5649
6036
|
driver.run(default_tag: 'test') do
|
5650
6037
|
driver.feed("id" => 1, "foo" => "bar", "baz" => "quix", "keys_to_skip" => ["baz"])
|
5651
6038
|
end
|
@@ -5670,6 +6057,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5670
6057
|
driver.configure("write_operation create
|
5671
6058
|
id_key request_id")
|
5672
6059
|
stub_elastic
|
6060
|
+
stub_elastic_info
|
5673
6061
|
driver.run(default_tag: 'test') do
|
5674
6062
|
driver.feed(sample_record)
|
5675
6063
|
end
|
@@ -5678,6 +6066,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5678
6066
|
|
5679
6067
|
def test_include_index_in_url
|
5680
6068
|
stub_elastic('http://localhost:9200/logstash-2018.01.01/_bulk')
|
6069
|
+
stub_elastic_info('http://localhost:9200/')
|
5681
6070
|
|
5682
6071
|
driver.configure("index_name logstash-2018.01.01
|
5683
6072
|
include_index_in_url true")
|
@@ -5691,8 +6080,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5691
6080
|
|
5692
6081
|
def test_use_simple_sniffer
|
5693
6082
|
require 'fluent/plugin/elasticsearch_simple_sniffer'
|
5694
|
-
stub_elastic_info
|
5695
6083
|
stub_elastic
|
6084
|
+
stub_elastic_info
|
5696
6085
|
config = %[
|
5697
6086
|
sniffer_class_name Fluent::Plugin::ElasticsearchSimpleSniffer
|
5698
6087
|
log_level debug
|
@@ -5716,6 +6105,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5716
6105
|
remove_keys id
|
5717
6106
|
suppress_doc_wrap true')
|
5718
6107
|
stub_elastic
|
6108
|
+
stub_elastic_info
|
5719
6109
|
doc_body = {'field' => 'value'}
|
5720
6110
|
script_body = {'source' => 'ctx._source.counter += params.param1',
|
5721
6111
|
'lang' => 'painless',
|
@@ -5742,6 +6132,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5742
6132
|
remove_keys id
|
5743
6133
|
suppress_doc_wrap true')
|
5744
6134
|
stub_elastic
|
6135
|
+
stub_elastic_info
|
5745
6136
|
doc_body = {'field' => 'value'}
|
5746
6137
|
script_body = {'source' => 'ctx._source.counter += params.param1',
|
5747
6138
|
'lang' => 'painless',
|
@@ -5768,6 +6159,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5768
6159
|
def test_ignore_exception
|
5769
6160
|
driver.configure('ignore_exceptions ["Elasticsearch::Transport::Transport::Errors::ServiceUnavailable"]')
|
5770
6161
|
stub_elastic_unavailable
|
6162
|
+
stub_elastic_info
|
5771
6163
|
|
5772
6164
|
driver.run(default_tag: 'test') do
|
5773
6165
|
driver.feed(sample_record)
|
@@ -5777,6 +6169,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5777
6169
|
def test_ignore_exception_with_superclass
|
5778
6170
|
driver.configure('ignore_exceptions ["Elasticsearch::Transport::Transport::ServerError"]')
|
5779
6171
|
stub_elastic_unavailable
|
6172
|
+
stub_elastic_info
|
5780
6173
|
|
5781
6174
|
driver.run(default_tag: 'test') do
|
5782
6175
|
driver.feed(sample_record)
|
@@ -5786,6 +6179,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
|
|
5786
6179
|
def test_ignore_excetion_handles_appropriate_ones
|
5787
6180
|
driver.configure('ignore_exceptions ["Faraday::ConnectionFailed"]')
|
5788
6181
|
stub_elastic_unavailable
|
6182
|
+
stub_elastic_info
|
5789
6183
|
|
5790
6184
|
assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) {
|
5791
6185
|
driver.run(default_tag: 'test', shutdown: false) do
|