fluent-plugin-elasticsearch 5.0.5 → 5.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
 
@@ -261,7 +265,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
261
265
  assert_true instance.verify_es_version_at_startup
262
266
  assert_equal Fluent::Plugin::ElasticsearchOutput::DEFAULT_ELASTICSEARCH_VERSION, instance.default_elasticsearch_version
263
267
  assert_false instance.log_es_400_reason
264
- assert_equal 20 * 1024 * 1024, Fluent::Plugin::ElasticsearchOutput::TARGET_BULK_BYTES
268
+ assert_equal -1, Fluent::Plugin::ElasticsearchOutput::DEFAULT_TARGET_BULK_BYTES
265
269
  assert_false instance.compression
266
270
  assert_equal :no_compression, instance.compression_level
267
271
  assert_true instance.http_backend_excon_nonblock
@@ -298,16 +302,25 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
298
302
  }
299
303
  instance = driver(config).instance
300
304
 
301
- assert_equal nil, instance.client.transport.options[:transport_options][:headers]["Content-Encoding"]
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
302
310
 
303
311
  stub_request(:post, "http://localhost:9200/_bulk").
304
312
  to_return(status: 200, body: "", headers: {})
313
+ stub_elastic_info
305
314
  driver.run(default_tag: 'test') do
306
315
  driver.feed(sample_record)
307
316
  end
308
317
  compressable = instance.compressable_connection
309
318
 
310
- assert_equal "gzip", instance.client(nil, compressable).transport.options[:transport_options][:headers]["Content-Encoding"]
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
311
324
  end
312
325
 
313
326
  test 'check compression option is passed to transport' do
@@ -318,16 +331,25 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
318
331
  }
319
332
  instance = driver(config).instance
320
333
 
321
- assert_equal false, instance.client.transport.options[:compression]
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
322
339
 
323
340
  stub_request(:post, "http://localhost:9200/_bulk").
324
341
  to_return(status: 200, body: "", headers: {})
342
+ stub_elastic_info
325
343
  driver.run(default_tag: 'test') do
326
344
  driver.feed(sample_record)
327
345
  end
328
346
  compressable = instance.compressable_connection
329
347
 
330
- assert_equal true, instance.client(nil, compressable).transport.options[:compression]
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
331
353
  end
332
354
 
333
355
  test 'check configure cloud_id based client' do
@@ -414,7 +436,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
414
436
  end
415
437
 
416
438
  def stub_elastic_info_bad(url="http://localhost:9200/", version="6.4.2")
417
- body ="{\"version\":{\"number\":\"#{version}\"}}"
439
+ body ="{\"version\":{\"number\":\"#{version}\",\"build_flavor\":\"default\"},\"tagline\":\"You Know, for Search\"}"
418
440
  stub_request(:get, url).to_return({:status => 200, :body => body, :headers => { 'Content-Type' => 'text/plain' } })
419
441
  end
420
442
 
@@ -431,9 +453,15 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
431
453
  scheme https
432
454
  @log_level info
433
455
  }
434
- d = create_driver(config, 7, "\"7.10.1\"")
435
- logs = d.logs
436
- assert_logs_include(logs, /can not dig version information. Assuming Elasticsearch 7/)
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
437
465
  end
438
466
  end
439
467
 
@@ -496,6 +524,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
496
524
  stub_request(:put, "http://localhost:9200/_ilm/policy/logstash-policy").
497
525
  with(body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
498
526
  to_return(status: 200, body: "", headers: {})
527
+ stub_elastic_info
499
528
 
500
529
  assert_nothing_raised {
501
530
  driver(config)
@@ -540,6 +569,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
540
569
  stub_request(:put, "http://localhost:9200/_ilm/policy/logstash-policy").
541
570
  with(body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"75gb\",\"max_age\":\"50d\"}}}}}}").
542
571
  to_return(status: 200, body: "", headers: {})
572
+ stub_elastic_info
543
573
 
544
574
  assert_nothing_raised {
545
575
  driver(config)
@@ -556,6 +586,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
556
586
  template_file #{template_file}
557
587
  ilm_policy_overwrite true
558
588
  }
589
+ stub_elastic_info
559
590
 
560
591
  assert_raise(Fluent::ConfigError) {
561
592
  driver(config)
@@ -938,6 +969,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
938
969
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
939
970
  with(basic_auth: ['john', 'doe']).
940
971
  to_return(:status => 200, :body => "", :headers => {})
972
+ stub_elastic_info("https://logs.google.com:777/es//")
941
973
 
942
974
  driver(config)
943
975
 
@@ -982,6 +1014,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
982
1014
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
983
1015
  with(basic_auth: ['john', 'doe']).
984
1016
  to_return(:status => 200, :body => "", :headers => {})
1017
+ stub_elastic_info("https://logs.google.com:777/es//")
985
1018
 
986
1019
  driver(config)
987
1020
 
@@ -1045,6 +1078,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1045
1078
  driver(config)
1046
1079
 
1047
1080
  elastic_request = stub_elastic("https://logs.google.com:777/es//_bulk")
1081
+ stub_elastic_info("https://logs.google.com:777/es//")
1048
1082
  driver.run(default_tag: 'test.template') do
1049
1083
  driver.feed(sample_record)
1050
1084
  end
@@ -1110,6 +1144,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1110
1144
  with(basic_auth: ['john', 'doe'],
1111
1145
  body: "{\"aliases\":{\"myapp_deflector-test.template\":{\"is_write_index\":true}}}").
1112
1146
  to_return(:status => 200, :body => "", :headers => {})
1147
+ stub_elastic_info("https://logs.google.com:777/es//")
1113
1148
 
1114
1149
  driver(config)
1115
1150
 
@@ -1220,6 +1255,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1220
1255
  with(basic_auth: ['john', 'doe'],
1221
1256
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
1222
1257
  to_return(:status => 200, :body => "", :headers => {})
1258
+ stub_elastic_info("https://logs.google.com:777/es//")
1223
1259
 
1224
1260
  driver(config)
1225
1261
 
@@ -1306,6 +1342,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1306
1342
  with(basic_auth: ['john', 'doe'],
1307
1343
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
1308
1344
  to_return(:status => 200, :body => "", :headers => {})
1345
+ stub_elastic_info("https://logs.google.com:777/es//")
1309
1346
 
1310
1347
  driver(config)
1311
1348
 
@@ -1397,6 +1434,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1397
1434
  with(basic_auth: ['john', 'doe'],
1398
1435
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"60gb\",\"max_age\":\"45d\"}}}}}}").
1399
1436
  to_return(:status => 200, :body => "", :headers => {})
1437
+ stub_elastic_info("https://logs.google.com:777/es//")
1400
1438
 
1401
1439
  driver(config)
1402
1440
 
@@ -1505,6 +1543,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1505
1543
  with(basic_auth: ['john', 'doe'],
1506
1544
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
1507
1545
  to_return(:status => 200, :body => "", :headers => {})
1546
+ stub_elastic_info("https://logs.google.com:777/es//")
1508
1547
 
1509
1548
  driver(config)
1510
1549
 
@@ -1589,6 +1628,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1589
1628
  with(basic_auth: ['john', 'doe'],
1590
1629
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
1591
1630
  to_return(:status => 200, :body => "", :headers => {})
1631
+ stub_elastic_info("https://logs.google.com:777/es//")
1592
1632
 
1593
1633
  driver(config)
1594
1634
 
@@ -1673,6 +1713,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1673
1713
  with(basic_auth: ['john', 'doe'],
1674
1714
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
1675
1715
  to_return(:status => 200, :body => "", :headers => {})
1716
+ stub_elastic_info("https://logs.google.com:777/es//")
1676
1717
 
1677
1718
  driver(config)
1678
1719
 
@@ -1764,6 +1805,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1764
1805
  with(basic_auth: ['john', 'doe'],
1765
1806
  body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
1766
1807
  to_return(:status => 200, :body => "", :headers => {})
1808
+ stub_elastic_info("https://logs.google.com:777/es//")
1767
1809
 
1768
1810
  driver(config)
1769
1811
 
@@ -1854,6 +1896,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1854
1896
  with(basic_auth: ['john', 'doe'],
1855
1897
  body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"80gb\",\"max_age\":\"20d\"}}}}}}").
1856
1898
  to_return(:status => 200, :body => "", :headers => {})
1899
+ stub_elastic_info("https://logs.google.com:777/es//")
1857
1900
 
1858
1901
  driver(config)
1859
1902
 
@@ -1979,6 +2022,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1979
2022
  with(basic_auth: ['john', 'doe'],
1980
2023
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
1981
2024
  to_return(:status => 200, :body => "", :headers => {})
2025
+ stub_elastic_info("https://logs.google.com:777/es//")
1982
2026
 
1983
2027
  driver(config)
1984
2028
 
@@ -2075,6 +2119,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2075
2119
  with(basic_auth: ['john', 'doe'],
2076
2120
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
2077
2121
  to_return(:status => 200, :body => "", :headers => {})
2122
+ stub_elastic_info("https://logs.google.com:777/es//")
2078
2123
 
2079
2124
  driver(config)
2080
2125
 
@@ -2171,6 +2216,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2171
2216
  with(basic_auth: ['john', 'doe'],
2172
2217
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
2173
2218
  to_return(:status => 200, :body => "", :headers => {})
2219
+ stub_elastic_info("https://logs.google.com:777/es//")
2174
2220
 
2175
2221
  driver(config)
2176
2222
 
@@ -2226,6 +2272,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2226
2272
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2227
2273
  with(basic_auth: ['john', 'doe']).
2228
2274
  to_return(:status => 200, :body => "", :headers => {})
2275
+ stub_elastic_info("https://logs.google.com:777/es//")
2229
2276
 
2230
2277
  driver(config)
2231
2278
 
@@ -2278,6 +2325,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2278
2325
  driver(config)
2279
2326
 
2280
2327
  stub_elastic("https://logs.google.com:777/es//_bulk")
2328
+ stub_elastic_info("https://logs.google.com:777/es//")
2281
2329
  driver.run(default_tag: 'test.template') do
2282
2330
  driver.feed(sample_record)
2283
2331
  end
@@ -2329,6 +2377,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2329
2377
  driver(config)
2330
2378
 
2331
2379
  stub_elastic("https://logs-test.google.com:777/es//_bulk")
2380
+ stub_elastic_info("https://logs-test.google.com:777/es//")
2332
2381
  driver.run(default_tag: 'test') do
2333
2382
  driver.feed(sample_record)
2334
2383
  end
@@ -2389,6 +2438,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2389
2438
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/mylogs").
2390
2439
  with(basic_auth: ['john', 'doe']).
2391
2440
  to_return(:status => 200, :body => "", :headers => {})
2441
+ stub_elastic_info("https://logs.google.com:777/es//")
2392
2442
 
2393
2443
  driver(config)
2394
2444
 
@@ -2451,6 +2501,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2451
2501
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/myapp_deflector").
2452
2502
  with(basic_auth: ['john', 'doe']).
2453
2503
  to_return(:status => 200, :body => "", :headers => {})
2504
+ stub_elastic_info("https://logs.google.com:777/es//")
2454
2505
 
2455
2506
  driver(config)
2456
2507
 
@@ -2519,6 +2570,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2519
2570
  driver(config)
2520
2571
 
2521
2572
  elastic_request = stub_elastic("https://logs.google.com:777/es//_bulk")
2573
+ stub_elastic_info("https://logs.google.com:777/es//")
2522
2574
  driver.run(default_tag: 'custom-test') do
2523
2575
  driver.feed(sample_record)
2524
2576
  end
@@ -2618,7 +2670,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2618
2670
  with(basic_auth: ['john', 'doe'],
2619
2671
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
2620
2672
  to_return(:status => 200, :body => "", :headers => {})
2621
-
2673
+ stub_elastic_info("https://logs.google.com:777/es//")
2622
2674
  driver(config)
2623
2675
 
2624
2676
  assert_requested(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs", times: 1)
@@ -2707,6 +2759,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2707
2759
  with(basic_auth: ['john', 'doe'],
2708
2760
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"60gb\",\"max_age\":\"45d\"}}}}}}").
2709
2761
  to_return(:status => 200, :body => "", :headers => {})
2762
+ stub_elastic_info("https://logs.google.com:777/es//")
2710
2763
 
2711
2764
  driver(config)
2712
2765
 
@@ -2736,6 +2789,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2736
2789
  }
2737
2790
 
2738
2791
  # Should raise error because multiple alias indices IllegalArgument Error on executing ILM feature
2792
+ stub_elastic_info("https://logs.google.com:777/es//")
2739
2793
  assert_raise(Fluent::ConfigError) do
2740
2794
  driver(config)
2741
2795
  end
@@ -2871,6 +2925,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2871
2925
  with(basic_auth: ['john', 'doe'],
2872
2926
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
2873
2927
  to_return(:status => 200, :body => "", :headers => {})
2928
+ stub_elastic_info("https://logs.google.com:777/es//")
2874
2929
 
2875
2930
  driver(config)
2876
2931
 
@@ -2961,7 +3016,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2961
3016
  with(basic_auth: ['john', 'doe'],
2962
3017
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
2963
3018
  to_return(:status => 200, :body => "", :headers => {})
2964
-
3019
+ stub_elastic_info("https://logs.google.com:777/es//")
2965
3020
  driver(config)
2966
3021
 
2967
3022
  assert_requested(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs", times: 1)
@@ -3007,6 +3062,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3007
3062
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
3008
3063
  with(basic_auth: ['john', 'doe']).
3009
3064
  to_return(:status => 200, :body => "", :headers => {})
3065
+ stub_elastic_info("https://logs.google.com:777/es//")
3010
3066
 
3011
3067
  driver(config)
3012
3068
 
@@ -3053,6 +3109,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3053
3109
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
3054
3110
  with(basic_auth: ['john', 'doe']).
3055
3111
  to_return(:status => 200, :body => "", :headers => {})
3112
+ stub_elastic_info("https://logs.google.com:777/es//")
3056
3113
 
3057
3114
  driver(config)
3058
3115
 
@@ -3115,6 +3172,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3115
3172
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fd%7D-000001%3E/#{alias_endpoint}/myapp_deflector").
3116
3173
  with(basic_auth: ['john', 'doe']).
3117
3174
  to_return(:status => 200, :body => "", :headers => {})
3175
+ stub_elastic_info("https://logs.google.com:777/es//")
3118
3176
 
3119
3177
  driver(config)
3120
3178
 
@@ -3141,7 +3199,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3141
3199
  stub_request(:get, "https://logs.google.com:777/es//_template/logstash").
3142
3200
  with(basic_auth: ['john', 'doe']).
3143
3201
  to_return(:status => 404, :body => "", :headers => {})
3144
-
3202
+ stub_elastic_info("https://logs.google.com:777/es//")
3145
3203
 
3146
3204
  assert_raise(RuntimeError) {
3147
3205
  driver(config)
@@ -3193,7 +3251,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3193
3251
 
3194
3252
  driver(config)
3195
3253
 
3196
- 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//")
3197
3256
  driver.run(default_tag: 'test') do
3198
3257
  driver.feed(sample_record)
3199
3258
  end
@@ -3233,6 +3292,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3233
3292
  connection_resets += 1
3234
3293
  raise Faraday::ConnectionFailed, "Test message"
3235
3294
  end
3295
+ stub_elastic_info("https://logs.google.com:778/es//")
3236
3296
 
3237
3297
  assert_raise(Fluent::Plugin::ElasticsearchError::RetryableOperationExhaustedFailure) do
3238
3298
  driver(config)
@@ -3274,6 +3334,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3274
3334
  retries += 1
3275
3335
  raise error
3276
3336
  end
3337
+ stub_elastic_info("https://logs.google.com:778/es//")
3277
3338
 
3278
3339
  assert_raise(Fluent::Plugin::ElasticsearchError::RetryableOperationExhaustedFailure) do
3279
3340
  driver(config)
@@ -3317,6 +3378,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3317
3378
  connection_resets += 1
3318
3379
  raise Faraday::ConnectionFailed, "Test message"
3319
3380
  end
3381
+ stub_elastic_info("https://logs.google.com:778/es//")
3320
3382
 
3321
3383
  driver(config)
3322
3384
 
@@ -3372,6 +3434,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3372
3434
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash3").
3373
3435
  with(basic_auth: ['john', 'doe']).
3374
3436
  to_return(:status => 200, :body => "", :headers => {})
3437
+ stub_elastic_info("https://logs.google.com:777/es//")
3375
3438
 
3376
3439
  driver(config)
3377
3440
 
@@ -3429,6 +3492,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3429
3492
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash3").
3430
3493
  with(basic_auth: ['john', 'doe']).
3431
3494
  to_return(:status => 200, :body => "", :headers => {})
3495
+ stub_elastic_info("https://logs.google.com:777/es//")
3432
3496
 
3433
3497
  driver(config)
3434
3498
 
@@ -3487,6 +3551,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3487
3551
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash2").
3488
3552
  with(basic_auth: ['john', 'doe']).
3489
3553
  to_return(:status => 200, :body => "", :headers => {})
3554
+ stub_elastic_info("https://logs.google.com:777/es//")
3490
3555
 
3491
3556
  driver(config)
3492
3557
 
@@ -3537,6 +3602,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3537
3602
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash2").
3538
3603
  with(basic_auth: ['john', 'doe']).
3539
3604
  to_return(:status => 200, :body => "", :headers => {})
3605
+ stub_elastic_info("https://logs.google.com:777/es//")
3540
3606
 
3541
3607
  assert_raise(RuntimeError) {
3542
3608
  driver(config)
@@ -3553,6 +3619,9 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3553
3619
  path /es/
3554
3620
  port 123
3555
3621
  }
3622
+ stub_elastic_info("https://host1:50")
3623
+ stub_elastic_info("https://host2:100")
3624
+ stub_elastic_info("https://host3:123")
3556
3625
  instance = driver(config).instance
3557
3626
 
3558
3627
  assert_equal 3, instance.get_connection_options[:hosts].length
@@ -3575,6 +3644,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3575
3644
  user default_user
3576
3645
  password default_password
3577
3646
  }
3647
+ stub_elastic_info("https://john:password@host1:443/elastic/")
3648
+ stub_elastic_info("http://host2")
3578
3649
  instance = driver(config).instance
3579
3650
 
3580
3651
  assert_equal 2, instance.get_connection_options[:hosts].length
@@ -3601,6 +3672,9 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3601
3672
  user default_user
3602
3673
  password default_password
3603
3674
  }
3675
+ stub_elastic_info("https://j%2Bhn:passw%40rd@host1:443/elastic/")
3676
+ stub_elastic_info("http://host2")
3677
+
3604
3678
  instance = driver(config).instance
3605
3679
 
3606
3680
  assert_equal 2, instance.get_connection_options[:hosts].length
@@ -3801,6 +3875,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3801
3875
  elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
3802
3876
  with(headers: { "Content-Type" => "application/json" })
3803
3877
  end
3878
+ stub_elastic_info
3804
3879
  driver.run(default_tag: 'test') do
3805
3880
  driver.feed(sample_record)
3806
3881
  end
@@ -3812,6 +3887,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3812
3887
  to_return(:status => 200, :body => "", :headers => {})
3813
3888
  elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
3814
3889
  with(headers: {'custom' => 'header1','and_others' => 'header2' })
3890
+ stub_elastic_info
3815
3891
  driver.configure(%[custom_headers {"custom":"header1", "and_others":"header2"}])
3816
3892
  driver.run(default_tag: 'test') do
3817
3893
  driver.feed(sample_record)
@@ -3824,6 +3900,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3824
3900
  to_return(:status => 200, :body => "", :headers => {})
3825
3901
  elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
3826
3902
  with(headers: {'Authorization'=>'ApiKey dGVzdGF1dGhoZWFkZXI='})
3903
+ stub_elastic_info
3827
3904
  driver.configure(%[api_key testauthheader])
3828
3905
  driver.run(default_tag: 'test') do
3829
3906
  driver.feed(sample_record)
@@ -3834,6 +3911,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3834
3911
  def test_write_message_with_bad_chunk
3835
3912
  driver.configure("target_index_key bad_value\n@log_level debug\n")
3836
3913
  stub_elastic
3914
+ stub_elastic_info
3837
3915
  driver.run(default_tag: 'test') do
3838
3916
  driver.feed({'bad_value'=>"\255"})
3839
3917
  end
@@ -3849,6 +3927,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3849
3927
  def test_writes_to_default_index(data)
3850
3928
  version, index_name = data
3851
3929
  stub_elastic
3930
+ stub_elastic_info
3852
3931
  driver("", version)
3853
3932
  driver.run(default_tag: 'test') do
3854
3933
  driver.feed(sample_record)
@@ -3890,6 +3969,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3890
3969
 
3891
3970
  elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
3892
3971
  to_return(:status => 200, :headers => {'Content-Type' => 'Application/json'}, :body => compressed_body)
3972
+ stub_elastic_info("http://localhost:9200/")
3893
3973
 
3894
3974
  driver(config)
3895
3975
  driver.run(default_tag: 'test') do
@@ -3906,6 +3986,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3906
3986
  def test_writes_to_default_type(data)
3907
3987
  version, index_type = data
3908
3988
  stub_elastic
3989
+ stub_elastic_info
3909
3990
  driver("", version)
3910
3991
  driver.run(default_tag: 'test') do
3911
3992
  driver.feed(sample_record)
@@ -3916,6 +3997,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3916
3997
  def test_writes_to_speficied_index
3917
3998
  driver.configure("index_name myindex\n")
3918
3999
  stub_elastic
4000
+ stub_elastic_info
3919
4001
  driver.run(default_tag: 'test') do
3920
4002
  driver.feed(sample_record)
3921
4003
  end
@@ -3935,6 +4017,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3935
4017
  ]
3936
4018
  ))
3937
4019
  request = stub_elastic
4020
+ stub_elastic_info
3938
4021
  driver.run(default_tag: 'test') do
3939
4022
  driver.feed(sample_record('huge_record' => ("a" * 20 * 1024 * 1024)))
3940
4023
  driver.feed(sample_record('huge_record' => ("a" * 20 * 1024 * 1024)))
@@ -3959,6 +4042,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3959
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|
3960
4043
  @index_cmds = req.body.split("\n").map {|r| JSON.parse(r) }
3961
4044
  end
4045
+ stub_elastic_info
3962
4046
  driver.run(default_tag: 'test', shutdown: false) do
3963
4047
  driver.feed(sample_record)
3964
4048
  end
@@ -3988,6 +4072,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3988
4072
  ]
3989
4073
  ))
3990
4074
  request = stub_elastic
4075
+ stub_elastic_info
3991
4076
  driver.run(default_tag: 'test') do
3992
4077
  driver.feed(sample_record('huge_record' => ("a" * 20 * 1024 * 1024)))
3993
4078
  driver.feed(sample_record('huge_record' => ("a" * 20 * 1024 * 1024)))
@@ -4000,6 +4085,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4000
4085
  def test_writes_to_speficied_index_with_tag_placeholder
4001
4086
  driver.configure("index_name myindex.${tag}\n")
4002
4087
  stub_elastic
4088
+ stub_elastic_info
4003
4089
  driver.run(default_tag: 'test') do
4004
4090
  driver.feed(sample_record)
4005
4091
  end
@@ -4019,6 +4105,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4019
4105
  ]
4020
4106
  ))
4021
4107
  stub_elastic
4108
+ stub_elastic_info
4022
4109
  time = Time.parse Date.today.iso8601
4023
4110
  driver.run(default_tag: 'test') do
4024
4111
  driver.feed(time.to_i, sample_record)
@@ -4039,6 +4126,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4039
4126
  pipeline_id = "mypipeline"
4040
4127
  logstash_index = "myindex.#{pipeline_id}"
4041
4128
  stub_elastic
4129
+ stub_elastic_info
4042
4130
  driver.run(default_tag: 'test') do
4043
4131
  driver.feed(time.to_i, sample_record.merge({"pipeline_id" => pipeline_id}))
4044
4132
  end
@@ -4049,6 +4137,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4049
4137
  def test_writes_to_speficied_index_uppercase
4050
4138
  driver.configure("index_name MyIndex\n")
4051
4139
  stub_elastic
4140
+ stub_elastic_info
4052
4141
  driver.run(default_tag: 'test') do
4053
4142
  driver.feed(sample_record)
4054
4143
  end
@@ -4060,6 +4149,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4060
4149
  def test_writes_to_target_index_key
4061
4150
  driver.configure("target_index_key @target_index\n")
4062
4151
  stub_elastic
4152
+ stub_elastic_info
4063
4153
  record = sample_record.clone
4064
4154
  driver.run(default_tag: 'test') do
4065
4155
  driver.feed(sample_record.merge('@target_index' => 'local-override'))
@@ -4073,17 +4163,19 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4073
4163
  logstash_format true")
4074
4164
  time = Time.parse Date.today.iso8601
4075
4165
  stub_elastic
4166
+ stub_elastic_info
4076
4167
  driver.run(default_tag: 'test') do
4077
4168
  driver.feed(time.to_i, sample_record.merge('@target_index' => 'local-override'))
4078
4169
  end
4079
4170
  assert_equal('local-override', index_cmds.first['index']['_index'])
4080
4171
  end
4081
4172
 
4082
- def test_writes_to_target_index_key_logstash_uppercase
4173
+ def test_writes_to_target_index_key_logstash_uppercase
4083
4174
  driver.configure("target_index_key @target_index
4084
4175
  logstash_format true")
4085
4176
  time = Time.parse Date.today.iso8601
4086
4177
  stub_elastic
4178
+ stub_elastic_info
4087
4179
  driver.run(default_tag: 'test') do
4088
4180
  driver.feed(time.to_i, sample_record.merge('@target_index' => 'LOCAL-OVERRIDE'))
4089
4181
  end
@@ -4096,6 +4188,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4096
4188
  pipeline = "fluentd"
4097
4189
  driver.configure("pipeline #{pipeline}")
4098
4190
  stub_elastic
4191
+ stub_elastic_info
4099
4192
  driver.run(default_tag: 'test') do
4100
4193
  driver.feed(sample_record)
4101
4194
  end
@@ -4192,6 +4285,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4192
4285
  ids = [my_id_value]
4193
4286
  indices = ["logstash-2021.04.28"]
4194
4287
  stub_elastic
4288
+ stub_elastic_info
4195
4289
  stub_elastic_affinity_target_index_search(ids, indices)
4196
4290
  driver.run(default_tag: 'test') do
4197
4291
  driver.feed(sample_record('my_id' => my_id_value))
@@ -4209,6 +4303,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4209
4303
  ids = [my_id_value]
4210
4304
  indices = ["logstash-2021.04.28"]
4211
4305
  stub_elastic
4306
+ stub_elastic_info
4212
4307
  stub_elastic_affinity_target_index_search(ids, indices)
4213
4308
  driver.run(default_tag: 'test') do
4214
4309
  driver.feed(sample_record('my_id' => my_id_value))
@@ -4225,6 +4320,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4225
4320
  my_id_value = "3408a2c8eecd4fbfb82e45012b54fa82"
4226
4321
  ids = [my_id_value]
4227
4322
  stub_elastic
4323
+ stub_elastic_info
4228
4324
  stub_elastic_affinity_target_index_search_return_empty(ids)
4229
4325
  time = Time.parse Date.today.iso8601
4230
4326
  driver.run(default_tag: 'test') do
@@ -4243,6 +4339,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4243
4339
  my_id_value2 = "3408a2c8eecd4fbfb82e45012b54fa82"
4244
4340
  ids = [my_id_value, my_id_value2]
4245
4341
  indices = ["logstash-2021.04.29", "logstash-2021.04.28"]
4342
+ stub_elastic_info
4246
4343
  stub_elastic_all_requests
4247
4344
  stub_elastic_affinity_target_index_search(ids, indices)
4248
4345
  driver.run(default_tag: 'test') do
@@ -4268,6 +4365,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4268
4365
  # Simulate the used sorting here, as search sorts indices in DESC order to pick only oldest index per single _id
4269
4366
  indices = ["logstash-2021.04.29", "logstash-2021.04.28"]
4270
4367
 
4368
+ stub_elastic_info
4271
4369
  stub_elastic_all_requests
4272
4370
  stub_elastic_affinity_target_index_search(ids, indices)
4273
4371
  driver.run(default_tag: 'test') do
@@ -4286,6 +4384,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4286
4384
  pipeline = "fluentd-${tag}"
4287
4385
  driver.configure("pipeline #{pipeline}")
4288
4386
  stub_elastic
4387
+ stub_elastic_info
4289
4388
  driver.run(default_tag: 'test.builtin.placeholder') do
4290
4389
  driver.feed(sample_record)
4291
4390
  end
@@ -4307,6 +4406,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4307
4406
  time = Time.parse Date.today.iso8601
4308
4407
  pipeline = "fluentd-#{time.getutc.strftime("%Y%m%d")}"
4309
4408
  stub_elastic
4409
+ stub_elastic_info
4310
4410
  driver.run(default_tag: 'test') do
4311
4411
  driver.feed(time.to_i, sample_record)
4312
4412
  end
@@ -4326,6 +4426,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4326
4426
  pipeline_id = "mypipeline"
4327
4427
  logstash_index = "fluentd-#{pipeline_id}"
4328
4428
  stub_elastic
4429
+ stub_elastic_info
4329
4430
  driver.run(default_tag: 'test') do
4330
4431
  driver.feed(time.to_i, sample_record.merge({"pipeline_id" => pipeline_id}))
4331
4432
  end
@@ -4336,6 +4437,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4336
4437
  def test_writes_to_target_index_key_fallack
4337
4438
  driver.configure("target_index_key @target_index\n")
4338
4439
  stub_elastic
4440
+ stub_elastic_info
4339
4441
  driver.run(default_tag: 'test') do
4340
4442
  driver.feed(sample_record)
4341
4443
  end
@@ -4348,6 +4450,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4348
4450
  time = Time.parse Date.today.iso8601
4349
4451
  logstash_index = "logstash-#{time.getutc.strftime("%Y.%m.%d")}"
4350
4452
  stub_elastic
4453
+ stub_elastic_info
4351
4454
  driver.run(default_tag: 'test') do
4352
4455
  driver.feed(time.to_i, sample_record)
4353
4456
  end
@@ -4361,6 +4464,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4361
4464
  def test_writes_to_speficied_type(data)
4362
4465
  driver('', data["es_version"]).configure("type_name mytype\n")
4363
4466
  stub_elastic
4467
+ stub_elastic_info
4364
4468
  driver.run(default_tag: 'test') do
4365
4469
  driver.feed(sample_record)
4366
4470
  end
@@ -4374,6 +4478,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4374
4478
  def test_writes_to_speficied_type_with_placeholders(data)
4375
4479
  driver('', data["es_version"]).configure("type_name mytype.${tag}\n")
4376
4480
  stub_elastic
4481
+ stub_elastic_info
4377
4482
  driver.run(default_tag: 'test') do
4378
4483
  driver.feed(sample_record)
4379
4484
  end
@@ -4388,6 +4493,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4388
4493
  driver('', data["es_version"])
4389
4494
  .configure("type_name mytype.${tag}\nsuppress_type_name true")
4390
4495
  stub_elastic
4496
+ stub_elastic_info
4391
4497
  driver.run(default_tag: 'test') do
4392
4498
  driver.feed(sample_record)
4393
4499
  end
@@ -4402,6 +4508,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4402
4508
  def test_writes_to_target_type_key(data)
4403
4509
  driver('', data["es_version"]).configure("target_type_key @target_type\n")
4404
4510
  stub_elastic
4511
+ stub_elastic_info
4405
4512
  record = sample_record.clone
4406
4513
  driver.run(default_tag: 'test') do
4407
4514
  driver.feed(sample_record.merge('@target_type' => 'local-override'))
@@ -4413,6 +4520,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4413
4520
  def test_writes_to_target_type_key_fallack_to_default
4414
4521
  driver.configure("target_type_key @target_type\n")
4415
4522
  stub_elastic
4523
+ stub_elastic_info
4416
4524
  driver.run(default_tag: 'test') do
4417
4525
  driver.feed(sample_record)
4418
4526
  end
@@ -4423,6 +4531,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4423
4531
  driver.configure("target_type_key @target_type
4424
4532
  type_name mytype")
4425
4533
  stub_elastic
4534
+ stub_elastic_info
4426
4535
  driver.run(default_tag: 'test') do
4427
4536
  driver.feed(sample_record)
4428
4537
  end
@@ -4437,6 +4546,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4437
4546
  def test_writes_to_target_type_key_nested(data)
4438
4547
  driver('', data["es_version"]).configure("target_type_key kubernetes.labels.log_type\n")
4439
4548
  stub_elastic
4549
+ stub_elastic_info
4440
4550
  driver.run(default_tag: 'test') do
4441
4551
  driver.feed(sample_record.merge('kubernetes' => {
4442
4552
  'labels' => {
@@ -4451,6 +4561,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4451
4561
  def test_writes_to_target_type_key_fallack_to_default_nested
4452
4562
  driver.configure("target_type_key kubernetes.labels.log_type\n")
4453
4563
  stub_elastic
4564
+ stub_elastic_info
4454
4565
  driver.run(default_tag: 'test') do
4455
4566
  driver.feed(sample_record.merge('kubernetes' => {
4456
4567
  'labels' => {
@@ -4464,6 +4575,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4464
4575
  def test_writes_to_speficied_host
4465
4576
  driver.configure("host 192.168.33.50\n")
4466
4577
  elastic_request = stub_elastic("http://192.168.33.50:9200/_bulk")
4578
+ stub_elastic_info("http://192.168.33.50:9200/")
4467
4579
  driver.run(default_tag: 'test') do
4468
4580
  driver.feed(sample_record)
4469
4581
  end
@@ -4473,6 +4585,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4473
4585
  def test_writes_to_speficied_port
4474
4586
  driver.configure("port 9201\n")
4475
4587
  elastic_request = stub_elastic("http://localhost:9201/_bulk")
4588
+ stub_elastic_info("http://localhost:9201")
4476
4589
  driver.run(default_tag: 'test') do
4477
4590
  driver.feed(sample_record)
4478
4591
  end
@@ -4488,6 +4601,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4488
4601
  hosts.each do |host_info|
4489
4602
  host, port = host_info
4490
4603
  stub_elastic_with_store_index_command_counts("http://#{host}:#{port}/_bulk")
4604
+ stub_elastic_info("http://#{host}:#{port}/")
4491
4605
  end
4492
4606
 
4493
4607
  driver.run(default_tag: 'test') do
@@ -4524,6 +4638,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4524
4638
  ]}
4525
4639
 
4526
4640
  stub_elastic
4641
+ stub_elastic_info
4527
4642
  driver.run(default_tag: 'test') do
4528
4643
  driver.feed(original_hash)
4529
4644
  end
@@ -4537,6 +4652,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4537
4652
  expected_output = {"foo" => {"bar" => "baz"}}
4538
4653
 
4539
4654
  stub_elastic
4655
+ stub_elastic_info
4540
4656
  driver.run(default_tag: 'test') do
4541
4657
  driver.feed(original_hash)
4542
4658
  end
@@ -4545,6 +4661,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4545
4661
 
4546
4662
  def test_makes_bulk_request
4547
4663
  stub_elastic
4664
+ stub_elastic_info
4548
4665
  driver.run(default_tag: 'test') do
4549
4666
  driver.feed(sample_record)
4550
4667
  driver.feed(sample_record.merge('age' => 27))
@@ -4552,8 +4669,9 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4552
4669
  assert_equal(4, index_cmds.count)
4553
4670
  end
4554
4671
 
4555
- def test_all_records_are_preserved_in_bulk
4672
+ def test_all_re
4556
4673
  stub_elastic
4674
+ stub_elastic_info
4557
4675
  driver.run(default_tag: 'test') do
4558
4676
  driver.feed(sample_record)
4559
4677
  driver.feed(sample_record.merge('age' => 27))
@@ -4569,6 +4687,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4569
4687
  dt = DateTime.new(2015, 6, 1, 0, 0, 1, "+01:00")
4570
4688
  logstash_index = "logstash-2015.05.31"
4571
4689
  stub_elastic
4690
+ stub_elastic_info
4572
4691
  driver.run(default_tag: 'test') do
4573
4692
  driver.feed(dt.to_time.to_i, sample_record)
4574
4693
  end
@@ -4583,6 +4702,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4583
4702
  time = Date.today.to_time
4584
4703
  index = "logstash-#{time.strftime("%Y.%m.%d")}"
4585
4704
  stub_elastic
4705
+ stub_elastic_info
4586
4706
  driver.run(default_tag: 'test') do
4587
4707
  driver.feed(time.to_i, sample_record)
4588
4708
  end
@@ -4595,6 +4715,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4595
4715
  time = Time.parse Date.today.iso8601
4596
4716
  logstash_index = "myprefix-#{time.getutc.strftime("%Y.%m.%d")}"
4597
4717
  stub_elastic
4718
+ stub_elastic_info
4598
4719
  driver.run(default_tag: 'test') do
4599
4720
  driver.feed(time.to_i, sample_record)
4600
4721
  end
@@ -4609,6 +4730,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4609
4730
  time = Time.parse Date.today.iso8601
4610
4731
  logstash_index = "myprefix#{separator}#{time.getutc.strftime("%Y.%m.%d")}"
4611
4732
  stub_elastic
4733
+ stub_elastic_info
4612
4734
  driver.run(default_tag: 'test') do
4613
4735
  driver.feed(time.to_i, sample_record)
4614
4736
  end
@@ -4622,6 +4744,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4622
4744
  time = Time.parse Date.today.iso8601
4623
4745
  logstash_index = "myprefix-test-#{time.getutc.strftime("%Y.%m.%d")}"
4624
4746
  stub_elastic
4747
+ stub_elastic_info
4625
4748
  driver.run(default_tag: 'test') do
4626
4749
  driver.feed(time.to_i, sample_record)
4627
4750
  end
@@ -4644,6 +4767,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4644
4767
  time = Time.parse Date.today.iso8601
4645
4768
  logstash_index = "myprefix-#{time.getutc.strftime("%H")}-#{time.getutc.strftime("%Y.%m.%d")}"
4646
4769
  stub_elastic
4770
+ stub_elastic_info
4647
4771
  driver.run(default_tag: 'test') do
4648
4772
  driver.feed(time.to_i, sample_record)
4649
4773
  end
@@ -4664,6 +4788,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4664
4788
  pipeline_id = "mypipeline"
4665
4789
  logstash_index = "myprefix-#{pipeline_id}-#{time.getutc.strftime("%Y.%m.%d")}"
4666
4790
  stub_elastic
4791
+ stub_elastic_info
4667
4792
  driver.run(default_tag: 'test') do
4668
4793
  driver.feed(time.to_i, sample_record.merge({"pipeline_id" => pipeline_id}))
4669
4794
  end
@@ -4689,6 +4814,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4689
4814
  time = Time.parse Date.today.iso8601
4690
4815
  logstash_index = "myprefix-#{time.getutc.strftime("%Y.%m.%d")}"
4691
4816
  stub_elastic
4817
+ stub_elastic_info
4692
4818
  driver.run(default_tag: 'test') do
4693
4819
  driver.feed(time.to_i, sample_record.merge('indexformat' => '%Y.%m.%d'))
4694
4820
  end
@@ -4712,6 +4838,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4712
4838
  time = Time.parse Date.today.iso8601
4713
4839
  logstash_index = "myprefix-#{time.getutc.strftime("%Y.%m")}"
4714
4840
  stub_elastic
4841
+ stub_elastic_info
4715
4842
  driver.run(default_tag: 'test') do
4716
4843
  driver.feed(time.to_i, sample_record.merge('indexformat' => '%Y.%m'))
4717
4844
  end
@@ -4724,6 +4851,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4724
4851
  driver.configure("host ${tag}\n")
4725
4852
  time = Time.parse Date.today.iso8601
4726
4853
  elastic_request = stub_elastic("http://extracted-host:9200/_bulk")
4854
+ stub_elastic_info("http://extracted-host:9200/")
4727
4855
  driver.run(default_tag: 'extracted-host') do
4728
4856
  driver.feed(time.to_i, sample_record)
4729
4857
  end
@@ -4740,6 +4868,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4740
4868
  host, port = host_info
4741
4869
  host = "extracted-host" if host == '${tag}'
4742
4870
  stub_elastic_with_store_index_command_counts("http://#{host}:#{port}/_bulk")
4871
+ stub_elastic_info("http://#{host}:#{port}")
4743
4872
  end
4744
4873
 
4745
4874
  driver.run(default_tag: 'extracted-host') do
@@ -4774,8 +4903,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4774
4903
  ]
4775
4904
  ))
4776
4905
  stub_elastic
4906
+ stub_elastic_info
4777
4907
  time = Time.parse Date.today.iso8601
4778
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/")
4779
4910
  driver.run(default_tag: 'test') do
4780
4911
  driver.feed(time.to_i, sample_record)
4781
4912
  end
@@ -4796,6 +4927,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4796
4927
  second_pipeline_id = "2"
4797
4928
  first_request = stub_elastic("http://myhost-1:9200/_bulk")
4798
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/")
4799
4932
  driver.run(default_tag: 'test') do
4800
4933
  driver.feed(time.to_i, sample_record.merge({"pipeline_id" => first_pipeline_id}))
4801
4934
  driver.feed(time.to_i, sample_record.merge({"pipeline_id" => second_pipeline_id}))
@@ -4816,6 +4949,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4816
4949
  time = Time.parse Date.today.iso8601
4817
4950
  pipeline_id = "1"
4818
4951
  request = stub_elastic_unavailable("http://myhost-1:9200/_bulk")
4952
+ stub_elastic_info("http://myhost-1:9200/")
4819
4953
  exception = assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) {
4820
4954
  driver.run(default_tag: 'test') do
4821
4955
  driver.feed(time.to_i, sample_record.merge({"pipeline_id" => pipeline_id}))
@@ -4831,6 +4965,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4831
4965
  time = Time.parse Date.today.iso8601
4832
4966
  logstash_index = "myprefix-#{time.getutc.strftime("%Y.%m.%d")}"
4833
4967
  stub_elastic
4968
+ stub_elastic_info
4834
4969
  driver.run(default_tag: 'test') do
4835
4970
  driver.feed(time.to_i, sample_record)
4836
4971
  end
@@ -4845,6 +4980,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4845
4980
  time = Time.parse Date.today.iso8601
4846
4981
  logstash_index = "logstash-#{time.getutc.strftime("%Y.%m")}"
4847
4982
  stub_elastic
4983
+ stub_elastic_info
4848
4984
  driver.run(default_tag: 'test') do
4849
4985
  driver.feed(time.to_i, sample_record)
4850
4986
  end
@@ -4858,6 +4994,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4858
4994
  time = Time.parse Date.today.iso8601
4859
4995
  logstash_index = "myprefix-#{time.getutc.strftime("%Y.%m")}"
4860
4996
  stub_elastic
4997
+ stub_elastic_info
4861
4998
  driver.run(default_tag: 'test') do
4862
4999
  driver.feed(time.to_i, sample_record)
4863
5000
  end
@@ -4884,6 +5021,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4884
5021
 
4885
5022
  def test_doesnt_add_logstash_timestamp_by_default
4886
5023
  stub_elastic
5024
+ stub_elastic_info
4887
5025
  driver.run(default_tag: 'test') do
4888
5026
  driver.feed(sample_record)
4889
5027
  end
@@ -4893,6 +5031,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4893
5031
  def test_adds_timestamp_when_logstash
4894
5032
  driver.configure("logstash_format true\n")
4895
5033
  stub_elastic
5034
+ stub_elastic_info
4896
5035
  ts = DateTime.now
4897
5036
  time = Fluent::EventTime.from_time(ts.to_time)
4898
5037
  driver.run(default_tag: 'test') do
@@ -4905,6 +5044,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4905
5044
  def test_adds_timestamp_when_include_timestamp
4906
5045
  driver.configure("include_timestamp true\n")
4907
5046
  stub_elastic
5047
+ stub_elastic_info
4908
5048
  ts = DateTime.now
4909
5049
  time = Fluent::EventTime.from_time(ts.to_time)
4910
5050
  driver.run(default_tag: 'test') do
@@ -4917,6 +5057,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4917
5057
  def test_uses_custom_timestamp_when_included_in_record
4918
5058
  driver.configure("logstash_format true\n")
4919
5059
  stub_elastic
5060
+ stub_elastic_info
4920
5061
  ts = DateTime.new(2001,2,3).iso8601
4921
5062
  driver.run(default_tag: 'test') do
4922
5063
  driver.feed(sample_record.merge!('@timestamp' => ts))
@@ -4928,6 +5069,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4928
5069
  def test_uses_custom_timestamp_when_included_in_record_without_logstash
4929
5070
  driver.configure("include_timestamp true\n")
4930
5071
  stub_elastic
5072
+ stub_elastic_info
4931
5073
  ts = DateTime.new(2001,2,3).iso8601
4932
5074
  driver.run(default_tag: 'test') do
4933
5075
  driver.feed(sample_record.merge!('@timestamp' => ts))
@@ -4940,6 +5082,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4940
5082
  driver.configure("logstash_format true
4941
5083
  time_key vtm\n")
4942
5084
  stub_elastic
5085
+ stub_elastic_info
4943
5086
  ts = DateTime.new(2001,2,3).iso8601(9)
4944
5087
  driver.run(default_tag: 'test') do
4945
5088
  driver.feed(sample_record.merge!('vtm' => ts))
@@ -4953,6 +5096,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4953
5096
  time_precision 3
4954
5097
  time_key vtm\n")
4955
5098
  stub_elastic
5099
+ stub_elastic_info
4956
5100
  time = Time.now
4957
5101
  float_time = time.to_f
4958
5102
  driver.run(default_tag: 'test') do
@@ -4967,6 +5111,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4967
5111
  time_key_format %Y-%m-%d %H:%M:%S.%N%z
4968
5112
  time_key vtm\n")
4969
5113
  stub_elastic
5114
+ stub_elastic_info
4970
5115
  ts = "2001-02-03 13:14:01.673+02:00"
4971
5116
  driver.run(default_tag: 'test') do
4972
5117
  driver.feed(sample_record.merge!('vtm' => ts))
@@ -4981,6 +5126,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4981
5126
  time_key_format %Y-%m-%d %H:%M:%S.%N%z
4982
5127
  time_key vtm\n")
4983
5128
  stub_elastic
5129
+ stub_elastic_info
4984
5130
  ts = "2001-02-03 13:14:01.673+02:00"
4985
5131
  time = Time.parse(ts)
4986
5132
  current_zone_offset = Time.new(2001, 02, 03).to_datetime.offset
@@ -4998,6 +5144,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4998
5144
  time_key_format %Y-%m-%d %H:%M:%S.%N%z
4999
5145
  time_key vtm\n")
5000
5146
  stub_elastic
5147
+ stub_elastic_info
5001
5148
  ts = "2001-02-03 13:14:01.673+02:00"
5002
5149
  driver.run(default_tag: 'test') do
5003
5150
  driver.feed(sample_record.merge!('vtm' => ts))
@@ -5012,6 +5159,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5012
5159
  time_key vtm
5013
5160
  time_key_exclude_timestamp true\n")
5014
5161
  stub_elastic
5162
+ stub_elastic_info
5015
5163
  ts = DateTime.new(2001,2,3).iso8601
5016
5164
  driver.run(default_tag: 'test') do
5017
5165
  driver.feed(sample_record.merge!('vtm' => ts))
@@ -5023,6 +5171,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5023
5171
  driver.configure("logstash_format true
5024
5172
  time_key_format %Y-%m-%dT%H:%M:%S.%N%z\n")
5025
5173
  stub_elastic
5174
+ stub_elastic_info
5026
5175
  ts = "2001-02-03T13:14:01.673+02:00"
5027
5176
  driver.run(default_tag: 'test') do
5028
5177
  driver.feed(sample_record.merge!('@timestamp' => ts))
@@ -5037,6 +5186,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5037
5186
  index_name test
5038
5187
  time_key_format %Y-%m-%dT%H:%M:%S.%N%z\n")
5039
5188
  stub_elastic
5189
+ stub_elastic_info
5040
5190
  ts = "2001-02-03T13:14:01.673+02:00"
5041
5191
  driver.run(default_tag: 'test') do
5042
5192
  driver.feed(sample_record.merge!('@timestamp' => ts))
@@ -5054,6 +5204,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5054
5204
  driver.configure("logstash_format true
5055
5205
  time_key_format %Y-%m-%dT%H:%M:%S.%N%z\n#{tag_config}\n")
5056
5206
  stub_elastic
5207
+ stub_elastic_info
5057
5208
 
5058
5209
  ts = "2001/02/03 13:14:01,673+02:00"
5059
5210
  index = "logstash-#{Time.now.getutc.strftime("%Y.%m.%d")}"
@@ -5074,6 +5225,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5074
5225
  driver.configure("logstash_format true
5075
5226
  time_key_format %a %b %d %H:%M:%S %Z %Y\n")
5076
5227
  stub_elastic
5228
+ stub_elastic_info
5077
5229
  ts = "Thu Nov 29 14:33:20 GMT 2001"
5078
5230
  driver.run(default_tag: 'test') do
5079
5231
  driver.feed(sample_record.merge!('@timestamp' => ts))
@@ -5086,6 +5238,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5086
5238
  def test_uses_nanosecond_precision_by_default
5087
5239
  driver.configure("logstash_format true\n")
5088
5240
  stub_elastic
5241
+ stub_elastic_info
5089
5242
  time = Fluent::EventTime.new(Time.now.to_i, 123456789)
5090
5243
  driver.run(default_tag: 'test') do
5091
5244
  driver.feed(time, sample_record)
@@ -5098,6 +5251,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5098
5251
  driver.configure("logstash_format true
5099
5252
  time_precision 3\n")
5100
5253
  stub_elastic
5254
+ stub_elastic_info
5101
5255
  time = Fluent::EventTime.new(Time.now.to_i, 123456789)
5102
5256
  driver.run(default_tag: 'test') do
5103
5257
  driver.feed(time, sample_record)
@@ -5108,6 +5262,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5108
5262
 
5109
5263
  def test_doesnt_add_tag_key_by_default
5110
5264
  stub_elastic
5265
+ stub_elastic_info
5111
5266
  driver.run(default_tag: 'test') do
5112
5267
  driver.feed(sample_record)
5113
5268
  end
@@ -5117,6 +5272,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5117
5272
  def test_adds_tag_key_when_configured
5118
5273
  driver.configure("include_tag_key true\n")
5119
5274
  stub_elastic
5275
+ stub_elastic_info
5120
5276
  driver.run(default_tag: 'mytag') do
5121
5277
  driver.feed(sample_record)
5122
5278
  end
@@ -5127,6 +5283,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5127
5283
  def test_adds_id_key_when_configured
5128
5284
  driver.configure("id_key request_id\n")
5129
5285
  stub_elastic
5286
+ stub_elastic_info
5130
5287
  driver.run(default_tag: 'test') do
5131
5288
  driver.feed(sample_record)
5132
5289
  end
@@ -5137,6 +5294,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5137
5294
  def test_adds_nested_id_key_with_dot
5138
5295
  driver.configure("id_key nested.request_id\n")
5139
5296
  stub_elastic
5297
+ stub_elastic_info
5140
5298
  driver.run(default_tag: 'test') do
5141
5299
  driver.feed(nested_sample_record)
5142
5300
  end
@@ -5146,6 +5304,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5146
5304
  def test_adds_nested_id_key_with_dollar_dot
5147
5305
  driver.configure("id_key $.nested.request_id\n")
5148
5306
  stub_elastic
5307
+ stub_elastic_info
5149
5308
  driver.run(default_tag: 'test') do
5150
5309
  driver.feed(nested_sample_record)
5151
5310
  end
@@ -5155,6 +5314,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5155
5314
  def test_adds_nested_id_key_with_bracket
5156
5315
  driver.configure("id_key $['nested']['request_id']\n")
5157
5316
  stub_elastic
5317
+ stub_elastic_info
5158
5318
  driver.run(default_tag: 'test') do
5159
5319
  driver.feed(nested_sample_record)
5160
5320
  end
@@ -5165,6 +5325,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5165
5325
  def test_doesnt_add_id_key_if_missing_when_configured
5166
5326
  driver.configure("id_key another_request_id\n")
5167
5327
  stub_elastic
5328
+ stub_elastic_info
5168
5329
  driver.run(default_tag: 'test') do
5169
5330
  driver.feed(sample_record)
5170
5331
  end
@@ -5173,6 +5334,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5173
5334
 
5174
5335
  def test_adds_id_key_when_not_configured
5175
5336
  stub_elastic
5337
+ stub_elastic_info
5176
5338
  driver.run(default_tag: 'test') do
5177
5339
  driver.feed(sample_record)
5178
5340
  end
@@ -5182,6 +5344,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5182
5344
  def test_adds_parent_key_when_configured
5183
5345
  driver.configure("parent_key parent_id\n")
5184
5346
  stub_elastic
5347
+ stub_elastic_info
5185
5348
  driver.run(default_tag: 'test') do
5186
5349
  driver.feed(sample_record)
5187
5350
  end
@@ -5192,6 +5355,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5192
5355
  def test_adds_nested_parent_key_with_dot
5193
5356
  driver.configure("parent_key nested.parent_id\n")
5194
5357
  stub_elastic
5358
+ stub_elastic_info
5195
5359
  driver.run(default_tag: 'test') do
5196
5360
  driver.feed(nested_sample_record)
5197
5361
  end
@@ -5201,6 +5365,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5201
5365
  def test_adds_nested_parent_key_with_dollar_dot
5202
5366
  driver.configure("parent_key $.nested.parent_id\n")
5203
5367
  stub_elastic
5368
+ stub_elastic_info
5204
5369
  driver.run(default_tag: 'test') do
5205
5370
  driver.feed(nested_sample_record)
5206
5371
  end
@@ -5210,6 +5375,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5210
5375
  def test_adds_nested_parent_key_with_bracket
5211
5376
  driver.configure("parent_key $['nested']['parent_id']\n")
5212
5377
  stub_elastic
5378
+ stub_elastic_info
5213
5379
  driver.run(default_tag: 'test') do
5214
5380
  driver.feed(nested_sample_record)
5215
5381
  end
@@ -5220,6 +5386,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5220
5386
  def test_doesnt_add_parent_key_if_missing_when_configured
5221
5387
  driver.configure("parent_key another_parent_id\n")
5222
5388
  stub_elastic
5389
+ stub_elastic_info
5223
5390
  driver.run(default_tag: 'test') do
5224
5391
  driver.feed(sample_record)
5225
5392
  end
@@ -5228,6 +5395,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5228
5395
 
5229
5396
  def test_adds_parent_key_when_not_configured
5230
5397
  stub_elastic
5398
+ stub_elastic_info
5231
5399
  driver.run(default_tag: 'test') do
5232
5400
  driver.feed(sample_record)
5233
5401
  end
@@ -5238,6 +5406,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5238
5406
  def test_es6
5239
5407
  driver("routing_key routing_id\n", 6)
5240
5408
  stub_elastic
5409
+ stub_elastic_info
5241
5410
  driver.run(default_tag: 'test') do
5242
5411
  driver.feed(sample_record)
5243
5412
  end
@@ -5247,6 +5416,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5247
5416
  def test_es7
5248
5417
  driver("routing_key routing_id\n", 7)
5249
5418
  stub_elastic
5419
+ stub_elastic_info
5250
5420
  driver.run(default_tag: 'test') do
5251
5421
  driver.feed(sample_record)
5252
5422
  end
@@ -5258,6 +5428,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5258
5428
  def test_adds_nested_routing_key_with_dot
5259
5429
  driver.configure("routing_key nested.routing_id\n")
5260
5430
  stub_elastic
5431
+ stub_elastic_info
5261
5432
  driver.run(default_tag: 'test') do
5262
5433
  driver.feed(nested_sample_record)
5263
5434
  end
@@ -5267,6 +5438,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5267
5438
  def test_adds_nested_routing_key_with_dollar_dot
5268
5439
  driver.configure("routing_key $.nested.routing_id\n")
5269
5440
  stub_elastic
5441
+ stub_elastic_info
5270
5442
  driver.run(default_tag: 'test') do
5271
5443
  driver.feed(nested_sample_record)
5272
5444
  end
@@ -5276,6 +5448,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5276
5448
  def test_adds_nested_routing_key_with_bracket
5277
5449
  driver.configure("routing_key $['nested']['routing_id']\n")
5278
5450
  stub_elastic
5451
+ stub_elastic_info
5279
5452
  driver.run(default_tag: 'test') do
5280
5453
  driver.feed(nested_sample_record)
5281
5454
  end
@@ -5286,6 +5459,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5286
5459
  def test_doesnt_add_routing_key_if_missing_when_configured
5287
5460
  driver.configure("routing_key another_routing_id\n")
5288
5461
  stub_elastic
5462
+ stub_elastic_info
5289
5463
  driver.run(default_tag: 'test') do
5290
5464
  driver.feed(sample_record)
5291
5465
  end
@@ -5294,6 +5468,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5294
5468
 
5295
5469
  def test_adds_routing_key_when_not_configured
5296
5470
  stub_elastic
5471
+ stub_elastic_info
5297
5472
  driver.run(default_tag: 'test') do
5298
5473
  driver.feed(sample_record)
5299
5474
  end
@@ -5303,6 +5478,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5303
5478
  def test_remove_one_key
5304
5479
  driver.configure("remove_keys key1\n")
5305
5480
  stub_elastic
5481
+ stub_elastic_info
5306
5482
  driver.run(default_tag: 'test') do
5307
5483
  driver.feed(sample_record.merge('key1' => 'v1', 'key2' => 'v2'))
5308
5484
  end
@@ -5313,6 +5489,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5313
5489
  def test_remove_multi_keys
5314
5490
  driver.configure("remove_keys key1, key2\n")
5315
5491
  stub_elastic
5492
+ stub_elastic_info
5316
5493
  driver.run(default_tag: 'test') do
5317
5494
  driver.feed(sample_record.merge('key1' => 'v1', 'key2' => 'v2'))
5318
5495
  end
@@ -5321,6 +5498,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5321
5498
  end
5322
5499
 
5323
5500
  def test_request_error
5501
+ stub_elastic_info
5324
5502
  stub_elastic_unavailable
5325
5503
  assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) {
5326
5504
  driver.run(default_tag: 'test', shutdown: false) do
@@ -5332,6 +5510,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5332
5510
  def test_request_forever
5333
5511
  omit("retry_forever test is unstable.") if ENV["CI"]
5334
5512
  stub_elastic
5513
+ stub_elastic_info
5335
5514
  driver.configure(Fluent::Config::Element.new(
5336
5515
  'ROOT', '', {
5337
5516
  '@type' => 'elasticsearch',
@@ -5356,6 +5535,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5356
5535
  connection_resets += 1
5357
5536
  raise Faraday::ConnectionFailed, "Test message"
5358
5537
  end
5538
+ stub_elastic_info
5359
5539
 
5360
5540
  assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) {
5361
5541
  driver.run(default_tag: 'test', shutdown: false) do
@@ -5372,6 +5552,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5372
5552
  connection_resets += 1
5373
5553
  raise ZeroDivisionError, "any not host_unreachable_exceptions exception"
5374
5554
  end
5555
+ stub_elastic_info
5375
5556
 
5376
5557
  driver.configure("reconnect_on_error true\n")
5377
5558
 
@@ -5398,6 +5579,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5398
5579
  connection_resets += 1
5399
5580
  raise ZeroDivisionError, "any not host_unreachable_exceptions exception"
5400
5581
  end
5582
+ stub_elastic_info
5401
5583
 
5402
5584
  driver.configure("reconnect_on_error false\n")
5403
5585
 
@@ -5441,6 +5623,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5441
5623
  })
5442
5624
  }
5443
5625
  end)
5626
+ stub_elastic_info
5444
5627
 
5445
5628
  driver.run(default_tag: 'test') do
5446
5629
  driver.feed(1, sample_record)
@@ -5512,6 +5695,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5512
5695
  })
5513
5696
  }
5514
5697
  end)
5698
+ stub_elastic_info
5515
5699
 
5516
5700
  # Check buffer fulfillment condition
5517
5701
  assert_raise(Fluent::Plugin::ElasticsearchOutput::RetryStreamEmitFailure) do
@@ -5558,6 +5742,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5558
5742
  })
5559
5743
  }
5560
5744
  end)
5745
+ stub_elastic_info
5746
+
5561
5747
  sample_record1 = sample_record('my_id' => 'abc')
5562
5748
  sample_record4 = sample_record('my_id' => 'xyz')
5563
5749
 
@@ -5607,6 +5793,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5607
5793
  })
5608
5794
  }
5609
5795
  end)
5796
+ stub_elastic_info
5797
+
5610
5798
  sample_record1 = sample_record('my_id' => 'abc')
5611
5799
  sample_record4 = sample_record('my_id' => 'xyz')
5612
5800
 
@@ -5677,6 +5865,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5677
5865
  })
5678
5866
  }
5679
5867
  end)
5868
+ stub_elastic_info
5680
5869
 
5681
5870
  driver.run(default_tag: 'test') do
5682
5871
  driver.feed(1, sample_record)
@@ -5693,6 +5882,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5693
5882
  def test_update_should_not_write_if_theres_no_id
5694
5883
  driver.configure("write_operation update\n")
5695
5884
  stub_elastic
5885
+ stub_elastic_info
5696
5886
  driver.run(default_tag: 'test') do
5697
5887
  driver.feed(sample_record)
5698
5888
  end
@@ -5702,6 +5892,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5702
5892
  def test_upsert_should_not_write_if_theres_no_id
5703
5893
  driver.configure("write_operation upsert\n")
5704
5894
  stub_elastic
5895
+ stub_elastic_info
5705
5896
  driver.run(default_tag: 'test') do
5706
5897
  driver.feed(sample_record)
5707
5898
  end
@@ -5711,6 +5902,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5711
5902
  def test_create_should_not_write_if_theres_no_id
5712
5903
  driver.configure("write_operation create\n")
5713
5904
  stub_elastic
5905
+ stub_elastic_info
5714
5906
  driver.run(default_tag: 'test') do
5715
5907
  driver.feed(sample_record)
5716
5908
  end
@@ -5721,6 +5913,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5721
5913
  driver.configure("write_operation update
5722
5914
  id_key request_id")
5723
5915
  stub_elastic
5916
+ stub_elastic_info
5724
5917
  driver.run(default_tag: 'test') do
5725
5918
  driver.feed(sample_record)
5726
5919
  end
@@ -5734,6 +5927,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5734
5927
  id_key request_id
5735
5928
  remove_keys_on_update parent_id")
5736
5929
  stub_elastic
5930
+ stub_elastic_info
5737
5931
  driver.run(default_tag: 'test') do
5738
5932
  driver.feed(sample_record)
5739
5933
  end
@@ -5745,6 +5939,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5745
5939
  driver.configure("write_operation upsert
5746
5940
  id_key request_id")
5747
5941
  stub_elastic
5942
+ stub_elastic_info
5748
5943
  driver.run(default_tag: 'test') do
5749
5944
  driver.feed(sample_record)
5750
5945
  end
@@ -5758,6 +5953,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5758
5953
  id_key request_id
5759
5954
  remove_keys_on_update parent_id")
5760
5955
  stub_elastic
5956
+ stub_elastic_info
5761
5957
  driver.run(default_tag: 'test') do
5762
5958
  driver.feed(sample_record)
5763
5959
  end
@@ -5772,6 +5968,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5772
5968
  id_key request_id
5773
5969
  remove_keys_on_update parent_id")
5774
5970
  stub_elastic
5971
+ stub_elastic_info
5775
5972
  driver.run(default_tag: 'test') do
5776
5973
  driver.feed(sample_record)
5777
5974
  end
@@ -5785,6 +5982,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5785
5982
  id_key id
5786
5983
  remove_keys_on_update foo,baz")
5787
5984
  stub_elastic
5985
+ stub_elastic_info
5788
5986
  driver.run(default_tag: 'test') do
5789
5987
  driver.feed("id" => 1, "foo" => "bar", "baz" => "quix", "zip" => "zam")
5790
5988
  end
@@ -5809,6 +6007,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5809
6007
  id_key id
5810
6008
  remove_keys_on_update_key keys_to_skip")
5811
6009
  stub_elastic
6010
+ stub_elastic_info
5812
6011
  driver.run(default_tag: 'test') do
5813
6012
  driver.feed("id" => 1, "foo" => "bar", "baz" => "quix", "keys_to_skip" => ["baz"])
5814
6013
  end
@@ -5833,6 +6032,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5833
6032
  remove_keys_on_update foo,bar
5834
6033
  remove_keys_on_update_key keys_to_skip")
5835
6034
  stub_elastic
6035
+ stub_elastic_info
5836
6036
  driver.run(default_tag: 'test') do
5837
6037
  driver.feed("id" => 1, "foo" => "bar", "baz" => "quix", "keys_to_skip" => ["baz"])
5838
6038
  end
@@ -5857,6 +6057,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5857
6057
  driver.configure("write_operation create
5858
6058
  id_key request_id")
5859
6059
  stub_elastic
6060
+ stub_elastic_info
5860
6061
  driver.run(default_tag: 'test') do
5861
6062
  driver.feed(sample_record)
5862
6063
  end
@@ -5865,6 +6066,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5865
6066
 
5866
6067
  def test_include_index_in_url
5867
6068
  stub_elastic('http://localhost:9200/logstash-2018.01.01/_bulk')
6069
+ stub_elastic_info('http://localhost:9200/')
5868
6070
 
5869
6071
  driver.configure("index_name logstash-2018.01.01
5870
6072
  include_index_in_url true")
@@ -5878,8 +6080,8 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5878
6080
 
5879
6081
  def test_use_simple_sniffer
5880
6082
  require 'fluent/plugin/elasticsearch_simple_sniffer'
5881
- stub_elastic_info
5882
6083
  stub_elastic
6084
+ stub_elastic_info
5883
6085
  config = %[
5884
6086
  sniffer_class_name Fluent::Plugin::ElasticsearchSimpleSniffer
5885
6087
  log_level debug
@@ -5903,6 +6105,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5903
6105
  remove_keys id
5904
6106
  suppress_doc_wrap true')
5905
6107
  stub_elastic
6108
+ stub_elastic_info
5906
6109
  doc_body = {'field' => 'value'}
5907
6110
  script_body = {'source' => 'ctx._source.counter += params.param1',
5908
6111
  'lang' => 'painless',
@@ -5929,6 +6132,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5929
6132
  remove_keys id
5930
6133
  suppress_doc_wrap true')
5931
6134
  stub_elastic
6135
+ stub_elastic_info
5932
6136
  doc_body = {'field' => 'value'}
5933
6137
  script_body = {'source' => 'ctx._source.counter += params.param1',
5934
6138
  'lang' => 'painless',
@@ -5955,6 +6159,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5955
6159
  def test_ignore_exception
5956
6160
  driver.configure('ignore_exceptions ["Elasticsearch::Transport::Transport::Errors::ServiceUnavailable"]')
5957
6161
  stub_elastic_unavailable
6162
+ stub_elastic_info
5958
6163
 
5959
6164
  driver.run(default_tag: 'test') do
5960
6165
  driver.feed(sample_record)
@@ -5964,6 +6169,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5964
6169
  def test_ignore_exception_with_superclass
5965
6170
  driver.configure('ignore_exceptions ["Elasticsearch::Transport::Transport::ServerError"]')
5966
6171
  stub_elastic_unavailable
6172
+ stub_elastic_info
5967
6173
 
5968
6174
  driver.run(default_tag: 'test') do
5969
6175
  driver.feed(sample_record)
@@ -5973,6 +6179,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5973
6179
  def test_ignore_excetion_handles_appropriate_ones
5974
6180
  driver.configure('ignore_exceptions ["Faraday::ConnectionFailed"]')
5975
6181
  stub_elastic_unavailable
6182
+ stub_elastic_info
5976
6183
 
5977
6184
  assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) {
5978
6185
  driver.run(default_tag: 'test', shutdown: false) do