fluentd 1.7.4-x64-mingw32 → 1.8.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd might be problematic. Click here for more details.

Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -1
  3. data/.travis.yml +4 -0
  4. data/CHANGELOG.md +70 -0
  5. data/MAINTAINERS.md +1 -0
  6. data/example/out_forward_sd.conf +17 -0
  7. data/example/sd.yaml +8 -0
  8. data/fluentd.gemspec +1 -1
  9. data/lib/fluent/agent.rb +3 -1
  10. data/lib/fluent/command/cat.rb +1 -2
  11. data/lib/fluent/command/fluentd.rb +16 -8
  12. data/lib/fluent/compat/call_super_mixin.rb +9 -0
  13. data/lib/fluent/compat/exec_util.rb +1 -1
  14. data/lib/fluent/config/configure_proxy.rb +4 -4
  15. data/lib/fluent/config/element.rb +28 -15
  16. data/lib/fluent/config/error.rb +6 -0
  17. data/lib/fluent/config/literal_parser.rb +24 -2
  18. data/lib/fluent/config/section.rb +43 -6
  19. data/lib/fluent/config/types.rb +98 -26
  20. data/lib/fluent/configurable.rb +2 -2
  21. data/lib/fluent/counter/base_socket.rb +2 -4
  22. data/lib/fluent/engine.rb +41 -122
  23. data/lib/fluent/event.rb +5 -7
  24. data/lib/fluent/fluent_log_event_router.rb +141 -0
  25. data/lib/fluent/msgpack_factory.rb +19 -2
  26. data/lib/fluent/plugin.rb +10 -1
  27. data/lib/fluent/plugin/base.rb +2 -2
  28. data/lib/fluent/plugin/buf_file.rb +11 -7
  29. data/lib/fluent/plugin/buf_file_single.rb +8 -5
  30. data/lib/fluent/plugin/buffer/chunk.rb +1 -1
  31. data/lib/fluent/plugin/buffer/file_chunk.rb +4 -6
  32. data/lib/fluent/plugin/buffer/file_single_chunk.rb +3 -5
  33. data/lib/fluent/plugin/formatter_csv.rb +23 -1
  34. data/lib/fluent/plugin/formatter_stdout.rb +1 -1
  35. data/lib/fluent/plugin/in_forward.rb +1 -1
  36. data/lib/fluent/plugin/in_monitor_agent.rb +4 -2
  37. data/lib/fluent/plugin/in_tail.rb +6 -0
  38. data/lib/fluent/plugin/in_unix.rb +1 -1
  39. data/lib/fluent/plugin/out_forward.rb +77 -28
  40. data/lib/fluent/plugin/out_forward/ack_handler.rb +1 -1
  41. data/lib/fluent/plugin/out_forward/load_balancer.rb +5 -2
  42. data/lib/fluent/plugin/out_stream.rb +1 -1
  43. data/lib/fluent/plugin/output.rb +11 -3
  44. data/lib/fluent/plugin/parser.rb +1 -0
  45. data/lib/fluent/plugin/sd_file.rb +155 -0
  46. data/lib/fluent/plugin/sd_static.rb +58 -0
  47. data/lib/fluent/plugin/service_discovery.rb +80 -0
  48. data/lib/fluent/plugin_helper.rb +1 -0
  49. data/lib/fluent/plugin_helper/child_process.rb +3 -3
  50. data/lib/fluent/plugin_helper/compat_parameters.rb +11 -1
  51. data/lib/fluent/plugin_helper/extract.rb +1 -1
  52. data/lib/fluent/plugin_helper/inject.rb +1 -1
  53. data/lib/fluent/plugin_helper/record_accessor.rb +10 -19
  54. data/lib/fluent/plugin_helper/server.rb +8 -4
  55. data/lib/fluent/plugin_helper/service_discovery.rb +80 -0
  56. data/lib/fluent/plugin_helper/service_discovery/manager.rb +132 -0
  57. data/lib/fluent/plugin_helper/service_discovery/round_robin_balancer.rb +43 -0
  58. data/lib/fluent/plugin_id.rb +7 -0
  59. data/lib/fluent/root_agent.rb +7 -9
  60. data/lib/fluent/supervisor.rb +192 -211
  61. data/lib/fluent/system_config.rb +26 -52
  62. data/lib/fluent/test/driver/base_owned.rb +15 -2
  63. data/lib/fluent/time.rb +8 -6
  64. data/lib/fluent/version.rb +1 -1
  65. data/test/command/test_fluentd.rb +12 -7
  66. data/test/config/test_configurable.rb +154 -0
  67. data/test/config/test_element.rb +18 -0
  68. data/test/config/test_literal_parser.rb +4 -0
  69. data/test/config/test_system_config.rb +48 -91
  70. data/test/config/test_types.rb +293 -120
  71. data/test/counter/test_client.rb +8 -4
  72. data/test/plugin/data/sd_file/config +11 -0
  73. data/test/plugin/data/sd_file/config.json +17 -0
  74. data/test/plugin/data/sd_file/config.yaml +11 -0
  75. data/test/plugin/data/sd_file/config.yml +11 -0
  76. data/test/plugin/data/sd_file/invalid_config.yml +7 -0
  77. data/test/plugin/out_forward/test_handshake_protocol.rb +2 -2
  78. data/test/plugin/out_forward/test_load_balancer.rb +1 -1
  79. data/test/plugin/out_forward/test_socket_cache.rb +2 -2
  80. data/test/plugin/test_buf_file.rb +40 -0
  81. data/test/plugin/test_buf_file_single.rb +32 -0
  82. data/test/plugin/test_buffer_file_chunk.rb +0 -11
  83. data/test/plugin/test_buffer_file_single_chunk.rb +0 -10
  84. data/test/plugin/test_formatter_csv.rb +9 -0
  85. data/test/plugin/test_in_forward.rb +9 -9
  86. data/test/plugin/test_in_monitor_agent.rb +37 -10
  87. data/test/plugin/test_in_unix.rb +5 -5
  88. data/test/plugin/test_out_forward.rb +45 -1
  89. data/test/plugin/test_out_stdout.rb +36 -1
  90. data/test/plugin/test_out_stream.rb +3 -3
  91. data/test/plugin/test_output.rb +25 -1
  92. data/test/plugin/test_sd_file.rb +211 -0
  93. data/test/plugin_helper/service_discovery/test_manager.rb +93 -0
  94. data/test/plugin_helper/service_discovery/test_round_robin_balancer.rb +21 -0
  95. data/test/plugin_helper/test_server.rb +13 -0
  96. data/test/plugin_helper/test_service_discovery.rb +72 -0
  97. data/test/test_event.rb +15 -15
  98. data/test/test_fluent_log_event_router.rb +99 -0
  99. data/test/test_logger_initializer.rb +26 -0
  100. data/test/test_supervisor.rb +30 -59
  101. metadata +43 -6
@@ -0,0 +1,21 @@
1
+ require_relative '../../helper'
2
+ require 'fluent/plugin_helper/service_discovery/round_robin_balancer'
3
+
4
+ class TestRoundRobinBalancer < ::Test::Unit::TestCase
5
+ test 'select_service' do
6
+ rrb = Fluent::PluginHelper::ServiceDiscovery::RoundRobinBalancer.new
7
+ rrb.rebalance([1, 2, 3])
8
+
9
+ rrb.select_service { |n| assert_equal 1, n }
10
+ rrb.select_service { |n| assert_equal 2, n }
11
+ rrb.select_service { |n| assert_equal 3, n }
12
+ rrb.select_service { |n| assert_equal 1, n }
13
+ rrb.select_service { |n| assert_equal 2, n }
14
+ rrb.select_service { |n| assert_equal 3, n }
15
+ rrb.rebalance([1, 2, 3, 4])
16
+ rrb.select_service { |n| assert_equal 1, n }
17
+ rrb.select_service { |n| assert_equal 2, n }
18
+ rrb.select_service { |n| assert_equal 3, n }
19
+ rrb.select_service { |n| assert_equal 4, n }
20
+ end
21
+ end
@@ -538,6 +538,19 @@ class ServerPluginHelperTest < Test::Unit::TestCase
538
538
  assert_equal ["yayfoo\n", "yayfoo\n", "yayfoo\n"], lines
539
539
  assert_equal ["closed", "closed", "closed"], callback_results
540
540
  end
541
+
542
+ test 'can listen IPv4 / IPv6 together' do
543
+ omit "IPv6 unavailable here" unless ipv6_enabled?
544
+
545
+ assert_nothing_raised do
546
+ @d.server_create_tcp(:s_ipv4, PORT, bind: '0.0.0.0', shared: false) do |data, conn|
547
+ # ...
548
+ end
549
+ @d.server_create_tcp(:s_ipv6, PORT, bind: '::', shared: false) do |data, conn|
550
+ # ...
551
+ end
552
+ end
553
+ end
541
554
  end
542
555
 
543
556
  sub_test_case '#server_create_udp' do
@@ -0,0 +1,72 @@
1
+ require_relative '../helper'
2
+ require 'flexmock/test_unit'
3
+ require 'fluent/plugin_helper/service_discovery'
4
+ require 'fluent/plugin/output'
5
+
6
+ class ServiceDiscoveryHelper < Test::Unit::TestCase
7
+ PORT = unused_port
8
+ NULL_LOGGER = Logger.new(nil)
9
+
10
+ class Dummy < Fluent::Plugin::TestBase
11
+ helpers :service_discovery
12
+
13
+ # Make these mehtod public
14
+ def service_discovery_create_manager(title, configurations:, load_balancer: nil, custom_build_method: nil, interval: 3)
15
+ super
16
+ end
17
+
18
+ def discovery_manager
19
+ super
20
+ end
21
+ end
22
+
23
+ setup do
24
+ @sd_file_dir = File.expand_path('../plugin/data/sd_file', __dir__)
25
+
26
+ @d = nil
27
+ end
28
+
29
+ teardown do
30
+ if @d
31
+ @d.stop unless @d.stopped?
32
+ @d.shutdown unless @d.shutdown?
33
+ @d.close unless @d.closed?
34
+ @d.terminate unless @d.terminated?
35
+ end
36
+ end
37
+
38
+ test 'start discovery manager' do
39
+ d = @d = Dummy.new
40
+
41
+ d.service_discovery_create_manager(
42
+ :service_discovery_helper_test,
43
+ configurations: [{ type: :static, conf: config_element('root', '', {}, [config_element('service', '', { 'host' => '127.0.0.1', 'port' => '1234' })]) }],
44
+ )
45
+
46
+ assert_true !!d.discovery_manager
47
+
48
+ mock.proxy(d.discovery_manager).start.once
49
+ mock.proxy(d).timer_execute(:service_discovery_helper_test, anything).never
50
+
51
+ d.start
52
+
53
+ services = d.discovery_manager.services
54
+ assert_equal 1, services.size
55
+ assert_equal '127.0.0.1', services[0].host
56
+ assert_equal 1234, services[0].port
57
+ end
58
+
59
+ test 'call timer_execute if dynamic configuration' do
60
+ d = @d = Dummy.new
61
+
62
+ d.service_discovery_create_manager(
63
+ :service_discovery_helper_test,
64
+ configurations: [{ type: :file, conf: config_element('file_config', '', { 'path' => File.join(@sd_file_dir, 'config.yml') }) }],
65
+ )
66
+
67
+ assert_true !!d.discovery_manager
68
+ mock.proxy(d.discovery_manager).start.once
69
+ mock(d).timer_execute(:service_discovery_helper_test, anything).once
70
+ d.start
71
+ end
72
+ end
@@ -74,7 +74,7 @@ module EventTest
74
74
 
75
75
  test 'to_msgpack_stream' do
76
76
  stream = @es.to_msgpack_stream
77
- Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
77
+ Fluent::MessagePackFactory.msgpack_unpacker.feed_each(stream) { |time, record|
78
78
  assert_equal @time, time
79
79
  assert_equal @record, record
80
80
  }
@@ -82,7 +82,7 @@ module EventTest
82
82
 
83
83
  test 'to_msgpack_stream with time_int argument' do
84
84
  stream = @es.to_msgpack_stream(time_int: true)
85
- Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
85
+ Fluent::MessagePackFactory.msgpack_unpacker.feed_each(stream) { |time, record|
86
86
  assert_equal @time.to_i, time
87
87
  assert_equal @record, record
88
88
  }
@@ -90,7 +90,7 @@ module EventTest
90
90
 
91
91
  test 'to_compressed_msgpack_stream' do
92
92
  stream = @es.to_compressed_msgpack_stream
93
- Fluent::Engine.msgpack_factory.unpacker.feed_each(decompress(stream)) { |time, record|
93
+ Fluent::MessagePackFactory.msgpack_unpacker.feed_each(decompress(stream)) { |time, record|
94
94
  assert_equal @time, time
95
95
  assert_equal @record, record
96
96
  }
@@ -98,7 +98,7 @@ module EventTest
98
98
 
99
99
  test 'to_compressed_msgpack_stream with time_int argument' do
100
100
  stream = @es.to_compressed_msgpack_stream(time_int: true)
101
- Fluent::Engine.msgpack_factory.unpacker.feed_each(decompress(stream)) { |time, record|
101
+ Fluent::MessagePackFactory.msgpack_unpacker.feed_each(decompress(stream)) { |time, record|
102
102
  assert_equal @time.to_i, time
103
103
  assert_equal @record, record
104
104
  }
@@ -174,7 +174,7 @@ module EventTest
174
174
  test 'to_msgpack_stream' do
175
175
  i = 0
176
176
  stream = @es.to_msgpack_stream
177
- Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
177
+ Fluent::MessagePackFactory.msgpack_unpacker.feed_each(stream) { |time, record|
178
178
  assert_equal @times[i], time
179
179
  assert_equal @records[i], record
180
180
  i += 1
@@ -185,7 +185,7 @@ module EventTest
185
185
  i = 0
186
186
  compressed_stream = @es.to_compressed_msgpack_stream
187
187
  stream = decompress(compressed_stream)
188
- Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
188
+ Fluent::MessagePackFactory.msgpack_unpacker.feed_each(stream) { |time, record|
189
189
  assert_equal @times[i], time
190
190
  assert_equal @records[i], record
191
191
  i += 1
@@ -196,7 +196,7 @@ module EventTest
196
196
  i = 0
197
197
  compressed_stream = @es.to_compressed_msgpack_stream(time_int: true)
198
198
  stream = decompress(compressed_stream)
199
- Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
199
+ Fluent::MessagePackFactory.msgpack_unpacker.feed_each(stream) { |time, record|
200
200
  assert_equal @times[i].to_i, time
201
201
  assert_equal @records[i], record
202
202
  i += 1
@@ -276,7 +276,7 @@ module EventTest
276
276
  test 'to_msgpack_stream' do
277
277
  i = 0
278
278
  stream = @es.to_msgpack_stream
279
- Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
279
+ Fluent::MessagePackFactory.msgpack_unpacker.feed_each(stream) { |time, record|
280
280
  assert_equal @times[i], time
281
281
  assert_equal @records[i], record
282
282
  i += 1
@@ -287,7 +287,7 @@ module EventTest
287
287
  i = 0
288
288
  compressed_stream = @es.to_compressed_msgpack_stream
289
289
  stream = decompress(compressed_stream)
290
- Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
290
+ Fluent::MessagePackFactory.msgpack_unpacker.feed_each(stream) { |time, record|
291
291
  assert_equal @times[i], time
292
292
  assert_equal @records[i], record
293
293
  i += 1
@@ -298,7 +298,7 @@ module EventTest
298
298
  i = 0
299
299
  compressed_stream = @es.to_compressed_msgpack_stream(time_int: true)
300
300
  stream = decompress(compressed_stream)
301
- Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
301
+ Fluent::MessagePackFactory.msgpack_unpacker.feed_each(stream) { |time, record|
302
302
  assert_equal @times[i].to_i, time
303
303
  assert_equal @records[i], record
304
304
  i += 1
@@ -312,7 +312,7 @@ module EventTest
312
312
  include Fluent::Plugin::Compressable
313
313
 
314
314
  def setup
315
- pk = Fluent::Engine.msgpack_factory.packer
315
+ pk = Fluent::MessagePackFactory.msgpack_packer
316
316
  time = Engine.now
317
317
  @times = [Fluent::EventTime.new(time.sec), Fluent::EventTime.new(time.sec + 1)]
318
318
  @records = [{'k' => 'v1', 'n' => 1}, {'k' => 'v2', 'n' => 2}]
@@ -384,7 +384,7 @@ module EventTest
384
384
  test 'to_msgpack_stream' do
385
385
  i = 0
386
386
  stream = @es.to_msgpack_stream
387
- Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
387
+ Fluent::MessagePackFactory.msgpack_unpacker.feed_each(stream) { |time, record|
388
388
  assert_equal @times[i], time
389
389
  assert_equal @records[i], record
390
390
  i += 1
@@ -395,7 +395,7 @@ module EventTest
395
395
  i = 0
396
396
  compressed_stream = @es.to_compressed_msgpack_stream
397
397
  stream = decompress(compressed_stream)
398
- Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
398
+ Fluent::MessagePackFactory.msgpack_unpacker.feed_each(stream) { |time, record|
399
399
  assert_equal @times[i], time
400
400
  assert_equal @records[i], record
401
401
  i += 1
@@ -490,7 +490,7 @@ module EventTest
490
490
  stream = nil
491
491
  ensure_data_is_decompressed { stream = @es.to_msgpack_stream }
492
492
 
493
- Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
493
+ Fluent::MessagePackFactory.msgpack_unpacker.feed_each(stream) { |time, record|
494
494
  assert_equal @times[i], time
495
495
  assert_equal @records[i], record
496
496
  i += 1
@@ -505,7 +505,7 @@ module EventTest
505
505
  assert_equal @entries, @es.instance_variable_get(:@data)
506
506
 
507
507
  stream = decompress(compressed_stream)
508
- Fluent::Engine.msgpack_factory.unpacker.feed_each(stream) { |time, record|
508
+ Fluent::MessagePackFactory.msgpack_unpacker.feed_each(stream) { |time, record|
509
509
  assert_equal @times[i], time
510
510
  assert_equal @records[i], record
511
511
  i += 1
@@ -0,0 +1,99 @@
1
+ require_relative 'helper'
2
+ require 'fluent/fluent_log_event_router'
3
+ require 'fluent/root_agent'
4
+ require 'fluent/system_config'
5
+
6
+ class FluentLogEventRouterTest < ::Test::Unit::TestCase
7
+ # @param config [String]
8
+ def build_config(config)
9
+ Fluent::Config.parse(config, 'fluent_log_event', '', syntax: :v1)
10
+ end
11
+
12
+ sub_test_case 'NullFluentLogEventRouter does nothing' do
13
+ test 'emittable? returns false but others does nothing' do
14
+ null_event_router = Fluent::NullFluentLogEventRouter.new
15
+ null_event_router.start
16
+ null_event_router.stop
17
+ null_event_router.graceful_stop
18
+ null_event_router.emit_event(nil)
19
+ assert_false null_event_router.emittable?
20
+ end
21
+ end
22
+
23
+ sub_test_case '#build' do
24
+ test 'NullFluentLogEventRouter if root_agent have not internal logger' do
25
+ root_agent = Fluent::RootAgent.new(log: $log, system_config: Fluent::SystemConfig.new)
26
+ root_agent.configure(build_config(''))
27
+
28
+ d = Fluent::FluentLogEventRouter.build(root_agent)
29
+ assert_equal Fluent::NullFluentLogEventRouter, d.class
30
+ end
31
+
32
+ test 'FluentLogEventRouter if <match fluent.*> exists in config' do
33
+ root_agent = Fluent::RootAgent.new(log: $log, system_config: Fluent::SystemConfig.new)
34
+ root_agent.configure(build_config(<<-CONFIG))
35
+ <match fluent.*>
36
+ @type null
37
+ </match>
38
+ CONFIG
39
+
40
+ d = Fluent::FluentLogEventRouter.build(root_agent)
41
+ assert_equal Fluent::FluentLogEventRouter, d.class
42
+ end
43
+
44
+ test 'FluentLogEventRouter if <label @FLUENT_LOG> exists in config' do
45
+ root_agent = Fluent::RootAgent.new(log: $log, system_config: Fluent::SystemConfig.new)
46
+ root_agent.configure(build_config(<<-CONFIG))
47
+ <label @FLUENT_LOG>
48
+ <match *>
49
+ @type null
50
+ </match>
51
+ </label>
52
+ CONFIG
53
+
54
+ d = Fluent::FluentLogEventRouter.build(root_agent)
55
+ assert_equal Fluent::FluentLogEventRouter, d.class
56
+ end
57
+ end
58
+
59
+ test 'when calling graceful_stop, it flushes all events' do
60
+ event_router = []
61
+ stub(event_router).emit do |tag, time, record|
62
+ event_router.push([tag, time, record])
63
+ end
64
+
65
+ d = Fluent::FluentLogEventRouter.new(event_router)
66
+
67
+ t = Time.now
68
+ msg = ['tag', t, { 'key' => 'value' }]
69
+ d.emit_event(msg)
70
+ d.graceful_stop
71
+ d.emit_event(msg)
72
+ d.start
73
+
74
+ d.graceful_stop # to call join
75
+ assert_equal 2, event_router.size
76
+ assert_equal msg, event_router[0]
77
+ assert_equal msg, event_router[1]
78
+ end
79
+
80
+ test 'when calling stop, it ignores existing events' do
81
+ event_router = []
82
+ stub(event_router).emit do |tag, time, record|
83
+ event_router.push([tag, time, record])
84
+ end
85
+
86
+ d = Fluent::FluentLogEventRouter.new(event_router)
87
+
88
+ t = Time.now
89
+ msg = ['tag', t, { 'key' => 'value' }]
90
+ d.emit_event(msg)
91
+ d.stop
92
+ d.emit_event(msg)
93
+ d.start
94
+
95
+ d.stop # to call join
96
+ assert_equal 1, event_router.size
97
+ assert_equal msg, event_router[0]
98
+ end
99
+ end
@@ -0,0 +1,26 @@
1
+ require_relative 'helper'
2
+ require 'fluent/supervisor'
3
+ require 'fileutils'
4
+
5
+ class LoggerInitializerTest < ::Test::Unit::TestCase
6
+ TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/tmp/logger_initializer#{ENV['TEST_ENV_NUMBER']}")
7
+
8
+ teardown do
9
+ begin
10
+ FileUtils.rm_rf(TMP_DIR)
11
+ rescue => _
12
+ end
13
+ end
14
+
15
+ test 'when path is given' do
16
+ path = File.join(TMP_DIR, 'fluent_with_path.log')
17
+
18
+ assert_false File.exist?(TMP_DIR)
19
+ logger = Fluent::Supervisor::LoggerInitializer.new(path, Fluent::Log::LEVEL_DEBUG, nil, nil, {})
20
+
21
+ assert_nothing_raised do
22
+ logger.init(:supervisor, 0)
23
+ end
24
+ assert_true File.exist?(TMP_DIR)
25
+ end
26
+ end
@@ -30,14 +30,6 @@ class SupervisorTest < ::Test::Unit::TestCase
30
30
  File.open(path, "w") {|f| f.write data }
31
31
  end
32
32
 
33
- def test_initialize
34
- opts = Fluent::Supervisor.default_options
35
- sv = Fluent::Supervisor.new(opts)
36
- opts.each { |k, v|
37
- assert_equal v, sv.instance_variable_get("@#{k}")
38
- }
39
- end
40
-
41
33
  def test_read_config
42
34
  create_info_dummy_logger
43
35
 
@@ -61,10 +53,8 @@ class SupervisorTest < ::Test::Unit::TestCase
61
53
 
62
54
  sv.instance_variable_set(:@config_path, tmp_dir)
63
55
  sv.instance_variable_set(:@use_v1_config, use_v1_config)
64
- sv.send(:read_config)
65
-
66
- conf = sv.instance_variable_get(:@conf)
67
56
 
57
+ conf = sv.__send__(:read_config)
68
58
  elem = conf.elements.find { |e| e.name == 'source' }
69
59
  assert_equal "forward", elem['@type']
70
60
  assert_equal "forward_input", elem['@id']
@@ -108,9 +98,8 @@ class SupervisorTest < ::Test::Unit::TestCase
108
98
 
109
99
  sv.instance_variable_set(:@config_path, tmp_path)
110
100
  sv.instance_variable_set(:@use_v1_config, use_v1_config)
111
- sv.send(:read_config)
112
101
 
113
- conf = sv.instance_variable_get(:@conf)
102
+ conf = sv.__send__(:read_config)
114
103
  label = conf.elements.detect {|e| e.name == "label" }
115
104
  filter = label.elements.detect {|e| e.name == "filter" }
116
105
  record_transformer = filter.elements.detect {|e| e.name = "record_transformer" }
@@ -148,9 +137,7 @@ class SupervisorTest < ::Test::Unit::TestCase
148
137
  </system>
149
138
  EOC
150
139
  conf = Fluent::Config.parse(conf_data, "(test)", "(test_dir)", true)
151
- sv.instance_variable_set(:@conf, conf)
152
- sv.send(:set_system_config)
153
- sys_conf = sv.instance_variable_get(:@system_config)
140
+ sys_conf = sv.__send__(:build_system_config, conf)
154
141
 
155
142
  assert_equal '127.0.0.1:24445', sys_conf.rpc_endpoint
156
143
  assert_equal true, sys_conf.suppress_repeated_stacktrace
@@ -229,9 +216,7 @@ class SupervisorTest < ::Test::Unit::TestCase
229
216
  </system>
230
217
  EOC
231
218
  conf = Fluent::Config.parse(conf_data, "(test)", "(test_dir)", true)
232
- sv.instance_variable_set(:@conf, conf)
233
- sv.send(:set_system_config)
234
- sys_conf = sv.instance_variable_get(:@system_config)
219
+ sys_conf = sv.__send__(:build_system_config, conf)
235
220
 
236
221
  server = DummyServer.new
237
222
  server.rpc_endpoint = sys_conf.rpc_endpoint
@@ -387,46 +372,6 @@ class SupervisorTest < ::Test::Unit::TestCase
387
372
  assert_equal Fluent::Log::LEVEL_INFO, se_config[:log_level]
388
373
  end
389
374
 
390
- def test_load_config_with_multibyte_string
391
- tmp_path = "#{TMP_DIR}/dir/test_multibyte_config.conf"
392
- conf_str = %[
393
- <source>
394
- @type forward
395
- @id forward_input
396
- @label @INPUT
397
- </source>
398
- <label @INPUT>
399
- <filter>
400
- @type record_transformer
401
- <record>
402
- message こんにちは. ${record["name"]} has made a order of ${record["item"]} just now.
403
- </record>
404
- </filter>
405
- <match>
406
- @type stdout
407
- </match>
408
- </label>
409
- ]
410
- FileUtils.mkdir_p(File.dirname(tmp_path))
411
- File.open(tmp_path, "w:utf-8") {|file| file.write(conf_str) }
412
-
413
- params = {}
414
- params['workers'] = 1
415
- params['use_v1_config'] = true
416
- params['log_path'] = 'test/tmp/supervisor/log'
417
- params['suppress_repeated_stacktrace'] = true
418
- params['log_level'] = Fluent::Log::LEVEL_INFO
419
- params['conf_encoding'] = 'utf-8'
420
- load_config_proc = Proc.new { Fluent::Supervisor.load_config(tmp_path, params) }
421
-
422
- se_config = load_config_proc.call
423
- conf = se_config[:fluentd_conf]
424
- label = conf.elements.detect {|e| e.name == "label" }
425
- filter = label.elements.detect {|e| e.name == "filter" }
426
- record_transformer = filter.elements.detect {|e| e.name = "record_transformer" }
427
- assert_equal(Encoding::UTF_8, record_transformer["message"].encoding)
428
- end
429
-
430
375
  def test_logger
431
376
  opts = Fluent::Supervisor.default_options
432
377
  sv = Fluent::Supervisor.new(opts)
@@ -463,6 +408,32 @@ class SupervisorTest < ::Test::Unit::TestCase
463
408
  assert_equal 10, $log.out.instance_variable_get(:@shift_size)
464
409
  end
465
410
 
411
+ def test_inline_config
412
+ opts = Fluent::Supervisor.default_options
413
+ opts[:inline_config] = '-'
414
+ sv = Fluent::Supervisor.new(opts)
415
+ assert_equal '-', sv.instance_variable_get(:@inline_config)
416
+
417
+ inline_config = '<match *>\n@type stdout\n</match>'
418
+ stub(STDIN).read { inline_config }
419
+ stub(sv).read_config # to skip
420
+ stub(sv).build_system_config { Fluent::SystemConfig.new } # to skip
421
+
422
+ sv.configure
423
+ assert_equal inline_config, sv.instance_variable_get(:@inline_config)
424
+ end
425
+
426
+ def test_log_level_affects
427
+ opts = Fluent::Supervisor.default_options
428
+ sv = Fluent::Supervisor.new(opts)
429
+
430
+ c = Fluent::Config::Element.new('system', '', { 'log_level' => 'error' }, [])
431
+ stub(sv).read_config { config_element('ROOT', '', {}, [c]) }
432
+
433
+ sv.configure
434
+ assert_equal Fluent::Log::LEVEL_ERROR, $log.level
435
+ end
436
+
466
437
  def create_debug_dummy_logger
467
438
  dl_opts = {}
468
439
  dl_opts[:log_level] = ServerEngine::DaemonLogger::DEBUG