fluentd 0.14.4-x64-mingw32 → 0.14.5-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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +18 -0
  3. data/example/in_forward.conf +3 -0
  4. data/example/in_forward_client.conf +37 -0
  5. data/example/in_forward_shared_key.conf +15 -0
  6. data/example/in_forward_users.conf +24 -0
  7. data/example/out_forward.conf +13 -13
  8. data/example/out_forward_client.conf +109 -0
  9. data/example/out_forward_shared_key.conf +36 -0
  10. data/example/out_forward_users.conf +65 -0
  11. data/example/{out_buffered_null.conf → out_null.conf} +10 -6
  12. data/example/secondary_file.conf +41 -0
  13. data/lib/fluent/agent.rb +3 -1
  14. data/lib/fluent/plugin/buffer.rb +5 -1
  15. data/lib/fluent/plugin/in_forward.rb +300 -50
  16. data/lib/fluent/plugin/in_tail.rb +41 -85
  17. data/lib/fluent/plugin/multi_output.rb +4 -0
  18. data/lib/fluent/plugin/out_forward.rb +326 -209
  19. data/lib/fluent/plugin/out_null.rb +37 -0
  20. data/lib/fluent/plugin/out_secondary_file.rb +128 -0
  21. data/lib/fluent/plugin/out_stdout.rb +38 -2
  22. data/lib/fluent/plugin/output.rb +13 -5
  23. data/lib/fluent/root_agent.rb +1 -1
  24. data/lib/fluent/test/startup_shutdown.rb +33 -0
  25. data/lib/fluent/version.rb +1 -1
  26. data/test/plugin/test_in_forward.rb +906 -441
  27. data/test/plugin/test_in_monitor_agent.rb +4 -0
  28. data/test/plugin/test_in_tail.rb +681 -663
  29. data/test/plugin/test_out_forward.rb +150 -208
  30. data/test/plugin/test_out_null.rb +85 -9
  31. data/test/plugin/test_out_secondary_file.rb +432 -0
  32. data/test/plugin/test_out_stdout.rb +143 -45
  33. data/test/test_root_agent.rb +42 -0
  34. metadata +14 -9
  35. data/lib/fluent/plugin/out_buffered_null.rb +0 -59
  36. data/lib/fluent/plugin/out_buffered_stdout.rb +0 -70
  37. data/test/plugin/test_out_buffered_null.rb +0 -79
  38. data/test/plugin/test_out_buffered_stdout.rb +0 -122
@@ -14,70 +14,168 @@ class StdoutOutputTest < Test::Unit::TestCase
14
14
  Fluent::Test::Driver::Output.new(Fluent::Plugin::StdoutOutput).configure(conf)
15
15
  end
16
16
 
17
- def test_configure
18
- d = create_driver
19
- assert_equal [], d.instance.formatter_configs
20
- end
17
+ sub_test_case 'non-buffered' do
18
+ test 'configure' do
19
+ d = create_driver
20
+ assert_equal [], d.instance.formatter_configs
21
+ end
21
22
 
22
- def test_configure_output_type
23
- d = create_driver(CONFIG + "\noutput_type json")
24
- assert_equal 'json', d.instance.formatter_configs.first[:@type]
23
+ test 'configure output_type' do
24
+ d = create_driver(CONFIG + "\noutput_type json")
25
+ assert_equal 'json', d.instance.formatter_configs.first[:@type]
25
26
 
26
- d = create_driver(CONFIG + "\noutput_type hash")
27
- assert_equal 'hash', d.instance.formatter_configs.first[:@type]
27
+ d = create_driver(CONFIG + "\noutput_type hash")
28
+ assert_equal 'hash', d.instance.formatter_configs.first[:@type]
28
29
 
29
- assert_raise(Fluent::ConfigError) do
30
- d = create_driver(CONFIG + "\noutput_type foo")
30
+ assert_raise(Fluent::ConfigError) do
31
+ d = create_driver(CONFIG + "\noutput_type foo")
32
+ end
31
33
  end
32
- end
33
34
 
34
- def test_emit_in_default
35
- d = create_driver
36
- time = event_time()
37
- out = capture_log do
38
- d.run(default_tag: 'test') do
39
- d.feed(time, {'test' => 'test1'})
35
+ test 'emit with default configuration' do
36
+ d = create_driver
37
+ time = event_time()
38
+ out = capture_log do
39
+ d.run(default_tag: 'test') do
40
+ d.feed(time, {'test' => 'test1'})
41
+ end
40
42
  end
43
+ assert_equal "#{Time.at(time).localtime} test: {\"test\":\"test1\"}\n", out
41
44
  end
42
- assert_equal "#{Time.at(time).localtime} test: {\"test\":\"test1\"}\n", out
43
- end
44
45
 
45
- data('oj' => 'oj', 'yajl' => 'yajl')
46
- def test_emit_json(data)
47
- d = create_driver(CONFIG + "\noutput_type json\njson_parser #{data}")
48
- time = event_time()
49
- out = capture_log do
50
- d.run(default_tag: 'test') do
51
- d.feed(time, {'test' => 'test1'})
46
+ data('oj' => 'oj', 'yajl' => 'yajl')
47
+ test 'emit in json format' do |data|
48
+ d = create_driver(CONFIG + "\noutput_type json\njson_parser #{data}")
49
+ time = event_time()
50
+ out = capture_log do
51
+ d.run(default_tag: 'test') do
52
+ d.feed(time, {'test' => 'test1'})
53
+ end
54
+ end
55
+ assert_equal "#{Time.at(time).localtime} test: {\"test\":\"test1\"}\n", out
56
+
57
+ if data == 'yajl'
58
+ # NOTE: Float::NAN is not jsonable
59
+ assert_raise(Yajl::EncodeError) { d.feed('test', time, {'test' => Float::NAN}) }
60
+ else
61
+ out = capture_log { d.feed('test', time, {'test' => Float::NAN}) }
62
+ assert_equal "#{Time.at(time).localtime} test: {\"test\":NaN}\n", out
52
63
  end
53
64
  end
54
- assert_equal "#{Time.at(time).localtime} test: {\"test\":\"test1\"}\n", out
55
65
 
56
- if data == 'yajl'
57
- # NOTE: Float::NAN is not jsonable
58
- assert_raise(Yajl::EncodeError) { d.feed('test', time, {'test' => Float::NAN}) }
59
- else
66
+ test 'emit in hash format' do
67
+ d = create_driver(CONFIG + "\noutput_type hash")
68
+ time = event_time()
69
+ out = capture_log do
70
+ d.run(default_tag: 'test') do
71
+ d.feed(time, {'test' => 'test2'})
72
+ end
73
+ end
74
+ assert_equal "#{Time.at(time).localtime} test: {\"test\"=>\"test2\"}\n", out
75
+
76
+ # NOTE: Float::NAN is not jsonable, but hash string can output it.
60
77
  out = capture_log { d.feed('test', time, {'test' => Float::NAN}) }
61
- assert_equal "#{Time.at(time).localtime} test: {\"test\":NaN}\n", out
78
+ assert_equal "#{Time.at(time).localtime} test: {\"test\"=>NaN}\n", out
62
79
  end
63
80
  end
64
81
 
65
- def test_emit_hash
66
- d = create_driver(CONFIG + "\noutput_type hash")
67
- time = event_time()
68
- out = capture_log do
69
- d.run(default_tag: 'test') do
70
- d.feed(time, {'test' => 'test2'})
82
+ sub_test_case 'buffered' do
83
+ test 'configure' do
84
+ d = create_driver(config_element("ROOT", "", {}, [config_element("buffer")]))
85
+ assert_equal [], d.instance.formatter_configs
86
+ assert_equal 10 * 1024, d.instance.buffer_config.chunk_limit_size
87
+ assert d.instance.buffer_config.flush_at_shutdown
88
+ assert_equal ['tag'], d.instance.buffer_config.chunk_keys
89
+ assert d.instance.chunk_key_tag
90
+ assert !d.instance.chunk_key_time
91
+ assert_equal [], d.instance.chunk_keys
92
+ end
93
+
94
+ test 'configure with output_type' do
95
+ d = create_driver(config_element("ROOT", "", {"output_type" => "json"}, [config_element("buffer")]))
96
+ assert_equal 'json', d.instance.formatter_configs.first[:@type]
97
+
98
+ d = create_driver(config_element("ROOT", "", {"output_type" => "hash"}, [config_element("buffer")]))
99
+ assert_equal 'hash', d.instance.formatter_configs.first[:@type]
100
+
101
+ assert_raise(Fluent::ConfigError) do
102
+ create_driver(config_element("ROOT", "", {"output_type" => "foo"}, [config_element("buffer")]))
71
103
  end
72
104
  end
73
- assert_equal "#{Time.at(time).localtime} test: {\"test\"=>\"test2\"}\n", out
74
105
 
75
- # NOTE: Float::NAN is not jsonable, but hash string can output it.
76
- out = capture_log { d.feed('test', time, {'test' => Float::NAN}) }
77
- assert_equal "#{Time.at(time).localtime} test: {\"test\"=>NaN}\n", out
78
- end
106
+ sub_test_case "emit with default config" do
107
+ test '#write(synchronous)' do
108
+ d = create_driver(config_element("ROOT", "", {}, [config_element("buffer")]))
109
+ time = event_time()
110
+
111
+ out = capture_log do
112
+ d.run(default_tag: 'test', flush: true) do
113
+ d.feed(time, {'test' => 'test'})
114
+ end
115
+ end
116
+ assert_equal "#{Time.at(time).localtime} test: {\"test\":\"test\"}\n", out
117
+ end
118
+ end
79
119
 
80
- private
120
+ sub_test_case "emit json" do
121
+ data('oj' => 'oj', 'yajl' => 'yajl')
122
+ test '#write(synchronous)' do |data|
123
+ d = create_driver(config_element("ROOT", "", {"output_type" => "json", "json_parser" => data}, [config_element("buffer")]))
124
+ time = event_time()
125
+
126
+ out = capture_log do
127
+ d.run(default_tag: 'test', flush: true) do
128
+ d.feed(time, {'test' => 'test'})
129
+ end
130
+ end
131
+ assert_equal "#{Time.at(time).localtime} test: {\"test\":\"test\"}\n", out
132
+ end
133
+
134
+ data('oj' => 'oj', 'yajl' => 'yajl')
135
+ test '#try_write(asynchronous)' do |data|
136
+ d = create_driver(config_element("ROOT", "", {"output_type" => "json", "json_parser" => data}, [config_element("buffer")]))
137
+ time = event_time()
138
+ d.instance.delayed = true
139
+
140
+ out = capture_log do
141
+ d.run(default_tag: 'test', flush: true, shutdown: false) do
142
+ d.feed(time, {'test' => 'test'})
143
+ end
144
+ end
145
+
146
+ assert_equal "#{Time.at(time).localtime} test: {\"test\":\"test\"}\n", out
147
+ end
148
+ end
149
+
150
+ sub_test_case 'emit hash' do
151
+ test '#write(synchronous)' do
152
+ d = create_driver(config_element("ROOT", "", {"output_type" => "hash"}, [config_element("buffer")]))
153
+ time = event_time()
154
+
155
+ out = capture_log do
156
+ d.run(default_tag: 'test', flush: true) do
157
+ d.feed(time, {'test' => 'test'})
158
+ end
159
+ end
160
+
161
+ assert_equal "#{Time.at(time).localtime} test: {\"test\"=>\"test\"}\n", out
162
+ end
163
+
164
+ test '#try_write(asynchronous)' do
165
+ d = create_driver(config_element("ROOT", "", {"output_type" => "hash"}, [config_element("buffer")]))
166
+ time = event_time()
167
+ d.instance.delayed = true
168
+
169
+ out = capture_log do
170
+ d.run(default_tag: 'test', flush: true, shutdown: false) do
171
+ d.feed(time, {'test' => 'test'})
172
+ end
173
+ end
174
+
175
+ assert_equal "#{Time.at(time).localtime} test: {\"test\"=>\"test\"}\n", out
176
+ end
177
+ end
178
+ end
81
179
 
82
180
  # Capture the log output of the block given
83
181
  def capture_log(&block)
@@ -47,6 +47,48 @@ class RootAgentTest < ::Test::Unit::TestCase
47
47
  assert_nil ra.error_collector
48
48
  end
49
49
 
50
+ test 'raises configuration error for missing type of source' do
51
+ conf = <<-EOC
52
+ <source>
53
+ </source>
54
+ EOC
55
+ errmsg = "Missing '@type' parameter on <source> directive"
56
+ assert_raise Fluent::ConfigError.new(errmsg) do
57
+ configure_ra(conf)
58
+ end
59
+ end
60
+
61
+ test 'raises configuration error for missing type of match' do
62
+ conf = <<-EOC
63
+ <source>
64
+ @type test_in
65
+ </source>
66
+ <match *.**>
67
+ </match>
68
+ EOC
69
+ errmsg = "Missing '@type' parameter on <match> directive"
70
+ assert_raise Fluent::ConfigError.new(errmsg) do
71
+ configure_ra(conf)
72
+ end
73
+ end
74
+
75
+ test 'raises configuration error for missing type of filter' do
76
+ conf = <<-EOC
77
+ <source>
78
+ @type test_in
79
+ </source>
80
+ <filter *.**>
81
+ </filter>
82
+ <match *.**>
83
+ @type test_out
84
+ </match>
85
+ EOC
86
+ errmsg = "Missing '@type' parameter on <filter> directive"
87
+ assert_raise Fluent::ConfigError.new(errmsg) do
88
+ configure_ra(conf)
89
+ end
90
+ end
91
+
50
92
  test 'with plugins' do
51
93
  # check @type and type in one configuration
52
94
  conf = <<-EOC
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
4
+ version: 0.14.5
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-31 00:00:00.000000000 Z
11
+ date: 2016-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -361,6 +361,9 @@ files:
361
361
  - example/copy_roundrobin.conf
362
362
  - example/filter_stdout.conf
363
363
  - example/in_forward.conf
364
+ - example/in_forward_client.conf
365
+ - example/in_forward_shared_key.conf
366
+ - example/in_forward_users.conf
364
367
  - example/in_http.conf
365
368
  - example/in_out_forward.conf
366
369
  - example/in_syslog.conf
@@ -368,11 +371,15 @@ files:
368
371
  - example/in_tcp.conf
369
372
  - example/in_udp.conf
370
373
  - example/multi_filters.conf
371
- - example/out_buffered_null.conf
372
374
  - example/out_copy.conf
373
375
  - example/out_file.conf
374
376
  - example/out_forward.conf
375
377
  - example/out_forward_buf_file.conf
378
+ - example/out_forward_client.conf
379
+ - example/out_forward_shared_key.conf
380
+ - example/out_forward_users.conf
381
+ - example/out_null.conf
382
+ - example/secondary_file.conf
376
383
  - example/v0_12_filter.conf
377
384
  - example/v1_literal_example.conf
378
385
  - fluent.conf
@@ -472,8 +479,6 @@ files:
472
479
  - lib/fluent/plugin/in_unix.rb
473
480
  - lib/fluent/plugin/input.rb
474
481
  - lib/fluent/plugin/multi_output.rb
475
- - lib/fluent/plugin/out_buffered_null.rb
476
- - lib/fluent/plugin/out_buffered_stdout.rb
477
482
  - lib/fluent/plugin/out_copy.rb
478
483
  - lib/fluent/plugin/out_exec.rb
479
484
  - lib/fluent/plugin/out_exec_filter.rb
@@ -482,6 +487,7 @@ files:
482
487
  - lib/fluent/plugin/out_null.rb
483
488
  - lib/fluent/plugin/out_relabel.rb
484
489
  - lib/fluent/plugin/out_roundrobin.rb
490
+ - lib/fluent/plugin/out_secondary_file.rb
485
491
  - lib/fluent/plugin/out_stdout.rb
486
492
  - lib/fluent/plugin/out_stream.rb
487
493
  - lib/fluent/plugin/output.rb
@@ -542,6 +548,7 @@ files:
542
548
  - lib/fluent/test/log.rb
543
549
  - lib/fluent/test/output_test.rb
544
550
  - lib/fluent/test/parser_test.rb
551
+ - lib/fluent/test/startup_shutdown.rb
545
552
  - lib/fluent/time.rb
546
553
  - lib/fluent/timezone.rb
547
554
  - lib/fluent/unique_id.rb
@@ -600,8 +607,6 @@ files:
600
607
  - test/plugin/test_in_unix.rb
601
608
  - test/plugin/test_input.rb
602
609
  - test/plugin/test_multi_output.rb
603
- - test/plugin/test_out_buffered_null.rb
604
- - test/plugin/test_out_buffered_stdout.rb
605
610
  - test/plugin/test_out_copy.rb
606
611
  - test/plugin/test_out_exec.rb
607
612
  - test/plugin/test_out_exec_filter.rb
@@ -610,6 +615,7 @@ files:
610
615
  - test/plugin/test_out_null.rb
611
616
  - test/plugin/test_out_relabel.rb
612
617
  - test/plugin/test_out_roundrobin.rb
618
+ - test/plugin/test_out_secondary_file.rb
613
619
  - test/plugin/test_out_stdout.rb
614
620
  - test/plugin/test_out_stream.rb
615
621
  - test/plugin/test_output.rb
@@ -749,8 +755,6 @@ test_files:
749
755
  - test/plugin/test_in_unix.rb
750
756
  - test/plugin/test_input.rb
751
757
  - test/plugin/test_multi_output.rb
752
- - test/plugin/test_out_buffered_null.rb
753
- - test/plugin/test_out_buffered_stdout.rb
754
758
  - test/plugin/test_out_copy.rb
755
759
  - test/plugin/test_out_exec.rb
756
760
  - test/plugin/test_out_exec_filter.rb
@@ -759,6 +763,7 @@ test_files:
759
763
  - test/plugin/test_out_null.rb
760
764
  - test/plugin/test_out_relabel.rb
761
765
  - test/plugin/test_out_roundrobin.rb
766
+ - test/plugin/test_out_secondary_file.rb
762
767
  - test/plugin/test_out_stdout.rb
763
768
  - test/plugin/test_out_stream.rb
764
769
  - test/plugin/test_output.rb
@@ -1,59 +0,0 @@
1
- #
2
- # Fluentd
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- require 'fluent/plugin/output'
18
-
19
- module Fluent::Plugin
20
- class BufferedNullOutput < Output
21
- # This plugin is for tests of buffer plugins
22
-
23
- Fluent::Plugin.register_output('buffered_null', self)
24
-
25
- config_section :buffer do
26
- config_set_default :chunk_keys, ['tag']
27
- config_set_default :flush_at_shutdown, true
28
- config_set_default :chunk_limit_size, 10 * 1024
29
- end
30
-
31
- attr_accessor :feed_proc, :delayed
32
-
33
- def initialize
34
- super
35
- @delayed = false
36
- @feed_proc = nil
37
- end
38
-
39
- def prefer_delayed_commit
40
- @delayed
41
- end
42
-
43
- def write(chunk)
44
- if @feed_proc
45
- @feed_proc.call(chunk)
46
- else
47
- # ignore chunk.read
48
- end
49
- end
50
-
51
- def try_write(chunk)
52
- if @feed_proc
53
- @feed_proc.call(chunk)
54
- else
55
- # ignore chunk.read
56
- end
57
- end
58
- end
59
- end
@@ -1,70 +0,0 @@
1
- #
2
- # Fluentd
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- require 'fluent/plugin/output'
18
-
19
- module Fluent::Plugin
20
- class BufferedStdoutOutput < Output
21
- Fluent::Plugin.register_output('buffered_stdout', self)
22
-
23
- helpers :formatter, :inject, :compat_parameters
24
-
25
- config_section :buffer do
26
- config_set_default :chunk_keys, ['tag']
27
- config_set_default :flush_at_shutdown, true
28
- config_set_default :chunk_limit_size, 10 * 1024
29
- end
30
-
31
- DEFAULT_FORMAT_TYPE = 'json'
32
-
33
- config_section :format do
34
- config_set_default :@type, DEFAULT_FORMAT_TYPE
35
- end
36
-
37
- attr_accessor :delayed
38
-
39
- def initialize
40
- super
41
- @delayed = false
42
- end
43
-
44
- def prefer_delayed_commit
45
- @delayed
46
- end
47
-
48
- def configure(conf)
49
- if conf['output_type'] && !conf['format']
50
- conf['format'] = conf['output_type']
51
- end
52
- compat_parameters_convert(conf, :inject, :formatter)
53
- super
54
- @formatter = formatter_create(conf: conf.elements('format').first, default_type: DEFAULT_FORMAT_TYPE)
55
- end
56
-
57
- def write(chunk)
58
- chunk.write_to($log)
59
- end
60
-
61
- def try_write(chunk)
62
- chunk.write_to($log)
63
- end
64
-
65
- def format(tag, time, record)
66
- record = inject_values_to_record(tag, time, record)
67
- "#{Time.at(time).localtime} #{tag}: #{@formatter.format(tag, time, record).chomp}\n"
68
- end
69
- end
70
- end