fluentd 0.10.36 → 0.10.37

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.

@@ -1,5 +1,5 @@
1
1
  module Fluent
2
2
 
3
- VERSION = '0.10.36'
3
+ VERSION = '0.10.37'
4
4
 
5
5
  end
@@ -0,0 +1,77 @@
1
+ require 'fluent/config_dsl'
2
+
3
+ class ConfigDSLTest < Test::Unit::TestCase
4
+ # TEST_CONFIG1 = %[
5
+ # <source>
6
+ # type forward
7
+ # port 24224
8
+ # </source>
9
+ # <match test.**>
10
+ # type forward
11
+ # flush_interval 1s
12
+ # <server>
13
+ # host host0.example.com
14
+ # port 24224
15
+ # </server>
16
+ # <server>
17
+ # host host1.example.com
18
+ # port 24224
19
+ # </server>
20
+ # </match>
21
+ # ]
22
+ TEST_DSL_CONFIG1 = %q[
23
+ source {
24
+ type "forward"
25
+ port 24224
26
+ }
27
+ match('test.**') {
28
+ type "forward"
29
+ flush_interval "1s"
30
+ (0..1).each do |i|
31
+ server {
32
+ host "host#{i}.example.com"
33
+ port 24224
34
+ }
35
+ end
36
+ }
37
+ ]
38
+
39
+ TEST_DSL_CONFIG2 = %q[
40
+ v = [0, 1, 2]
41
+ ]
42
+
43
+ def test_parse
44
+ root = Fluent::Config::DSL::DSLParser.parse(TEST_DSL_CONFIG1)
45
+
46
+ assert_equal 0, root.keys.size
47
+ assert_equal 2, root.elements.size
48
+
49
+ e0 = root.elements[0]
50
+ assert_equal 'source', e0.name
51
+ assert_equal '', e0.arg
52
+ assert_equal 'forward', e0['type']
53
+ assert_equal '24224', e0['port']
54
+
55
+ e1 = root.elements[1]
56
+ assert_equal 'match', e1.name
57
+ assert_equal 'test.**', e1.arg
58
+ assert_equal 'forward', e1['type']
59
+ assert_equal '1s', e1['flush_interval']
60
+ assert_equal 2, e1.elements.size
61
+ e1s0 = e1.elements[0]
62
+ assert_equal 'server', e1s0.name
63
+ assert_equal 'host0.example.com', e1s0['host']
64
+ assert_equal '24224', e1s0['port']
65
+ e1s1 = e1.elements[1]
66
+ assert_equal 'server', e1s1.name
67
+ assert_equal 'host1.example.com', e1s1['host']
68
+ assert_equal '24224', e1s1['port']
69
+ end
70
+
71
+ def test_parse2
72
+ root = Fluent::Config::DSL::DSLParser.parse(TEST_DSL_CONFIG2)
73
+
74
+ assert_equal 0, root.keys.size
75
+ assert_equal 0, root.elements.size
76
+ end
77
+ end
@@ -4,33 +4,82 @@ require 'net/http'
4
4
  class ExecInputTest < Test::Unit::TestCase
5
5
  def setup
6
6
  Fluent::Test.setup
7
+ @test_time = Time.parse("2011-01-02 13:14:15").to_i
8
+ @script = File.expand_path(File.join(File.dirname(__FILE__), '..', 'scripts', 'exec_script.rb'))
7
9
  end
8
10
 
9
- CONFIG = %[
10
- command bash -c "echo -e '2011-01-02 13:14:15\ttag1\tok'"
11
- keys time,tag,k1
12
- time_key time
13
- tag_key tag
14
- time_format %Y-%m-%d %H:%M:%S
15
- run_interval 1s
16
- ]
17
-
18
- def create_driver(conf=CONFIG)
11
+ def create_driver(conf = tsv_config)
19
12
  Fluent::Test::InputTestDriver.new(Fluent::ExecInput).configure(conf)
20
13
  end
21
14
 
15
+ def tsv_config
16
+ %[
17
+ command ruby #{@script} "2011-01-02 13:14:15" 0
18
+ keys time,tag,k1
19
+ time_key time
20
+ tag_key tag
21
+ time_format %Y-%m-%d %H:%M:%S
22
+ run_interval 1s
23
+ ]
24
+ end
25
+
26
+ def json_config
27
+ %[
28
+ command ruby #{@script} #{@test_time} 1
29
+ format json
30
+ tag_key tag
31
+ time_key time
32
+ run_interval 1s
33
+ ]
34
+ end
35
+
36
+ def msgpack_config
37
+ %[
38
+ command ruby #{@script} #{@test_time} 2
39
+ format msgpack
40
+ tag_key tagger
41
+ time_key datetime
42
+ run_interval 1s
43
+ ]
44
+ end
45
+
22
46
  def test_configure
23
47
  d = create_driver
48
+ assert_equal :tsv, d.instance.format
24
49
  assert_equal ["time","tag","k1"], d.instance.keys
25
50
  assert_equal "tag", d.instance.tag_key
26
51
  assert_equal "time", d.instance.time_key
27
52
  assert_equal "%Y-%m-%d %H:%M:%S", d.instance.time_format
28
53
  end
29
54
 
55
+ def test_configure_with_json
56
+ d = create_driver json_config
57
+ assert_equal :json, d.instance.format
58
+ assert_equal [], d.instance.keys
59
+ end
60
+
61
+ def test_configure_with_msgpack
62
+ d = create_driver msgpack_config
63
+ assert_equal :msgpack, d.instance.format
64
+ assert_equal [], d.instance.keys
65
+ end
66
+
67
+ # TODO: Merge following tests into one case with parameters
68
+
30
69
  def test_emit
31
70
  d = create_driver
32
71
 
33
- time = Time.parse("2011-01-02 13:14:15").to_i
72
+ d.run do
73
+ sleep 2
74
+ end
75
+
76
+ emits = d.emits
77
+ assert_equal true, emits.length > 0
78
+ assert_equal ["tag1", @test_time, {"k1"=>"ok"}], emits[0]
79
+ end
80
+
81
+ def test_emit_json
82
+ d = create_driver json_config
34
83
 
35
84
  d.run do
36
85
  sleep 2
@@ -38,7 +87,18 @@ class ExecInputTest < Test::Unit::TestCase
38
87
 
39
88
  emits = d.emits
40
89
  assert_equal true, emits.length > 0
41
- assert_equal ["tag1", time, {"k1"=>"ok"}], emits[0]
90
+ assert_equal ["tag1", @test_time, {"k1"=>"ok"}], emits[0]
42
91
  end
43
- end
44
92
 
93
+ def test_emit_msgpack
94
+ d = create_driver msgpack_config
95
+
96
+ d.run do
97
+ sleep 2
98
+ end
99
+
100
+ emits = d.emits
101
+ assert_equal true, emits.length > 0
102
+ assert_equal ["tag1", @test_time, {"k1"=>"ok"}], emits[0]
103
+ end
104
+ end
@@ -1,6 +1,6 @@
1
1
  require 'fluent/test'
2
2
 
3
- class ObjectSpaceInputTest < Test::Unit::TestCase
3
+ class GCStatInputTest < Test::Unit::TestCase
4
4
  def setup
5
5
  Fluent::Test.setup
6
6
  end
@@ -11,13 +11,13 @@ class ObjectSpaceInputTest < Test::Unit::TestCase
11
11
  Fluent::Test.setup
12
12
  end
13
13
 
14
- CONFIG = %[
14
+ TESTCONFIG = %[
15
15
  emit_interval 1
16
16
  tag t1
17
17
  top 2
18
18
  ]
19
19
 
20
- def create_driver(conf=CONFIG)
20
+ def create_driver(conf=TESTCONFIG)
21
21
  Fluent::Test::InputTestDriver.new(Fluent::ObjectSpaceInput).configure(conf)
22
22
  end
23
23
 
@@ -14,9 +14,52 @@ class StdoutOutputTest < Test::Unit::TestCase
14
14
 
15
15
  def test_configure
16
16
  d = create_driver
17
+ assert_equal :json, d.instance.output_type
17
18
  end
18
19
 
19
- # def test_emit
20
- # end
20
+ def test_configure_output_type
21
+ d = create_driver(CONFIG + "\noutput_type json")
22
+ assert_equal :json, d.instance.output_type
23
+
24
+ d = create_driver(CONFIG + "\noutput_type hash")
25
+ assert_equal :hash, d.instance.output_type
26
+
27
+ assert_raise(Fluent::ConfigError) do
28
+ d = create_driver(CONFIG + "\noutput_type foo")
29
+ end
30
+ end
31
+
32
+ def test_emit_json
33
+ d = create_driver(CONFIG + "\noutput_type json")
34
+ time = Time.now
35
+ out = capture_log { d.emit({'test' => 'test'}, time) }
36
+ assert_equal "#{time.localtime} test: {\"test\":\"test\"}\n", out
37
+
38
+ # NOTE: Float::NAN is not jsonable
39
+ assert_raise(Yajl::EncodeError) { d.emit({'test' => Float::NAN}, time) }
40
+ end
41
+
42
+ def test_emit_hash
43
+ d = create_driver(CONFIG + "\noutput_type hash")
44
+ time = Time.now
45
+ out = capture_log { d.emit({'test' => 'test'}, time) }
46
+ assert_equal "#{time.localtime} test: {\"test\"=>\"test\"}\n", out
47
+
48
+ # NOTE: Float::NAN is not jsonable, but hash string can output it.
49
+ out = capture_log { d.emit({'test' => Float::NAN}, time) }
50
+ assert_equal "#{time.localtime} test: {\"test\"=>NaN}\n", out
51
+ end
52
+
53
+ private
54
+
55
+ # Capture the log output of the block given
56
+ def capture_log(&block)
57
+ tmp = $log
58
+ $log = StringIO.new
59
+ yield
60
+ return $log.string
61
+ ensure
62
+ $log = tmp
63
+ end
21
64
  end
22
65
 
@@ -0,0 +1,26 @@
1
+ require 'json'
2
+ require 'msgpack'
3
+
4
+ def gen_tsv(time)
5
+ "#{time}\ttag1\tok"
6
+ end
7
+
8
+ def gen_json(time)
9
+ {'tag' => 'tag1', 'time' => time, 'k1' => 'ok'}.to_json
10
+ end
11
+
12
+ def gen_msgpack(time)
13
+ {'tagger' => 'tag1', 'datetime' => time, 'k1' => 'ok'}.to_msgpack
14
+ end
15
+
16
+ time = ARGV.first
17
+ time = Integer(time) rescue time
18
+
19
+ case ARGV.last.to_i
20
+ when 0
21
+ puts gen_tsv(time)
22
+ when 1
23
+ puts gen_json(time)
24
+ when 2
25
+ print gen_msgpack(time)
26
+ end
metadata CHANGED
@@ -1,34 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluentd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.36
5
- prerelease:
4
+ version: 0.10.37
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sadayuki Furuhashi
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-31 00:00:00.000000000 Z
11
+ date: 2013-08-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: msgpack
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.4.4
22
- - - ! '!='
20
+ - - '!='
23
21
  - !ruby/object:Gem::Version
24
22
  version: 0.5.0
25
- - - ! '!='
23
+ - - '!='
26
24
  - !ruby/object:Gem::Version
27
25
  version: 0.5.1
28
- - - ! '!='
26
+ - - '!='
29
27
  - !ruby/object:Gem::Version
30
28
  version: 0.5.2
31
- - - ! '!='
29
+ - - '!='
32
30
  - !ruby/object:Gem::Version
33
31
  version: 0.5.3
34
32
  - - <
@@ -37,21 +35,20 @@ dependencies:
37
35
  type: :runtime
38
36
  prerelease: false
39
37
  version_requirements: !ruby/object:Gem::Requirement
40
- none: false
41
38
  requirements:
42
- - - ! '>='
39
+ - - '>='
43
40
  - !ruby/object:Gem::Version
44
41
  version: 0.4.4
45
- - - ! '!='
42
+ - - '!='
46
43
  - !ruby/object:Gem::Version
47
44
  version: 0.5.0
48
- - - ! '!='
45
+ - - '!='
49
46
  - !ruby/object:Gem::Version
50
47
  version: 0.5.1
51
- - - ! '!='
48
+ - - '!='
52
49
  - !ruby/object:Gem::Version
53
50
  version: 0.5.2
54
- - - ! '!='
51
+ - - '!='
55
52
  - !ruby/object:Gem::Version
56
53
  version: 0.5.3
57
54
  - - <
@@ -60,23 +57,20 @@ dependencies:
60
57
  - !ruby/object:Gem::Dependency
61
58
  name: json
62
59
  requirement: !ruby/object:Gem::Requirement
63
- none: false
64
60
  requirements:
65
- - - ! '>='
61
+ - - '>='
66
62
  - !ruby/object:Gem::Version
67
63
  version: 1.4.3
68
64
  type: :runtime
69
65
  prerelease: false
70
66
  version_requirements: !ruby/object:Gem::Requirement
71
- none: false
72
67
  requirements:
73
- - - ! '>='
68
+ - - '>='
74
69
  - !ruby/object:Gem::Version
75
70
  version: 1.4.3
76
71
  - !ruby/object:Gem::Dependency
77
72
  name: yajl-ruby
78
73
  requirement: !ruby/object:Gem::Requirement
79
- none: false
80
74
  requirements:
81
75
  - - ~>
82
76
  - !ruby/object:Gem::Version
@@ -84,7 +78,6 @@ dependencies:
84
78
  type: :runtime
85
79
  prerelease: false
86
80
  version_requirements: !ruby/object:Gem::Requirement
87
- none: false
88
81
  requirements:
89
82
  - - ~>
90
83
  - !ruby/object:Gem::Version
@@ -92,7 +85,6 @@ dependencies:
92
85
  - !ruby/object:Gem::Dependency
93
86
  name: cool.io
94
87
  requirement: !ruby/object:Gem::Requirement
95
- none: false
96
88
  requirements:
97
89
  - - ~>
98
90
  - !ruby/object:Gem::Version
@@ -100,7 +92,6 @@ dependencies:
100
92
  type: :runtime
101
93
  prerelease: false
102
94
  version_requirements: !ruby/object:Gem::Requirement
103
- none: false
104
95
  requirements:
105
96
  - - ~>
106
97
  - !ruby/object:Gem::Version
@@ -108,7 +99,6 @@ dependencies:
108
99
  - !ruby/object:Gem::Dependency
109
100
  name: http_parser.rb
110
101
  requirement: !ruby/object:Gem::Requirement
111
- none: false
112
102
  requirements:
113
103
  - - ~>
114
104
  - !ruby/object:Gem::Version
@@ -116,7 +106,6 @@ dependencies:
116
106
  type: :runtime
117
107
  prerelease: false
118
108
  version_requirements: !ruby/object:Gem::Requirement
119
- none: false
120
109
  requirements:
121
110
  - - ~>
122
111
  - !ruby/object:Gem::Version
@@ -124,49 +113,43 @@ dependencies:
124
113
  - !ruby/object:Gem::Dependency
125
114
  name: rake
126
115
  requirement: !ruby/object:Gem::Requirement
127
- none: false
128
116
  requirements:
129
- - - ! '>='
117
+ - - '>='
130
118
  - !ruby/object:Gem::Version
131
119
  version: 0.9.2
132
120
  type: :development
133
121
  prerelease: false
134
122
  version_requirements: !ruby/object:Gem::Requirement
135
- none: false
136
123
  requirements:
137
- - - ! '>='
124
+ - - '>='
138
125
  - !ruby/object:Gem::Version
139
126
  version: 0.9.2
140
127
  - !ruby/object:Gem::Dependency
141
128
  name: rr
142
129
  requirement: !ruby/object:Gem::Requirement
143
- none: false
144
130
  requirements:
145
- - - ! '>='
131
+ - - '>='
146
132
  - !ruby/object:Gem::Version
147
133
  version: 1.0.0
148
134
  type: :development
149
135
  prerelease: false
150
136
  version_requirements: !ruby/object:Gem::Requirement
151
- none: false
152
137
  requirements:
153
- - - ! '>='
138
+ - - '>='
154
139
  - !ruby/object:Gem::Version
155
140
  version: 1.0.0
156
141
  - !ruby/object:Gem::Dependency
157
142
  name: timecop
158
143
  requirement: !ruby/object:Gem::Requirement
159
- none: false
160
144
  requirements:
161
- - - ! '>='
145
+ - - '>='
162
146
  - !ruby/object:Gem::Version
163
147
  version: 0.3.0
164
148
  type: :development
165
149
  prerelease: false
166
150
  version_requirements: !ruby/object:Gem::Requirement
167
- none: false
168
151
  requirements:
169
- - - ! '>='
152
+ - - '>='
170
153
  - !ruby/object:Gem::Version
171
154
  version: 0.3.0
172
155
  description: Fluentd is an event collector system. It is a generalized version of
@@ -201,6 +184,7 @@ files:
201
184
  - lib/fluent/command/debug.rb
202
185
  - lib/fluent/command/fluentd.rb
203
186
  - lib/fluent/config.rb
187
+ - lib/fluent/config_dsl.rb
204
188
  - lib/fluent/engine.rb
205
189
  - lib/fluent/env.rb
206
190
  - lib/fluent/event.rb
@@ -215,6 +199,7 @@ files:
215
199
  - lib/fluent/plugin/buf_file.rb
216
200
  - lib/fluent/plugin/buf_memory.rb
217
201
  - lib/fluent/plugin/buf_zfile.rb
202
+ - lib/fluent/plugin/exec_util.rb
218
203
  - lib/fluent/plugin/in_debug_agent.rb
219
204
  - lib/fluent/plugin/in_exec.rb
220
205
  - lib/fluent/plugin/in_forward.rb
@@ -246,6 +231,7 @@ files:
246
231
  - lib/fluent/test/output_test.rb
247
232
  - lib/fluent/version.rb
248
233
  - test/config.rb
234
+ - test/configdsl.rb
249
235
  - test/helper.rb
250
236
  - test/match.rb
251
237
  - test/mixin.rb
@@ -267,35 +253,33 @@ files:
267
253
  - test/plugin/out_roundrobin.rb
268
254
  - test/plugin/out_stdout.rb
269
255
  - test/plugin/out_stream.rb
256
+ - test/scripts/exec_script.rb
270
257
  homepage: http://fluentd.org/
271
258
  licenses: []
259
+ metadata: {}
272
260
  post_install_message:
273
261
  rdoc_options: []
274
262
  require_paths:
275
263
  - lib
276
264
  required_ruby_version: !ruby/object:Gem::Requirement
277
- none: false
278
265
  requirements:
279
- - - ! '>='
266
+ - - '>='
280
267
  - !ruby/object:Gem::Version
281
268
  version: 1.9.2
282
269
  required_rubygems_version: !ruby/object:Gem::Requirement
283
- none: false
284
270
  requirements:
285
- - - ! '>='
271
+ - - '>='
286
272
  - !ruby/object:Gem::Version
287
273
  version: '0'
288
- segments:
289
- - 0
290
- hash: 1938960347567989865
291
274
  requirements: []
292
275
  rubyforge_project:
293
- rubygems_version: 1.8.23
276
+ rubygems_version: 2.0.2
294
277
  signing_key:
295
- specification_version: 3
278
+ specification_version: 4
296
279
  summary: Fluentd event collector
297
280
  test_files:
298
281
  - test/config.rb
282
+ - test/configdsl.rb
299
283
  - test/helper.rb
300
284
  - test/match.rb
301
285
  - test/mixin.rb
@@ -317,3 +301,4 @@ test_files:
317
301
  - test/plugin/out_roundrobin.rb
318
302
  - test/plugin/out_stdout.rb
319
303
  - test/plugin/out_stream.rb
304
+ - test/scripts/exec_script.rb