fluentd 1.7.4-x86-mingw32 → 1.8.0-x86-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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -1
- data/.travis.yml +4 -0
- data/CHANGELOG.md +70 -0
- data/MAINTAINERS.md +1 -0
- data/example/out_forward_sd.conf +17 -0
- data/example/sd.yaml +8 -0
- data/fluentd.gemspec +1 -1
- data/lib/fluent/agent.rb +3 -1
- data/lib/fluent/command/cat.rb +1 -2
- data/lib/fluent/command/fluentd.rb +16 -8
- data/lib/fluent/compat/call_super_mixin.rb +9 -0
- data/lib/fluent/compat/exec_util.rb +1 -1
- data/lib/fluent/config/configure_proxy.rb +4 -4
- data/lib/fluent/config/element.rb +28 -15
- data/lib/fluent/config/error.rb +6 -0
- data/lib/fluent/config/literal_parser.rb +24 -2
- data/lib/fluent/config/section.rb +43 -6
- data/lib/fluent/config/types.rb +98 -26
- data/lib/fluent/configurable.rb +2 -2
- data/lib/fluent/counter/base_socket.rb +2 -4
- data/lib/fluent/engine.rb +41 -122
- data/lib/fluent/event.rb +5 -7
- data/lib/fluent/fluent_log_event_router.rb +141 -0
- data/lib/fluent/msgpack_factory.rb +19 -2
- data/lib/fluent/plugin.rb +10 -1
- data/lib/fluent/plugin/base.rb +2 -2
- data/lib/fluent/plugin/buf_file.rb +11 -7
- data/lib/fluent/plugin/buf_file_single.rb +8 -5
- data/lib/fluent/plugin/buffer/chunk.rb +1 -1
- data/lib/fluent/plugin/buffer/file_chunk.rb +4 -6
- data/lib/fluent/plugin/buffer/file_single_chunk.rb +3 -5
- data/lib/fluent/plugin/formatter_csv.rb +23 -1
- data/lib/fluent/plugin/formatter_stdout.rb +1 -1
- data/lib/fluent/plugin/in_forward.rb +1 -1
- data/lib/fluent/plugin/in_monitor_agent.rb +4 -2
- data/lib/fluent/plugin/in_tail.rb +6 -0
- data/lib/fluent/plugin/in_unix.rb +1 -1
- data/lib/fluent/plugin/out_forward.rb +77 -28
- data/lib/fluent/plugin/out_forward/ack_handler.rb +1 -1
- data/lib/fluent/plugin/out_forward/load_balancer.rb +5 -2
- data/lib/fluent/plugin/out_stream.rb +1 -1
- data/lib/fluent/plugin/output.rb +11 -3
- data/lib/fluent/plugin/parser.rb +1 -0
- data/lib/fluent/plugin/sd_file.rb +155 -0
- data/lib/fluent/plugin/sd_static.rb +58 -0
- data/lib/fluent/plugin/service_discovery.rb +80 -0
- data/lib/fluent/plugin_helper.rb +1 -0
- data/lib/fluent/plugin_helper/child_process.rb +3 -3
- data/lib/fluent/plugin_helper/compat_parameters.rb +11 -1
- data/lib/fluent/plugin_helper/extract.rb +1 -1
- data/lib/fluent/plugin_helper/inject.rb +1 -1
- data/lib/fluent/plugin_helper/record_accessor.rb +10 -19
- data/lib/fluent/plugin_helper/server.rb +8 -4
- data/lib/fluent/plugin_helper/service_discovery.rb +80 -0
- data/lib/fluent/plugin_helper/service_discovery/manager.rb +132 -0
- data/lib/fluent/plugin_helper/service_discovery/round_robin_balancer.rb +43 -0
- data/lib/fluent/plugin_id.rb +7 -0
- data/lib/fluent/root_agent.rb +7 -9
- data/lib/fluent/supervisor.rb +192 -211
- data/lib/fluent/system_config.rb +26 -52
- data/lib/fluent/test/driver/base_owned.rb +15 -2
- data/lib/fluent/time.rb +8 -6
- data/lib/fluent/version.rb +1 -1
- data/test/command/test_fluentd.rb +12 -7
- data/test/config/test_configurable.rb +154 -0
- data/test/config/test_element.rb +18 -0
- data/test/config/test_literal_parser.rb +4 -0
- data/test/config/test_system_config.rb +48 -91
- data/test/config/test_types.rb +293 -120
- data/test/counter/test_client.rb +8 -4
- data/test/plugin/data/sd_file/config +11 -0
- data/test/plugin/data/sd_file/config.json +17 -0
- data/test/plugin/data/sd_file/config.yaml +11 -0
- data/test/plugin/data/sd_file/config.yml +11 -0
- data/test/plugin/data/sd_file/invalid_config.yml +7 -0
- data/test/plugin/out_forward/test_handshake_protocol.rb +2 -2
- data/test/plugin/out_forward/test_load_balancer.rb +1 -1
- data/test/plugin/out_forward/test_socket_cache.rb +2 -2
- data/test/plugin/test_buf_file.rb +40 -0
- data/test/plugin/test_buf_file_single.rb +32 -0
- data/test/plugin/test_buffer_file_chunk.rb +0 -11
- data/test/plugin/test_buffer_file_single_chunk.rb +0 -10
- data/test/plugin/test_formatter_csv.rb +9 -0
- data/test/plugin/test_in_forward.rb +9 -9
- data/test/plugin/test_in_monitor_agent.rb +37 -10
- data/test/plugin/test_in_unix.rb +5 -5
- data/test/plugin/test_out_forward.rb +45 -1
- data/test/plugin/test_out_stdout.rb +36 -1
- data/test/plugin/test_out_stream.rb +3 -3
- data/test/plugin/test_output.rb +25 -1
- data/test/plugin/test_sd_file.rb +211 -0
- data/test/plugin_helper/service_discovery/test_manager.rb +93 -0
- data/test/plugin_helper/service_discovery/test_round_robin_balancer.rb +21 -0
- data/test/plugin_helper/test_server.rb +13 -0
- data/test/plugin_helper/test_service_discovery.rb +72 -0
- data/test/test_event.rb +15 -15
- data/test/test_fluent_log_event_router.rb +99 -0
- data/test/test_logger_initializer.rb +26 -0
- data/test/test_supervisor.rb +30 -59
- metadata +43 -6
data/test/counter/test_client.rb
CHANGED
@@ -128,7 +128,8 @@ class CounterClientTest < ::Test::Unit::TestCase
|
|
128
128
|
test 'raise an error when @scope is nil' do
|
129
129
|
@client.instance_variable_set(:@scope, nil)
|
130
130
|
assert_raise 'Call `establish` method to get a `scope` before calling this method' do
|
131
|
-
|
131
|
+
params = { name: 'key1', reset_interval: 10 }
|
132
|
+
@client.init(params).get
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
@@ -151,7 +152,8 @@ class CounterClientTest < ::Test::Unit::TestCase
|
|
151
152
|
]
|
152
153
|
)
|
153
154
|
test 'return an error object' do |(param, expected_error)|
|
154
|
-
|
155
|
+
params = { name: 'key1', reset_interval: 10 }
|
156
|
+
@client.init(params).get
|
155
157
|
response = @client.init(param).get
|
156
158
|
errors = response.errors.first
|
157
159
|
|
@@ -164,7 +166,8 @@ class CounterClientTest < ::Test::Unit::TestCase
|
|
164
166
|
end
|
165
167
|
|
166
168
|
test 'return an existing value when passed key already exists and ignore option is true' do
|
167
|
-
|
169
|
+
params = { name: 'key1', reset_interval: 10 }
|
170
|
+
res1 = @client.init(params).get
|
168
171
|
res2 = nil
|
169
172
|
assert_nothing_raised do
|
170
173
|
res2 = @client.init({ name: 'key1', reset_interval: 10 }, options: { ignore: true }).get
|
@@ -312,7 +315,8 @@ class CounterClientTest < ::Test::Unit::TestCase
|
|
312
315
|
test 'raise an error when @scope is nil' do
|
313
316
|
@client.instance_variable_set(:@scope, nil)
|
314
317
|
assert_raise 'Call `establish` method to get a `scope` before calling this method' do
|
315
|
-
|
318
|
+
params = { name: 'name', value: 1 }
|
319
|
+
@client.inc(params).get
|
316
320
|
end
|
317
321
|
end
|
318
322
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"host": "127.0.0.1",
|
4
|
+
"port": 24224,
|
5
|
+
"weight": 1,
|
6
|
+
"name": "test1",
|
7
|
+
"standby": false,
|
8
|
+
"username": "user1",
|
9
|
+
"password": "pass1",
|
10
|
+
"shared_key": "key1"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"host": "127.0.0.1",
|
14
|
+
"port": 24225,
|
15
|
+
"weight": 1
|
16
|
+
}
|
17
|
+
]
|
@@ -16,7 +16,7 @@ class HandshakeProtocolTest < Test::Unit::TestCase
|
|
16
16
|
handshake.invoke(sock, ri, ['HELO', {}])
|
17
17
|
|
18
18
|
assert_equal(ri.state, :pingpong)
|
19
|
-
Fluent::
|
19
|
+
Fluent::MessagePackFactory.msgpack_unpacker.feed_each(sock.string) do |ping|
|
20
20
|
assert_equal(ping.size, 6)
|
21
21
|
assert_equal(ping[0], 'PING')
|
22
22
|
assert_equal(ping[1], hostname)
|
@@ -38,7 +38,7 @@ class HandshakeProtocolTest < Test::Unit::TestCase
|
|
38
38
|
handshake.invoke(sock, ri, ['HELO', { 'auth' => 'auth' }])
|
39
39
|
|
40
40
|
assert_equal(ri.state, :pingpong)
|
41
|
-
Fluent::
|
41
|
+
Fluent::MessagePackFactory.msgpack_unpacker.feed_each(sock.string) do |ping|
|
42
42
|
assert_equal(ping.size, 6)
|
43
43
|
assert_equal(ping[0], 'PING')
|
44
44
|
assert_equal(ping[1], hostname)
|
@@ -5,7 +5,7 @@ require 'fluent/plugin/out_forward/load_balancer'
|
|
5
5
|
|
6
6
|
class LoadBalancerTest < Test::Unit::TestCase
|
7
7
|
sub_test_case 'select_healthy_node' do
|
8
|
-
test 'select
|
8
|
+
test 'select healthy node' do
|
9
9
|
lb = Fluent::Plugin::ForwardOutput::LoadBalancer.new($log)
|
10
10
|
n1 = flexmock('node', :'standby?' => false, :'available?' => false, weight: 1)
|
11
11
|
n2 = flexmock('node', :'standby?' => false, :'available?' => true, weight: 1)
|
@@ -23,7 +23,7 @@ class SocketCacheTest < Test::Unit::TestCase
|
|
23
23
|
|
24
24
|
test 'when given key exists but used by other' do
|
25
25
|
c = Fluent::Plugin::ForwardOutput::SocketCache.new(10, $log)
|
26
|
-
assert_equal(
|
26
|
+
assert_equal('sock', c.checkout_or('key') { 'sock' })
|
27
27
|
|
28
28
|
new_sock = 'new sock'
|
29
29
|
sock = mock!.open { new_sock }.subject
|
@@ -32,7 +32,7 @@ class SocketCacheTest < Test::Unit::TestCase
|
|
32
32
|
|
33
33
|
test "when given key's value was expired" do
|
34
34
|
c = Fluent::Plugin::ForwardOutput::SocketCache.new(0, $log)
|
35
|
-
assert_equal(
|
35
|
+
assert_equal('sock', c.checkout_or('key') { 'sock' })
|
36
36
|
|
37
37
|
new_sock = 'new sock'
|
38
38
|
sock = mock!.open { new_sock }.subject
|
@@ -327,6 +327,46 @@ class FileBufferTest < Test::Unit::TestCase
|
|
327
327
|
plugin.stop; plugin.before_shutdown; plugin.shutdown; plugin.after_shutdown; plugin.close; plugin.terminate
|
328
328
|
FileUtils.rm_r bufdir
|
329
329
|
end
|
330
|
+
|
331
|
+
test '#generate_chunk generates blank file chunk with specified permission with system_config' do
|
332
|
+
omit "NTFS doesn't support UNIX like permissions" if Fluent.windows?
|
333
|
+
|
334
|
+
begin
|
335
|
+
plugin = Fluent::Plugin::FileBuffer.new
|
336
|
+
plugin.owner = @d
|
337
|
+
rand_num = rand(0..100)
|
338
|
+
bufpath = File.join(File.expand_path("../../tmp/buffer_file_#{rand_num}", __FILE__), 'testbuf.*.log')
|
339
|
+
bufdir = File.dirname(bufpath)
|
340
|
+
|
341
|
+
FileUtils.rm_r bufdir if File.exist?(bufdir)
|
342
|
+
assert !File.exist?(bufdir)
|
343
|
+
|
344
|
+
plugin.configure(config_element('buffer', '', { 'path' => bufpath }))
|
345
|
+
|
346
|
+
assert !File.exist?(bufdir)
|
347
|
+
plugin.start
|
348
|
+
|
349
|
+
m = metadata()
|
350
|
+
c = nil
|
351
|
+
Fluent::SystemConfig.overwrite_system_config("file_permission" => "700") do
|
352
|
+
c = plugin.generate_chunk(m)
|
353
|
+
end
|
354
|
+
|
355
|
+
assert c.is_a? Fluent::Plugin::Buffer::FileChunk
|
356
|
+
assert_equal m, c.metadata
|
357
|
+
assert c.empty?
|
358
|
+
assert_equal :unstaged, c.state
|
359
|
+
assert_equal 0700, c.permission
|
360
|
+
assert_equal bufpath.gsub('.*.', ".b#{Fluent::UniqueId.hex(c.unique_id)}."), c.path
|
361
|
+
assert{ File.stat(c.path).mode.to_s(8).end_with?('700') }
|
362
|
+
|
363
|
+
c.purge
|
364
|
+
|
365
|
+
plugin.stop; plugin.before_shutdown; plugin.shutdown; plugin.after_shutdown; plugin.close; plugin.terminate
|
366
|
+
ensure
|
367
|
+
FileUtils.rm_r bufdir
|
368
|
+
end
|
369
|
+
end
|
330
370
|
end
|
331
371
|
|
332
372
|
sub_test_case 'configured with system root directory and plugin @id' do
|
@@ -293,6 +293,38 @@ class FileSingleBufferTest < Test::Unit::TestCase
|
|
293
293
|
|
294
294
|
c.purge
|
295
295
|
end
|
296
|
+
|
297
|
+
test '#generate_chunk generates blank file chunk with specified permission with system_config' do
|
298
|
+
omit "NTFS doesn't support UNIX like permissions" if Fluent.windows?
|
299
|
+
|
300
|
+
@d = create_driver(%[
|
301
|
+
<buffer tag>
|
302
|
+
@type file_single
|
303
|
+
path #{PATH}
|
304
|
+
</buffer>
|
305
|
+
])
|
306
|
+
@p = @d.instance.buffer
|
307
|
+
|
308
|
+
FileUtils.rm_r @bufdir if File.exist?(@bufdir)
|
309
|
+
assert !File.exist?(@bufdir)
|
310
|
+
|
311
|
+
@p.start
|
312
|
+
|
313
|
+
m = metadata()
|
314
|
+
c = nil
|
315
|
+
Fluent::SystemConfig.overwrite_system_config("file_permission" => "700") do
|
316
|
+
c = @p.generate_chunk(m)
|
317
|
+
end
|
318
|
+
assert c.is_a? Fluent::Plugin::Buffer::FileSingleChunk
|
319
|
+
assert_equal m, c.metadata
|
320
|
+
assert c.empty?
|
321
|
+
assert_equal :unstaged, c.state
|
322
|
+
assert_equal 0700, c.permission
|
323
|
+
assert_equal File.join(@bufdir, "fsb.testing.b#{Fluent::UniqueId.hex(c.unique_id)}.buf"), c.path
|
324
|
+
assert{ File.stat(c.path).mode.to_s(8).end_with?('700') }
|
325
|
+
|
326
|
+
c.purge
|
327
|
+
end
|
296
328
|
end
|
297
329
|
|
298
330
|
sub_test_case 'configured with system root directory and plugin @id' do
|
@@ -416,17 +416,6 @@ class BufferFileChunkTest < Test::Unit::TestCase
|
|
416
416
|
assert_equal d4.to_json + "\n", lines[3]
|
417
417
|
end
|
418
418
|
|
419
|
-
test 'can refer system config for file permission' do
|
420
|
-
omit "NTFS doesn't support UNIX like permissions" if Fluent.windows?
|
421
|
-
|
422
|
-
chunk_path = File.join(@chunkdir, 'testperm.*.log')
|
423
|
-
Fluent::SystemConfig.overwrite_system_config("file_permission" => "600") do
|
424
|
-
c = Fluent::Plugin::Buffer::FileChunk.new(gen_metadata, chunk_path, :create)
|
425
|
-
assert{ File.stat(c.path).mode.to_s(8).end_with?('600') }
|
426
|
-
assert{ File.stat(c.path + '.meta').mode.to_s(8).end_with?('600') }
|
427
|
-
end
|
428
|
-
end
|
429
|
-
|
430
419
|
test '#write_metadata tries to store metadata on file' do
|
431
420
|
d1 = {"f1" => 'v1', "f2" => 'v2', "f3" => 'v3'}
|
432
421
|
d2 = {"f1" => 'vv1', "f2" => 'vv2', "f3" => 'vv3'}
|
@@ -353,16 +353,6 @@ class BufferFileSingleChunkTest < Test::Unit::TestCase
|
|
353
353
|
assert_equal d3.to_json + "\n", lines[2]
|
354
354
|
assert_equal d4.to_json + "\n", lines[3]
|
355
355
|
end
|
356
|
-
|
357
|
-
test 'can refer system config for file permission' do
|
358
|
-
omit "NTFS doesn't support UNIX like permissions" if Fluent.windows?
|
359
|
-
|
360
|
-
chunk_path = File.join(@chunkdir, 'fsb.*.buf')
|
361
|
-
Fluent::SystemConfig.overwrite_system_config("file_permission" => "600") do
|
362
|
-
c = Fluent::Plugin::Buffer::FileSingleChunk.new(gen_metadata, chunk_path, :create, nil)
|
363
|
-
assert{ File.stat(c.path).mode.to_s(8).end_with?('600') }
|
364
|
-
end
|
365
|
-
end
|
366
356
|
end
|
367
357
|
|
368
358
|
sub_test_case 'chunk with file for staged chunk' do
|
@@ -54,6 +54,15 @@ class CsvFormatterTest < ::Test::Unit::TestCase
|
|
54
54
|
assert_equal("\"awesome\",\"awesome2\"\n", formatted)
|
55
55
|
end
|
56
56
|
|
57
|
+
def test_format_with_nested_fields
|
58
|
+
d = create_driver("fields" => "message,$.nest.key")
|
59
|
+
formatted = d.instance.format(tag, @time, {
|
60
|
+
'message' => 'awesome',
|
61
|
+
'nest' => {'key' => 'awesome2'}
|
62
|
+
})
|
63
|
+
assert_equal("\"awesome\",\"awesome2\"\n", formatted)
|
64
|
+
end
|
65
|
+
|
57
66
|
def test_format_without_newline
|
58
67
|
d = create_driver("fields" => "message,message2", "add_newline" => false)
|
59
68
|
formatted = d.instance.format(tag, @time, {
|
@@ -538,7 +538,7 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
538
538
|
chunk = ["tag1", entries, { 'compressed' => 'gzip' }].to_msgpack
|
539
539
|
|
540
540
|
d.run do
|
541
|
-
Fluent::
|
541
|
+
Fluent::MessagePackFactory.msgpack_unpacker.feed_each(chunk) do |obj|
|
542
542
|
option = d.instance.send(:on_message, obj, chunk.size, DUMMY_SOCK)
|
543
543
|
assert_equal 'gzip', option['compressed']
|
544
544
|
end
|
@@ -568,7 +568,7 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
568
568
|
mock(Fluent::CompressedMessagePackEventStream).new(entries, nil, 0)
|
569
569
|
|
570
570
|
d.run do
|
571
|
-
Fluent::
|
571
|
+
Fluent::MessagePackFactory.msgpack_unpacker.feed_each(chunk) do |obj|
|
572
572
|
option = d.instance.send(:on_message, obj, chunk.size, DUMMY_SOCK)
|
573
573
|
assert_equal 'gzip', option['compressed']
|
574
574
|
end
|
@@ -592,7 +592,7 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
592
592
|
assert chunk.size < (32 * 1024 * 1024)
|
593
593
|
|
594
594
|
d.run(shutdown: false) do
|
595
|
-
Fluent::
|
595
|
+
Fluent::MessagePackFactory.msgpack_unpacker.feed_each(chunk) do |obj|
|
596
596
|
d.instance.send(:on_message, obj, chunk.size, DUMMY_SOCK)
|
597
597
|
end
|
598
598
|
end
|
@@ -624,7 +624,7 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
624
624
|
chunk = [ "test.tag", (0...16).map{|i| [time + i, {"data" => str}] } ].to_msgpack
|
625
625
|
|
626
626
|
d.run(shutdown: false) do
|
627
|
-
Fluent::
|
627
|
+
Fluent::MessagePackFactory.msgpack_unpacker.feed_each(chunk) do |obj|
|
628
628
|
d.instance.send(:on_message, obj, chunk.size, DUMMY_SOCK)
|
629
629
|
end
|
630
630
|
end
|
@@ -654,7 +654,7 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
654
654
|
|
655
655
|
# d.run => send_data
|
656
656
|
d.run(shutdown: false) do
|
657
|
-
Fluent::
|
657
|
+
Fluent::MessagePackFactory.msgpack_unpacker.feed_each(chunk) do |obj|
|
658
658
|
d.instance.send(:on_message, obj, chunk.size, DUMMY_SOCK)
|
659
659
|
end
|
660
660
|
end
|
@@ -1004,11 +1004,11 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
1004
1004
|
end
|
1005
1005
|
|
1006
1006
|
def packer(*args)
|
1007
|
-
Fluent::
|
1007
|
+
Fluent::MessagePackFactory.msgpack_packer(*args)
|
1008
1008
|
end
|
1009
1009
|
|
1010
1010
|
def unpacker
|
1011
|
-
Fluent::
|
1011
|
+
Fluent::MessagePackFactory.msgpack_unpacker
|
1012
1012
|
end
|
1013
1013
|
|
1014
1014
|
# res
|
@@ -1158,9 +1158,9 @@ class ForwardInputTest < Test::Unit::TestCase
|
|
1158
1158
|
execute_test_with_source_hostname_key(*keys) { |events|
|
1159
1159
|
entries = ''
|
1160
1160
|
events.each { |tag, time, record|
|
1161
|
-
Fluent::
|
1161
|
+
Fluent::MessagePackFactory.msgpack_packer(entries).write([time, record]).flush
|
1162
1162
|
}
|
1163
|
-
send_data Fluent::
|
1163
|
+
send_data Fluent::MessagePackFactory.msgpack_packer.write(["tag1", entries]).to_s
|
1164
1164
|
}
|
1165
1165
|
end
|
1166
1166
|
end
|
@@ -12,6 +12,8 @@ require_relative '../test_plugin_classes'
|
|
12
12
|
class MonitorAgentInputTest < Test::Unit::TestCase
|
13
13
|
include FuzzyAssert
|
14
14
|
|
15
|
+
CONFIG_DIR = File.expand_path('../tmp/in_monitor_agent', __dir__)
|
16
|
+
|
15
17
|
def setup
|
16
18
|
Fluent::Test.setup
|
17
19
|
end
|
@@ -160,9 +162,20 @@ EOC
|
|
160
162
|
test "fluentd opts" do
|
161
163
|
d = create_driver
|
162
164
|
opts = Fluent::Supervisor.default_options
|
163
|
-
|
165
|
+
|
166
|
+
filepath = nil
|
167
|
+
begin
|
168
|
+
FileUtils.mkdir_p(CONFIG_DIR)
|
169
|
+
filepath = File.expand_path('fluentd.conf', CONFIG_DIR)
|
170
|
+
FileUtils.touch(filepath)
|
171
|
+
s = Fluent::Supervisor.new(opts.merge(config_path: filepath))
|
172
|
+
s.configure
|
173
|
+
ensure
|
174
|
+
FileUtils.rm_r(CONFIG_DIR) rescue _
|
175
|
+
end
|
176
|
+
|
164
177
|
expected_opts = {
|
165
|
-
"config_path" =>
|
178
|
+
"config_path" => filepath,
|
166
179
|
"pid_file" => nil,
|
167
180
|
"plugin_dirs" => ["/etc/fluent/plugin"],
|
168
181
|
"log_path" => nil,
|
@@ -279,11 +292,25 @@ EOC
|
|
279
292
|
</match>
|
280
293
|
</label>
|
281
294
|
EOC
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
295
|
+
|
296
|
+
|
297
|
+
begin
|
298
|
+
@ra = Fluent::RootAgent.new(log: $log)
|
299
|
+
stub(Fluent::Engine).root_agent { @ra }
|
300
|
+
@ra = configure_ra(@ra, conf)
|
301
|
+
# store Supervisor instance to avoid collected by GC
|
302
|
+
|
303
|
+
FileUtils.mkdir_p(CONFIG_DIR)
|
304
|
+
@filepath = File.expand_path('fluentd.conf', CONFIG_DIR)
|
305
|
+
File.open(@filepath, 'w') do |v|
|
306
|
+
v.puts(conf)
|
307
|
+
end
|
308
|
+
|
309
|
+
@supervisor = Fluent::Supervisor.new(Fluent::Supervisor.default_options.merge(config_path: @filepath))
|
310
|
+
@supervisor.configure
|
311
|
+
ensure
|
312
|
+
FileUtils.rm_r(CONFIG_DIR) rescue _
|
313
|
+
end
|
287
314
|
end
|
288
315
|
|
289
316
|
test "/api/plugins" do
|
@@ -469,8 +496,7 @@ plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:f
|
|
469
496
|
tag monitor
|
470
497
|
")
|
471
498
|
d.instance.start
|
472
|
-
expected_response_regex =
|
473
|
-
|
499
|
+
expected_response_regex = %r{pid:\d+\tppid:\d+\tversion:#{Fluent::VERSION}\tconfig_path:#{@filepath}\tpid_file:\tplugin_dirs:/etc/fluent/plugin\tlog_path:}
|
474
500
|
assert_match(expected_response_regex,
|
475
501
|
get("http://127.0.0.1:#{@port}/api/config").body)
|
476
502
|
end
|
@@ -484,10 +510,11 @@ plugin_id:test_filter\tplugin_category:filter\ttype:test_filter\toutput_plugin:f
|
|
484
510
|
")
|
485
511
|
d.instance.start
|
486
512
|
res = JSON.parse(get("http://127.0.0.1:#{@port}/api/config.json").body)
|
487
|
-
assert_equal(
|
513
|
+
assert_equal(@filepath, res["config_path"])
|
488
514
|
assert_nil(res["pid_file"])
|
489
515
|
assert_equal(["/etc/fluent/plugin"], res["plugin_dirs"])
|
490
516
|
assert_nil(res["log_path"])
|
517
|
+
assert_equal(Fluent::VERSION, res["version"])
|
491
518
|
end
|
492
519
|
|
493
520
|
test "/api/config.json?debug=1" do
|
data/test/plugin/test_in_unix.rb
CHANGED
@@ -18,7 +18,7 @@ module StreamInputTest
|
|
18
18
|
|
19
19
|
d.run do
|
20
20
|
d.expected_emits.each {|tag,_time,record|
|
21
|
-
send_data Fluent::
|
21
|
+
send_data Fluent::MessagePackFactory.msgpack_packer.write([tag, 0, record]).to_s
|
22
22
|
}
|
23
23
|
end
|
24
24
|
end
|
@@ -33,7 +33,7 @@ module StreamInputTest
|
|
33
33
|
|
34
34
|
d.run do
|
35
35
|
d.expected_emits.each {|tag,_time,record|
|
36
|
-
send_data Fluent::
|
36
|
+
send_data Fluent::MessagePackFactory.msgpack_packer.write([tag, _time, record]).to_s
|
37
37
|
}
|
38
38
|
end
|
39
39
|
end
|
@@ -51,7 +51,7 @@ module StreamInputTest
|
|
51
51
|
d.expected_emits.each {|tag,_time,record|
|
52
52
|
entries << [_time, record]
|
53
53
|
}
|
54
|
-
send_data Fluent::
|
54
|
+
send_data Fluent::MessagePackFactory.msgpack_packer.write(["tag1", entries]).to_s
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -66,9 +66,9 @@ module StreamInputTest
|
|
66
66
|
d.run do
|
67
67
|
entries = ''
|
68
68
|
d.expected_emits.each {|tag,_time,record|
|
69
|
-
Fluent::
|
69
|
+
Fluent::MessagePackFactory.msgpack_packer(entries).write([_time, record]).flush
|
70
70
|
}
|
71
|
-
send_data Fluent::
|
71
|
+
send_data Fluent::MessagePackFactory.msgpack_packer.write(["tag1", entries]).to_s
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|