fluentd 0.14.10 → 0.14.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +14 -6
- data/ChangeLog +28 -2
- data/appveyor.yml +1 -0
- data/lib/fluent/engine.rb +4 -7
- data/lib/fluent/error.rb +30 -0
- data/lib/fluent/log.rb +0 -7
- data/lib/fluent/plugin/base.rb +11 -0
- data/lib/fluent/plugin/buf_file.rb +9 -7
- data/lib/fluent/plugin/formatter_csv.rb +4 -2
- data/lib/fluent/plugin/in_forward.rb +46 -17
- data/lib/fluent/plugin/in_http.rb +2 -0
- data/lib/fluent/plugin/in_monitor_agent.rb +27 -2
- data/lib/fluent/plugin/in_syslog.rb +52 -36
- data/lib/fluent/plugin/in_tail.rb +1 -0
- data/lib/fluent/plugin/out_forward.rb +39 -29
- data/lib/fluent/plugin/output.rb +17 -0
- data/lib/fluent/plugin/storage_local.rb +16 -13
- data/lib/fluent/plugin_helper/storage.rb +21 -9
- data/lib/fluent/plugin_id.rb +17 -0
- data/lib/fluent/supervisor.rb +73 -45
- data/lib/fluent/system_config.rb +24 -21
- data/lib/fluent/version.rb +1 -1
- data/test/command/test_fluentd.rb +348 -0
- data/test/config/test_system_config.rb +39 -31
- data/test/plugin/test_base.rb +20 -0
- data/test/plugin/test_buf_file.rb +40 -0
- data/test/plugin/test_formatter_csv.rb +8 -0
- data/test/plugin/test_in_forward.rb +56 -21
- data/test/plugin/test_in_monitor_agent.rb +80 -8
- data/test/plugin/test_in_syslog.rb +75 -45
- data/test/plugin/test_out_file.rb +0 -1
- data/test/plugin/test_out_forward.rb +19 -11
- data/test/plugin/test_output.rb +44 -0
- data/test/plugin/test_storage_local.rb +290 -2
- data/test/plugin_helper/test_child_process.rb +40 -39
- data/test/plugin_helper/test_storage.rb +4 -3
- data/test/test_log.rb +1 -1
- data/test/test_output.rb +3 -0
- data/test/test_plugin_id.rb +101 -0
- data/test/test_supervisor.rb +3 -0
- metadata +7 -2
|
@@ -23,6 +23,7 @@ class ChildProcessTest < Test::Unit::TestCase
|
|
|
23
23
|
@d.shutdown unless @d.shutdown?
|
|
24
24
|
@d.close unless @d.closed?
|
|
25
25
|
@d.terminate unless @d.terminated?
|
|
26
|
+
@d.log.reset
|
|
26
27
|
end
|
|
27
28
|
end
|
|
28
29
|
|
|
@@ -226,55 +227,55 @@ class ChildProcessTest < Test::Unit::TestCase
|
|
|
226
227
|
end
|
|
227
228
|
end
|
|
228
229
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
rescue
|
|
244
|
-
# ignore
|
|
245
|
-
ensure
|
|
246
|
-
m.unlock
|
|
230
|
+
# In windows environment, child_process try KILL at first (because there's no SIGTERM)
|
|
231
|
+
test 'can execute external command just once, and can terminate it forcedly when shutdown/terminate even if it ignore SIGTERM' do
|
|
232
|
+
omit "SIGTERM is unavailable on Windows" if Fluent.windows?
|
|
233
|
+
|
|
234
|
+
m = Mutex.new
|
|
235
|
+
ary = []
|
|
236
|
+
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
|
|
237
|
+
ran = false
|
|
238
|
+
@d.child_process_execute(:t4, "ruby -e 'Signal.trap(:TERM, nil); while sleep #{TEST_WAIT_INTERVAL_FOR_LOOP}; puts 1; STDOUT.flush rescue nil; end'", mode: [:read]) do |io|
|
|
239
|
+
m.lock
|
|
240
|
+
ran = true
|
|
241
|
+
begin
|
|
242
|
+
while line = io.readline
|
|
243
|
+
ary << line
|
|
247
244
|
end
|
|
245
|
+
rescue
|
|
246
|
+
# ignore
|
|
247
|
+
ensure
|
|
248
|
+
m.unlock
|
|
248
249
|
end
|
|
249
|
-
|
|
250
|
+
end
|
|
251
|
+
sleep TEST_WAIT_INTERVAL_FOR_BLOCK_RUNNING until m.locked? || ran
|
|
250
252
|
|
|
251
|
-
|
|
253
|
+
assert_equal [], @d.log.out.logs
|
|
252
254
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
@d.stop # nothing occurs
|
|
256
|
+
sleep TEST_WAIT_INTERVAL_FOR_LOOP * 5
|
|
257
|
+
lines1 = ary.size
|
|
258
|
+
assert{ lines1 > 1 }
|
|
257
259
|
|
|
258
|
-
|
|
260
|
+
pid = @d._child_process_processes.keys.first
|
|
259
261
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
@d.shutdown
|
|
263
|
+
sleep TEST_WAIT_INTERVAL_FOR_LOOP * 5
|
|
264
|
+
lines2 = ary.size
|
|
265
|
+
assert{ lines2 > lines1 }
|
|
264
266
|
|
|
265
|
-
|
|
267
|
+
@d.close
|
|
266
268
|
|
|
267
|
-
|
|
269
|
+
assert_nil((Process.waitpid(pid, Process::WNOHANG) rescue nil))
|
|
268
270
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
end
|
|
275
|
-
# Process successfully KILLed if test reaches here
|
|
276
|
-
assert true
|
|
271
|
+
@d.terminate
|
|
272
|
+
assert @d._child_process_processes.empty?
|
|
273
|
+
begin
|
|
274
|
+
Process.waitpid(pid)
|
|
275
|
+
rescue Errno::ECHILD
|
|
277
276
|
end
|
|
277
|
+
# Process successfully KILLed if test reaches here
|
|
278
|
+
assert true
|
|
278
279
|
end
|
|
279
280
|
end
|
|
280
281
|
|
|
@@ -102,7 +102,8 @@ class StorageHelperTest < Test::Unit::TestCase
|
|
|
102
102
|
test 'can override default configuration parameters, but not overwrite whole definition' do
|
|
103
103
|
d = Dummy.new
|
|
104
104
|
d.configure(config_element())
|
|
105
|
-
assert_equal
|
|
105
|
+
assert_equal 1, d.storage_configs.size
|
|
106
|
+
assert_equal 'local', d.storage_configs.first[:@type]
|
|
106
107
|
|
|
107
108
|
d = Dummy2.new
|
|
108
109
|
d.configure(config_element('ROOT', '', {}, [config_element('storage', '', {}, [])]))
|
|
@@ -130,7 +131,7 @@ class StorageHelperTest < Test::Unit::TestCase
|
|
|
130
131
|
d = Dummy2.new
|
|
131
132
|
d.configure(config_element())
|
|
132
133
|
assert_raise Fluent::ConfigError.new("@type is required in <storage>") do
|
|
133
|
-
d.storage_create(conf: config_element('storage', '', {}), default_type: 'ex2')
|
|
134
|
+
d.storage_create(conf: config_element('storage', 'foo', {}), default_type: 'ex2')
|
|
134
135
|
end
|
|
135
136
|
end
|
|
136
137
|
|
|
@@ -139,7 +140,7 @@ class StorageHelperTest < Test::Unit::TestCase
|
|
|
139
140
|
assert_nothing_raised do
|
|
140
141
|
d.configure(config_element())
|
|
141
142
|
end
|
|
142
|
-
assert_equal
|
|
143
|
+
assert_equal 1, d._storages.size
|
|
143
144
|
end
|
|
144
145
|
|
|
145
146
|
test 'can be configured with a storage section' do
|
data/test/test_log.rb
CHANGED
data/test/test_output.rb
CHANGED
|
@@ -246,6 +246,9 @@ module FluentOutputTest
|
|
|
246
246
|
d.instance.after_start
|
|
247
247
|
d.instance.emit_events('test', OneEventStream.new(event_time("2016-11-08 17:44:30 +0900"), {"message" => "yay"}))
|
|
248
248
|
d.instance.force_flush
|
|
249
|
+
waiting(10) do
|
|
250
|
+
sleep 0.1 until d.instance.written_chunk_keys.size == 1
|
|
251
|
+
end
|
|
249
252
|
assert_equal [], d.instance.errors_in_write
|
|
250
253
|
assert_equal ["2016110808"], d.instance.written_chunk_keys # default timezone is UTC
|
|
251
254
|
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
require_relative 'helper'
|
|
2
|
+
require 'fluent/plugin/base'
|
|
3
|
+
require 'fluent/system_config'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
|
|
6
|
+
class PluginIdTest < Test::Unit::TestCase
|
|
7
|
+
TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/tmp/plugin_id/#{ENV['TEST_ENV_NUMBER']}")
|
|
8
|
+
|
|
9
|
+
class MyPlugin < Fluent::Plugin::Base
|
|
10
|
+
include Fluent::PluginId
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
setup do
|
|
14
|
+
@p = MyPlugin.new
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
sub_test_case '#plugin_id_for_test?' do
|
|
18
|
+
test 'returns true always in test files' do
|
|
19
|
+
assert @p.plugin_id_for_test?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
test 'returns false always out of test files' do
|
|
23
|
+
# TODO: no good way to write this test....
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
sub_test_case 'configured without @id' do
|
|
28
|
+
setup do
|
|
29
|
+
@p.configure(config_element())
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
test '#plugin_id_configured? returns false' do
|
|
33
|
+
assert_false @p.plugin_id_configured?
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
test '#plugin_id returns object_id based string' do
|
|
37
|
+
assert_kind_of String, @p.plugin_id
|
|
38
|
+
assert @p.plugin_id =~ /^object:[0-9a-f]+/
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
test '#plugin_root_dir returns nil' do
|
|
42
|
+
assert_nil @p.plugin_root_dir
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
sub_test_case 'configured with @id' do
|
|
47
|
+
setup do
|
|
48
|
+
FileUtils.rm_rf(TMP_DIR)
|
|
49
|
+
FileUtils.mkdir_p(TMP_DIR)
|
|
50
|
+
@p.configure(config_element('ROOT', '', {'@id' => 'testing_plugin_id'}))
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
test '#plugin_id_configured? returns true' do
|
|
54
|
+
assert @p.plugin_id_configured?
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
test '#plugin_id returns the configured value' do
|
|
58
|
+
assert_equal 'testing_plugin_id', @p.plugin_id
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
test '#plugin_root_dir returns nil without system root directory configuration' do
|
|
62
|
+
assert_nil @p.plugin_root_dir
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
test '#plugin_root_dir returns an existing directory path frozen String' do
|
|
66
|
+
root_dir = Fluent::SystemConfig.overwrite_system_config('root_dir' => File.join(TMP_DIR, "myroot")) do
|
|
67
|
+
@p.plugin_root_dir
|
|
68
|
+
end
|
|
69
|
+
assert_kind_of String, root_dir
|
|
70
|
+
assert Dir.exist?(root_dir)
|
|
71
|
+
assert root_dir =~ %r!/worker0/!
|
|
72
|
+
assert root_dir.frozen?
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
test '#plugin_root_dir returns the same value for 2nd or more call' do
|
|
76
|
+
root_dir = Fluent::SystemConfig.overwrite_system_config('root_dir' => File.join(TMP_DIR, "myroot")) do
|
|
77
|
+
@p.plugin_root_dir
|
|
78
|
+
end
|
|
79
|
+
twice = Fluent::SystemConfig.overwrite_system_config('root_dir' => File.join(TMP_DIR, "myroot")) do
|
|
80
|
+
@p.plugin_root_dir
|
|
81
|
+
end
|
|
82
|
+
assert_equal root_dir.object_id, twice.object_id
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
test '#plugin_root_dir referres SERVERENGINE_WORKER_ID environment path to create it' do
|
|
86
|
+
prev_env_val = ENV['SERVERENGINE_WORKER_ID']
|
|
87
|
+
begin
|
|
88
|
+
ENV['SERVERENGINE_WORKER_ID'] = '7'
|
|
89
|
+
root_dir = Fluent::SystemConfig.overwrite_system_config('root_dir' => File.join(TMP_DIR, "myroot")) do
|
|
90
|
+
@p.plugin_root_dir
|
|
91
|
+
end
|
|
92
|
+
assert_kind_of String, root_dir
|
|
93
|
+
assert Dir.exist?(root_dir)
|
|
94
|
+
assert root_dir =~ %r!/worker7/!
|
|
95
|
+
assert root_dir.frozen?
|
|
96
|
+
ensure
|
|
97
|
+
ENV['SERVERENGINE_WORKER_ID'] = prev_env_val
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
data/test/test_supervisor.rb
CHANGED
|
@@ -15,6 +15,7 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
|
15
15
|
include WorkerModule
|
|
16
16
|
|
|
17
17
|
TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/tmp/supervisor#{ENV['TEST_ENV_NUMBER']}")
|
|
18
|
+
TMP_ROOT_DIR = File.join(TMP_DIR, 'root')
|
|
18
19
|
|
|
19
20
|
def setup
|
|
20
21
|
FileUtils.rm_rf(TMP_DIR)
|
|
@@ -85,6 +86,7 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
|
85
86
|
enable_get_dump true
|
|
86
87
|
process_name "process_name"
|
|
87
88
|
log_level info
|
|
89
|
+
root_dir #{TMP_ROOT_DIR}
|
|
88
90
|
</system>
|
|
89
91
|
EOC
|
|
90
92
|
conf = Fluent::Config.parse(conf_data, "(test)", "(test_dir)", true)
|
|
@@ -99,6 +101,7 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
|
99
101
|
assert_equal true, sys_conf.enable_get_dump
|
|
100
102
|
assert_equal "process_name", sys_conf.process_name
|
|
101
103
|
assert_equal 2, sys_conf.log_level
|
|
104
|
+
assert_equal TMP_ROOT_DIR, sys_conf.root_dir
|
|
102
105
|
end
|
|
103
106
|
|
|
104
107
|
def test_main_process_signal_handlers
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluentd
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.14.
|
|
4
|
+
version: 0.14.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sadayuki Furuhashi
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-12-
|
|
11
|
+
date: 2016-12-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: msgpack
|
|
@@ -381,6 +381,7 @@ files:
|
|
|
381
381
|
- lib/fluent/daemon.rb
|
|
382
382
|
- lib/fluent/engine.rb
|
|
383
383
|
- lib/fluent/env.rb
|
|
384
|
+
- lib/fluent/error.rb
|
|
384
385
|
- lib/fluent/event.rb
|
|
385
386
|
- lib/fluent/event_router.rb
|
|
386
387
|
- lib/fluent/filter.rb
|
|
@@ -519,6 +520,7 @@ files:
|
|
|
519
520
|
- lib/fluent/version.rb
|
|
520
521
|
- lib/fluent/winsvc.rb
|
|
521
522
|
- test/command/test_binlog_reader.rb
|
|
523
|
+
- test/command/test_fluentd.rb
|
|
522
524
|
- test/compat/test_calls_super.rb
|
|
523
525
|
- test/compat/test_parser.rb
|
|
524
526
|
- test/config/assertions.rb
|
|
@@ -643,6 +645,7 @@ files:
|
|
|
643
645
|
- test/test_output.rb
|
|
644
646
|
- test/test_plugin_classes.rb
|
|
645
647
|
- test/test_plugin_helper.rb
|
|
648
|
+
- test/test_plugin_id.rb
|
|
646
649
|
- test/test_process.rb
|
|
647
650
|
- test/test_root_agent.rb
|
|
648
651
|
- test/test_supervisor.rb
|
|
@@ -676,6 +679,7 @@ specification_version: 4
|
|
|
676
679
|
summary: Fluentd event collector
|
|
677
680
|
test_files:
|
|
678
681
|
- test/command/test_binlog_reader.rb
|
|
682
|
+
- test/command/test_fluentd.rb
|
|
679
683
|
- test/compat/test_calls_super.rb
|
|
680
684
|
- test/compat/test_parser.rb
|
|
681
685
|
- test/config/assertions.rb
|
|
@@ -800,6 +804,7 @@ test_files:
|
|
|
800
804
|
- test/test_output.rb
|
|
801
805
|
- test/test_plugin_classes.rb
|
|
802
806
|
- test/test_plugin_helper.rb
|
|
807
|
+
- test/test_plugin_id.rb
|
|
803
808
|
- test/test_process.rb
|
|
804
809
|
- test/test_root_agent.rb
|
|
805
810
|
- test/test_supervisor.rb
|