fluentd 0.10.7 → 0.10.8

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.

Potentially problematic release.


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

@@ -87,7 +87,54 @@ class BufferedOutputTestDriver < InputTestDriver
87
87
  end
88
88
  end
89
89
 
90
+ class TimeSlicedOutputTestDriver < InputTestDriver
91
+ def initialize(klass, tag='test', &block)
92
+ super(klass, &block)
93
+ @entries = {}
94
+ @expected_buffer = nil
95
+ @tag = tag
96
+ end
90
97
 
91
- end
98
+ attr_accessor :tag
99
+
100
+ def emit(record, time=Time.now)
101
+ slicer = @instance.instance_eval{@time_slicer}
102
+ key = slicer.call(time.to_i)
103
+ @entries[key] = [] unless @entries.has_key?(key)
104
+ @entries[key] << [time.to_i, record]
105
+ self
106
+ end
107
+
108
+ def expect_format(str)
109
+ (@expected_buffer ||= '') << str
110
+ end
111
+
112
+ def run(&block)
113
+ result = []
114
+ super {
115
+ @entries.keys.each {|key|
116
+ es = ArrayEventStream.new(@entries[key])
117
+ @instance.emit(@tag, es, NullOutputChain.instance)
118
+ }
119
+
120
+ block.call if block
121
+
122
+ chunks = @instance.instance_eval {
123
+ @buffer.instance_eval {
124
+ chunks = []
125
+ @map.keys.each {|key|
126
+ chunks.push(@map.delete(key))
127
+ }
128
+ chunks
129
+ }
130
+ }
131
+ chunks.each { |chunk|
132
+ result.push(@instance.write(chunk))
133
+ }
134
+ }
135
+ result
136
+ end
92
137
  end
93
138
 
139
+ end
140
+ end
@@ -1,5 +1,5 @@
1
1
  module Fluent
2
2
 
3
- VERSION = '0.10.7'
3
+ VERSION = '0.10.8'
4
4
 
5
5
  end
@@ -1,6 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
-
3
2
  require 'fluent/config'
3
+ require 'fluent/supervisor'
4
+ require 'fluent/load'
4
5
  require 'fileutils'
5
6
 
6
7
  class ConfigTest < Test::Unit::TestCase
@@ -8,7 +9,7 @@ class ConfigTest < Test::Unit::TestCase
8
9
 
9
10
  TMP_DIR = File.dirname(__FILE__) + "/tmp"
10
11
 
11
- def test_include
12
+ def prepare_config
12
13
  write_config "#{TMP_DIR}/config_test_1.conf", %[
13
14
  k1 root_config
14
15
  include dir/config_test_2.conf #
@@ -39,6 +40,10 @@ class ConfigTest < Test::Unit::TestCase
39
40
  k7 wildcard_include_2
40
41
  ]
41
42
 
43
+ end
44
+
45
+ def test_include
46
+ prepare_config
42
47
  c = Config.read("#{TMP_DIR}/config_test_1.conf")
43
48
  assert_equal 'root_config', c['k1']
44
49
  assert_equal 'relative_path_include', c['k2']
@@ -50,11 +55,23 @@ class ConfigTest < Test::Unit::TestCase
50
55
  assert_equal 'elem', c.elements.first.name
51
56
  assert_equal 'name', c.elements.first.arg
52
57
  assert_equal 'normal_parameter', c.elements.first['include']
58
+
53
59
  end
54
60
 
55
61
  def write_config(path, data)
56
62
  FileUtils.mkdir_p(File.dirname(path))
57
63
  File.open(path, "w") {|f| f.write data }
58
64
  end
65
+
66
+ def test_inline
67
+ prepare_config
68
+ opts = {
69
+ :config_path => "#{TMP_DIR}/config_test_1.conf",
70
+ :inline_config => "<source>\n type http\n port 2222\n </source>"
71
+ }
72
+ assert_nothing_raised do
73
+ Fluent::Supervisor.new(opts)
74
+ end
75
+ end
59
76
  end
60
77
 
@@ -1,6 +1,9 @@
1
1
  require 'test/unit'
2
2
  require 'fileutils'
3
+ require 'fluent/log'
3
4
 
4
5
  class Test::Unit::TestCase
5
6
  end
6
7
 
8
+ $log = Fluent::Log.new(STDOUT, Fluent::Log::LEVEL_WARN)
9
+
@@ -0,0 +1,232 @@
1
+ require 'helper'
2
+ require 'fluent/mixin'
3
+
4
+ #class MixinTest < Test::Unit::TestCase
5
+ # class MixinOutputTester < Fluent::BufferedOutput
6
+ # Fluent::Plugin.register_output('mixintest', self)
7
+ # include Fluent::PlainTextFormatterMixin
8
+ # def configure(conf)
9
+ # super
10
+ # end
11
+ # def write(chunk)
12
+ # chunk.read
13
+ # end
14
+ # end
15
+ #
16
+ # def create_driver(conf='')
17
+ # Fluent::Test::BufferedOutputTestDriver.new(MixinOutputTester).configure(conf)
18
+ # end
19
+ #
20
+ # def test_default_config
21
+ # d = create_driver
22
+ # assert_equal true, d.instance.output_include_time
23
+ # assert_equal true, d.instance.output_include_tag
24
+ # assert_equal 'json', d.instance.output_data_type
25
+ # assert_equal "\t", d.instance.output_field_separator
26
+ # assert_equal true, d.instance.output_add_newline
27
+ # assert_equal nil, d.instance.instance_eval{@localtime}
28
+ #
29
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
30
+ # d.emit({"foo"=>1,"bar"=>501}, time)
31
+ # d.emit({"foo"=>2,"bar"=>502}, time)
32
+ # text = d.run
33
+ # assert_equal %[2011-11-29T12:02:50Z\ttest\t{"foo":1,"bar":501}\n2011-11-29T12:02:50Z\ttest\t{"foo":2,"bar":502}\n], text
34
+ # end
35
+ #
36
+ # def test_timezone
37
+ # d = create_driver %[
38
+ #utc
39
+ #]
40
+ # assert_equal false, d.instance.instance_eval{@localtime}
41
+ #
42
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
43
+ # d.emit({"foo"=>1,"bar"=>501}, time)
44
+ # d.emit({"foo"=>2,"bar"=>502}, time)
45
+ # text = d.run
46
+ # assert_equal %[2011-11-29T12:02:50Z\ttest\t{"foo":1,"bar":501}\n2011-11-29T12:02:50Z\ttest\t{"foo":2,"bar":502}\n], text
47
+ #
48
+ # d = create_driver %[
49
+ #localtime
50
+ #]
51
+ # assert_equal true, d.instance.instance_eval{@localtime}
52
+ #
53
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
54
+ # time_s = Time.parse("2011-11-29 12:02:50 UTC").getlocal.iso8601
55
+ # d.emit({"foo"=>1,"bar"=>501}, time)
56
+ # d.emit({"foo"=>2,"bar"=>502}, time)
57
+ # text = d.run
58
+ # assert_equal time_s + %[\ttest\t{"foo":1,"bar":501}\n] + time_s + %[\ttest\t{"foo":2,"bar":502}\n], text
59
+ # end
60
+ #
61
+ # def test_time_tag_onoff
62
+ # d = create_driver %[
63
+ #output_include_time true
64
+ #output_include_tag false
65
+ #]
66
+ # assert_equal true, d.instance.output_include_time
67
+ # assert_equal false, d.instance.output_include_tag
68
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
69
+ # d.emit({"foo"=>1,"bar"=>501}, time)
70
+ # d.emit({"foo"=>2,"bar"=>502}, time)
71
+ # text = d.run
72
+ # assert_equal %[2011-11-29T12:02:50Z\t{"foo":1,"bar":501}\n2011-11-29T12:02:50Z\t{"foo":2,"bar":502}\n], text
73
+ #
74
+ # d = create_driver %[
75
+ #output_include_time false
76
+ #output_include_tag true
77
+ #]
78
+ # assert_equal false, d.instance.output_include_time
79
+ # assert_equal true, d.instance.output_include_tag
80
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
81
+ # d.emit({"foo"=>1,"bar"=>501}, time)
82
+ # d.emit({"foo"=>2,"bar"=>502}, time)
83
+ # text = d.run
84
+ # assert_equal %[test\t{"foo":1,"bar":501}\ntest\t{"foo":2,"bar":502}\n], text
85
+ #
86
+ # d = create_driver %[
87
+ #output_include_time false
88
+ #output_include_tag false
89
+ #]
90
+ # assert_equal false, d.instance.output_include_time
91
+ # assert_equal false, d.instance.output_include_tag
92
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
93
+ # d.emit({"foo"=>1,"bar"=>501}, time)
94
+ # d.emit({"foo"=>2,"bar"=>502}, time)
95
+ # text = d.run
96
+ # assert_equal %[{"foo":1,"bar":501}\n{"foo":2,"bar":502}\n], text
97
+ # end
98
+ #
99
+ # def test_data_type
100
+ # d = create_driver %[
101
+ #output_data_type json
102
+ #]
103
+ # assert_equal 'json', d.instance.output_data_type
104
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
105
+ # d.emit({"foo"=>1,"bar"=>"This is what you want"}, time)
106
+ # d.emit({"foo"=>2,"bar"=>"Is this what you want or not"}, time)
107
+ # text = d.run
108
+ # assert_equal %[2011-11-29T12:02:50Z\ttest\t{"foo":1,"bar":"This is what you want"}\n2011-11-29T12:02:50Z\ttest\t{"foo":2,"bar":"Is this what you want or not"}\n], text
109
+ #
110
+ # d = create_driver %[
111
+ #output_data_type attr:foo
112
+ #]
113
+ # assert_equal 'attr:foo', d.instance.output_data_type
114
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
115
+ # d.emit({"foo"=>1,"bar"=>"This is what you want"}, time)
116
+ # d.emit({"foo"=>2,"bar"=>"Is this what you want or not"}, time)
117
+ # text = d.run
118
+ # assert_equal %[2011-11-29T12:02:50Z\ttest\t1\n2011-11-29T12:02:50Z\ttest\t2\n], text
119
+ #
120
+ # d = create_driver %[
121
+ #output_data_type attr:bar
122
+ #]
123
+ # assert_equal 'attr:bar', d.instance.output_data_type
124
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
125
+ # d.emit({"foo"=>1,"bar"=>"This is what you want"}, time)
126
+ # d.emit({"foo"=>2,"bar"=>"Is this what you want or not"}, time)
127
+ # text = d.run
128
+ # assert_equal %[2011-11-29T12:02:50Z\ttest\tThis is what you want\n2011-11-29T12:02:50Z\ttest\tIs this what you want or not\n], text
129
+ #
130
+ # d = create_driver %[
131
+ #output_data_type attr:foo,bar
132
+ #]
133
+ # assert_equal 'attr:foo,bar', d.instance.output_data_type
134
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
135
+ # d.emit({"foo"=>1,"bar"=>"This is what you want"}, time)
136
+ # d.emit({"foo"=>2,"bar"=>"Is this what you want or not"}, time)
137
+ # text = d.run
138
+ # assert_equal %[2011-11-29T12:02:50Z\ttest\t1\tThis is what you want\n2011-11-29T12:02:50Z\ttest\t2\tIs this what you want or not\n], text
139
+ # end
140
+ #
141
+ # def test_add_newline
142
+ # d = create_driver %[
143
+ #output_add_newline false
144
+ #]
145
+ # assert_equal false, d.instance.output_add_newline
146
+ #
147
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
148
+ # d.emit({"foo"=>1,"bar"=>"This is what you want"}, time)
149
+ # d.emit({"foo"=>2,"bar"=>"Is this what you want or not"}, time)
150
+ # text = d.run
151
+ # assert_equal %[2011-11-29T12:02:50Z\ttest\t{"foo":1,"bar":"This is what you want"}2011-11-29T12:02:50Z\ttest\t{"foo":2,"bar":"Is this what you want or not"}], text
152
+ #
153
+ # d = create_driver %[
154
+ #output_add_newline false
155
+ #]
156
+ # assert_equal false, d.instance.output_add_newline
157
+ #
158
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
159
+ # d.emit({"foo"=>1,"bar"=>"This is what you want\n"}, time)
160
+ # d.emit({"foo"=>2,"bar"=>"Is this what you want or not\n"}, time)
161
+ # text = d.run
162
+ # assert_equal %[2011-11-29T12:02:50Z\ttest\t{"foo":1,"bar":"This is what you want\\n"}2011-11-29T12:02:50Z\ttest\t{"foo":2,"bar":"Is this what you want or not\\n"}], text
163
+ #
164
+ # d = create_driver %[
165
+ #output_data_type attr:bar
166
+ #output_add_newline false
167
+ #]
168
+ # assert_equal false, d.instance.output_add_newline
169
+ #
170
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
171
+ # d.emit({"foo"=>1,"bar"=>"This is what you want\n"}, time)
172
+ # d.emit({"foo"=>2,"bar"=>"Is this what you want or not\n"}, time)
173
+ # text = d.run
174
+ # assert_equal %[2011-11-29T12:02:50Z\ttest\tThis is what you want\n2011-11-29T12:02:50Z\ttest\tIs this what you want or not\n], text
175
+ #
176
+ # d = create_driver %[
177
+ #output_data_type attr:bar
178
+ #output_add_newline true
179
+ #]
180
+ # assert_equal true, d.instance.output_add_newline
181
+ #
182
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
183
+ # d.emit({"foo"=>1,"bar"=>"This is what you want\n"}, time)
184
+ # d.emit({"foo"=>2,"bar"=>"Is this what you want or not\n"}, time)
185
+ # text = d.run
186
+ # assert_equal %[2011-11-29T12:02:50Z\ttest\tThis is what you want\n\n2011-11-29T12:02:50Z\ttest\tIs this what you want or not\n\n], text
187
+ # end
188
+ #
189
+ # def test_field_separator
190
+ # time = Time.parse("2011-11-29 12:02:50 UTC").to_i
191
+ #
192
+ # d = create_driver %[
193
+ #output_field_separator SPACE
194
+ #]
195
+ # assert_equal " ", d.instance.output_field_separator
196
+ # d.emit({"foo"=>1,"bar"=>501}, time)
197
+ # d.emit({"foo"=>2,"bar"=>502}, time)
198
+ # text = d.run
199
+ # assert_equal %[2011-11-29T12:02:50Z test {"foo":1,"bar":501}\n2011-11-29T12:02:50Z test {"foo":2,"bar":502}\n], text
200
+ #
201
+ # d = create_driver %[
202
+ #output_field_separator SPACE
203
+ #output_data_type attr:bar,foo
204
+ #]
205
+ # assert_equal " ", d.instance.output_field_separator
206
+ # d.emit({"foo"=>1,"bar"=>501}, time)
207
+ # d.emit({"foo"=>2,"bar"=>502}, time)
208
+ # text = d.run
209
+ # assert_equal %[2011-11-29T12:02:50Z test 501 1\n2011-11-29T12:02:50Z test 502 2\n], text
210
+ #
211
+ # d = create_driver %[
212
+ #output_field_separator COMMA
213
+ #]
214
+ # assert_equal ",", d.instance.output_field_separator
215
+ # d.emit({"foo"=>1,"bar"=>501}, time)
216
+ # d.emit({"foo"=>2,"bar"=>502}, time)
217
+ # text = d.run
218
+ # assert_equal %[2011-11-29T12:02:50Z,test,{"foo":1,"bar":501}\n2011-11-29T12:02:50Z,test,{"foo":2,"bar":502}\n], text
219
+ #
220
+ # d = create_driver %[
221
+ #output_field_separator COMMA
222
+ #output_data_type attr:foo,bar
223
+ #]
224
+ # assert_equal ",", d.instance.output_field_separator
225
+ # d.emit({"foo"=>1,"bar"=>501}, time)
226
+ # d.emit({"foo"=>2,"bar"=>502}, time)
227
+ # text = d.run
228
+ # assert_equal %[2011-11-29T12:02:50Z,test,1,501\n2011-11-29T12:02:50Z,test,2,502\n], text
229
+ # end
230
+ #
231
+ #end
232
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluentd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.7
4
+ version: 0.10.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-16 00:00:00.000000000Z
12
+ date: 2011-12-04 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack
16
- requirement: &9186500 !ruby/object:Gem::Requirement
16
+ requirement: &70282132235300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.4.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *9186500
24
+ version_requirements: *70282132235300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &9185640 !ruby/object:Gem::Requirement
27
+ requirement: &70282132234740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.4.3
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *9185640
35
+ version_requirements: *70282132234740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: yajl-ruby
38
- requirement: &9184720 !ruby/object:Gem::Requirement
38
+ requirement: &70282132234020 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *9184720
46
+ version_requirements: *70282132234020
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: cool.io
49
- requirement: &9183560 !ruby/object:Gem::Requirement
49
+ requirement: &70282132233440 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *9183560
57
+ version_requirements: *70282132233440
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: http_parser.rb
60
- requirement: &9182640 !ruby/object:Gem::Requirement
60
+ requirement: &70282132232700 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.5.1
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *9182640
68
+ version_requirements: *70282132232700
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
- requirement: &9181600 !ruby/object:Gem::Requirement
71
+ requirement: &70282132231740 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 0.9.2
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *9181600
79
+ version_requirements: *70282132231740
80
80
  description:
81
81
  email: frsyuki@gmail.com
82
82
  executables:
@@ -132,6 +132,7 @@ files:
132
132
  - lib/fluent/plugin/out_stream.rb
133
133
  - lib/fluent/plugin/out_test.rb
134
134
  - lib/fluent/process.rb
135
+ - lib/fluent/supervisor.rb
135
136
  - lib/fluent/test.rb
136
137
  - lib/fluent/test/base.rb
137
138
  - lib/fluent/test/input_test.rb
@@ -140,6 +141,7 @@ files:
140
141
  - test/config.rb
141
142
  - test/helper.rb
142
143
  - test/match.rb
144
+ - test/mixin.rb
143
145
  - test/plugin/in_exec.rb
144
146
  - test/plugin/in_forward.rb
145
147
  - test/plugin/in_http.rb
@@ -179,17 +181,18 @@ signing_key:
179
181
  specification_version: 3
180
182
  summary: Fluent event collector
181
183
  test_files:
184
+ - test/config.rb
185
+ - test/helper.rb
182
186
  - test/match.rb
183
- - test/plugin/out_roundrobin.rb
184
- - test/plugin/in_stream.rb
185
- - test/plugin/out_stream.rb
186
- - test/plugin/out_copy.rb
187
+ - test/mixin.rb
188
+ - test/plugin/in_exec.rb
187
189
  - test/plugin/in_forward.rb
188
- - test/plugin/out_forward.rb
189
190
  - test/plugin/in_http.rb
190
- - test/plugin/in_exec.rb
191
+ - test/plugin/in_stream.rb
192
+ - test/plugin/out_copy.rb
193
+ - test/plugin/out_exec.rb
191
194
  - test/plugin/out_exec_filter.rb
192
195
  - test/plugin/out_file.rb
193
- - test/plugin/out_exec.rb
194
- - test/helper.rb
195
- - test/config.rb
196
+ - test/plugin/out_forward.rb
197
+ - test/plugin/out_roundrobin.rb
198
+ - test/plugin/out_stream.rb