fluentd 0.14.0 → 0.14.1

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 (105) hide show
  1. checksums.yaml +4 -4
  2. data/example/copy_roundrobin.conf +39 -0
  3. data/example/filter_stdout.conf +5 -5
  4. data/example/in_forward.conf +2 -2
  5. data/example/in_http.conf +2 -2
  6. data/example/in_syslog.conf +2 -2
  7. data/example/in_tail.conf +2 -2
  8. data/example/in_tcp.conf +2 -2
  9. data/example/in_udp.conf +2 -2
  10. data/example/out_buffered_null.conf +32 -0
  11. data/example/out_copy.conf +4 -4
  12. data/example/out_file.conf +2 -2
  13. data/example/out_forward.conf +2 -2
  14. data/example/v0_12_filter.conf +8 -8
  15. data/fluentd.gemspec +1 -1
  16. data/lib/fluent/command/fluentd.rb +6 -1
  17. data/lib/fluent/compat/handle_tag_name_mixin.rb +53 -0
  18. data/lib/fluent/compat/input.rb +1 -0
  19. data/lib/fluent/compat/output.rb +1 -0
  20. data/lib/fluent/compat/record_filter_mixin.rb +34 -0
  21. data/lib/fluent/compat/set_tag_key_mixin.rb +50 -0
  22. data/lib/fluent/compat/set_time_key_mixin.rb +69 -0
  23. data/lib/fluent/compat/type_converter.rb +90 -0
  24. data/lib/fluent/config/configure_proxy.rb +24 -4
  25. data/lib/fluent/config/dsl.rb +18 -1
  26. data/lib/fluent/config/v1_parser.rb +3 -2
  27. data/lib/fluent/configurable.rb +1 -1
  28. data/lib/fluent/event.rb +37 -9
  29. data/lib/fluent/mixin.rb +12 -286
  30. data/lib/fluent/plugin/buffer.rb +2 -2
  31. data/lib/fluent/plugin/in_dummy.rb +5 -1
  32. data/lib/fluent/plugin/in_gc_stat.rb +7 -37
  33. data/lib/fluent/plugin/in_http.rb +2 -0
  34. data/lib/fluent/plugin/{in_stream.rb → in_unix.rb} +0 -0
  35. data/lib/fluent/plugin/out_buffered_stdout.rb +60 -0
  36. data/lib/fluent/plugin/out_copy.rb +8 -51
  37. data/lib/fluent/plugin/out_null.rb +5 -5
  38. data/lib/fluent/plugin/out_relabel.rb +5 -5
  39. data/lib/fluent/plugin/out_roundrobin.rb +13 -40
  40. data/lib/fluent/plugin/output.rb +9 -0
  41. data/lib/fluent/plugin_helper.rb +2 -0
  42. data/lib/fluent/plugin_helper/formatter.rb +138 -0
  43. data/lib/fluent/plugin_helper/inject.rb +112 -0
  44. data/lib/fluent/plugin_helper/parser.rb +138 -0
  45. data/lib/fluent/plugin_helper/storage.rb +64 -50
  46. data/lib/fluent/process.rb +6 -1
  47. data/lib/fluent/registry.rb +1 -1
  48. data/lib/fluent/supervisor.rb +20 -2
  49. data/lib/fluent/test.rb +30 -5
  50. data/lib/fluent/test/base.rb +2 -66
  51. data/lib/fluent/test/driver/base.rb +3 -0
  52. data/lib/fluent/test/driver/base_owned.rb +106 -0
  53. data/lib/fluent/test/driver/formatter.rb +30 -0
  54. data/lib/fluent/test/driver/multi_output.rb +52 -0
  55. data/lib/fluent/test/driver/owner.rb +32 -0
  56. data/lib/fluent/test/driver/parser.rb +30 -0
  57. data/lib/fluent/test/helpers.rb +54 -0
  58. data/lib/fluent/test/log.rb +73 -0
  59. data/lib/fluent/time.rb +71 -0
  60. data/lib/fluent/version.rb +1 -1
  61. data/test/compat/test_parser.rb +82 -0
  62. data/test/config/test_configure_proxy.rb +15 -0
  63. data/test/config/test_dsl.rb +180 -2
  64. data/test/helper.rb +2 -24
  65. data/test/plugin/test_in_gc_stat.rb +6 -6
  66. data/test/plugin/test_in_http.rb +49 -32
  67. data/test/plugin/{test_in_stream.rb → test_in_unix.rb} +1 -1
  68. data/test/plugin/test_out_buffered_stdout.rb +108 -0
  69. data/test/plugin/test_out_copy.rb +88 -127
  70. data/test/plugin/test_out_null.rb +29 -0
  71. data/test/plugin/test_out_relabel.rb +28 -0
  72. data/test/plugin/test_out_roundrobin.rb +35 -29
  73. data/test/plugin/test_out_stdout.rb +4 -4
  74. data/test/plugin/test_output_as_buffered.rb +51 -0
  75. data/test/plugin/test_output_as_buffered_secondary.rb +13 -0
  76. data/test/plugin/test_parser_apache.rb +38 -0
  77. data/test/plugin/test_parser_apache2.rb +38 -0
  78. data/test/plugin/test_parser_apache_error.rb +40 -0
  79. data/test/plugin/test_parser_base.rb +32 -0
  80. data/test/plugin/test_parser_csv.rb +94 -0
  81. data/test/plugin/test_parser_json.rb +107 -0
  82. data/test/plugin/test_parser_labeled_tsv.rb +129 -0
  83. data/test/plugin/test_parser_multiline.rb +100 -0
  84. data/test/plugin/test_parser_nginx.rb +42 -0
  85. data/test/plugin/test_parser_none.rb +53 -0
  86. data/test/plugin/test_parser_regexp.rb +110 -0
  87. data/test/plugin/test_parser_syslog.rb +66 -0
  88. data/test/plugin/test_parser_time.rb +46 -0
  89. data/test/plugin/test_parser_tsv.rb +125 -0
  90. data/test/plugin_helper/test_child_process.rb +11 -2
  91. data/test/plugin_helper/test_formatter.rb +212 -0
  92. data/test/plugin_helper/test_inject.rb +388 -0
  93. data/test/plugin_helper/test_parser.rb +223 -0
  94. data/test/plugin_helper/test_retry_state.rb +40 -40
  95. data/test/plugin_helper/test_storage.rb +77 -10
  96. data/test/scripts/fluent/plugin/out_test.rb +22 -17
  97. data/test/scripts/fluent/plugin/out_test2.rb +80 -0
  98. data/test/test_event.rb +57 -0
  99. data/test/test_formatter.rb +0 -178
  100. data/test/test_output.rb +2 -152
  101. data/test/test_root_agent.rb +3 -2
  102. data/test/test_supervisor.rb +93 -26
  103. data/test/test_time_formatter.rb +186 -0
  104. metadata +69 -7
  105. data/test/test_parser.rb +0 -1087
@@ -0,0 +1,29 @@
1
+ require_relative '../helper'
2
+ require 'fluent/test/driver/output'
3
+ require 'fluent/plugin/out_null'
4
+
5
+ class NullOutputTest < Test::Unit::TestCase
6
+ def setup
7
+ Fluent::Test.setup
8
+ end
9
+
10
+ def create_driver(conf = "")
11
+ Fluent::Test::Driver::Output.new(Fluent::Plugin::NullOutput).configure(conf)
12
+ end
13
+
14
+ def test_configure
15
+ assert_nothing_raised do
16
+ create_driver
17
+ end
18
+ end
19
+
20
+ def test_process
21
+ d = create_driver
22
+ assert_nothing_raised do
23
+ d.run do
24
+ d.feed("test", Fluent::EventTime.now, {"test" => "null"})
25
+ end
26
+ end
27
+ assert_equal([], d.events(tag: "test"))
28
+ end
29
+ end
@@ -0,0 +1,28 @@
1
+ require_relative '../helper'
2
+ require 'fluent/test/driver/output'
3
+ require 'fluent/plugin/out_relabel'
4
+
5
+ class RelabelOutputTest < Test::Unit::TestCase
6
+ def setup
7
+ Fluent::Test.setup
8
+ end
9
+
10
+ def default_config
11
+ config_element('ROOT', '', {"@type"=>"relabel", "@label"=>"@RELABELED"})
12
+ end
13
+
14
+ def create_driver(conf = default_config)
15
+ Fluent::Test::Driver::Output.new(Fluent::Plugin::RelabelOutput).configure(conf)
16
+ end
17
+
18
+ def test_process
19
+ d = create_driver
20
+
21
+ time = event_time("2011-01-02 13:14:15 UTC")
22
+ d.run(default_tag: 'test') do
23
+ d.feed(time, {"a"=>1})
24
+ d.feed(time, {"a"=>2})
25
+ end
26
+ assert_equal [["test", time, {"a"=>1}], ["test", time, {"a"=>2}]], d.events
27
+ end
28
+ end
@@ -1,5 +1,5 @@
1
1
  require_relative '../helper'
2
- require 'fluent/test'
2
+ require 'fluent/test/driver/multi_output'
3
3
  require 'fluent/plugin/out_roundrobin'
4
4
 
5
5
  class RoundRobinOutputTest < Test::Unit::TestCase
@@ -7,6 +7,7 @@ class RoundRobinOutputTest < Test::Unit::TestCase
7
7
  def startup
8
8
  $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'scripts'))
9
9
  require 'fluent/plugin/out_test'
10
+ require 'fluent/plugin/out_test2'
10
11
  end
11
12
 
12
13
  def shutdown
@@ -20,37 +21,37 @@ class RoundRobinOutputTest < Test::Unit::TestCase
20
21
 
21
22
  CONFIG = %[
22
23
  <store>
23
- type test
24
+ @type test
24
25
  name c0
25
26
  </store>
26
27
  <store>
27
- type test
28
+ @type test2
28
29
  name c1
29
30
  </store>
30
31
  <store>
31
- type test
32
+ @type test
32
33
  name c2
33
34
  </store>
34
35
  ]
35
36
  CONFIG_WITH_WEIGHT = %[
36
37
  <store>
37
- type test
38
+ @type test
38
39
  name c0
39
40
  weight 3
40
41
  </store>
41
42
  <store>
42
- type test
43
+ @type test2
43
44
  name c1
44
45
  weight 3
45
46
  </store>
46
47
  <store>
47
- type test
48
+ @type test
48
49
  name c2
49
50
  </store>
50
51
  ]
51
52
 
52
53
  def create_driver(conf = CONFIG)
53
- Fluent::Test::OutputTestDriver.new(Fluent::RoundRobinOutput).configure(conf)
54
+ Fluent::Test::Driver::MultiOutput.new(Fluent::Plugin::RoundRobinOutput).configure(conf)
54
55
  end
55
56
 
56
57
  def test_configure
@@ -58,9 +59,16 @@ class RoundRobinOutputTest < Test::Unit::TestCase
58
59
 
59
60
  outputs = d.instance.outputs
60
61
  assert_equal 3, outputs.size
61
- assert_equal Fluent::TestOutput, outputs[0].class
62
- assert_equal Fluent::TestOutput, outputs[1].class
63
- assert_equal Fluent::TestOutput, outputs[2].class
62
+
63
+ assert_equal Fluent::Plugin::TestOutput, outputs[0].class
64
+ assert_equal Fluent::Plugin::Test2Output, outputs[1].class
65
+ assert_equal Fluent::Plugin::TestOutput, outputs[2].class
66
+
67
+ assert !outputs[0].has_router?
68
+ assert outputs[1].has_router?
69
+ assert outputs[1].router
70
+ assert !outputs[2].has_router?
71
+
64
72
  assert_equal "c0", outputs[0].name
65
73
  assert_equal "c1", outputs[1].name
66
74
  assert_equal "c2", outputs[2].name
@@ -75,9 +83,11 @@ class RoundRobinOutputTest < Test::Unit::TestCase
75
83
 
76
84
  outputs = d.instance.outputs
77
85
  assert_equal 3, outputs.size
78
- assert_equal Fluent::TestOutput, outputs[0].class
79
- assert_equal Fluent::TestOutput, outputs[1].class
80
- assert_equal Fluent::TestOutput, outputs[2].class
86
+
87
+ assert_equal Fluent::Plugin::TestOutput, outputs[0].class
88
+ assert_equal Fluent::Plugin::Test2Output, outputs[1].class
89
+ assert_equal Fluent::Plugin::TestOutput, outputs[2].class
90
+
81
91
  assert_equal "c0", outputs[0].name
82
92
  assert_equal "c1", outputs[1].name
83
93
  assert_equal "c2", outputs[2].name
@@ -89,15 +99,15 @@ class RoundRobinOutputTest < Test::Unit::TestCase
89
99
  assert_equal 1, weights[2]
90
100
  end
91
101
 
92
- def test_emit
102
+ def test_events_feeded_to_plugins_by_roundrobin
93
103
  d = create_driver
94
104
 
95
- time = Time.parse("2011-01-02 13:14:15 UTC").to_i
96
- d.run do
97
- d.emit({"a"=>1}, time)
98
- d.emit({"a"=>2}, time)
99
- d.emit({"a"=>3}, time)
100
- d.emit({"a"=>4}, time)
105
+ time = event_time("2011-01-02 13:14:15 UTC")
106
+ d.run(default_tag: 'test') do
107
+ d.feed(time, {"a" => 1})
108
+ d.feed(time, {"a" => 2})
109
+ d.feed(time, {"a" => 3})
110
+ d.feed(time, {"a" => 4})
101
111
  end
102
112
 
103
113
  os = d.instance.outputs
@@ -114,19 +124,15 @@ class RoundRobinOutputTest < Test::Unit::TestCase
114
124
  assert_equal [
115
125
  [time, {"a"=>3}],
116
126
  ], os[2].events
117
-
118
- d.instance.outputs.each {|o|
119
- assert_not_nil o.router
120
- }
121
127
  end
122
128
 
123
- def test_emit_weighted
129
+ def test_events_feeded_with_specified_weights
124
130
  d = create_driver(CONFIG_WITH_WEIGHT)
125
131
 
126
- time = Time.parse("2011-01-02 13:14:15 UTC").to_i
127
- d.run do
132
+ time = event_time("2011-01-02 13:14:15 UTC")
133
+ d.run(default_tag: 'test') do
128
134
  14.times do |i|
129
- d.emit({"a"=>i}, time)
135
+ d.feed(time, {"a" => i})
130
136
  end
131
137
  end
132
138
 
@@ -37,10 +37,10 @@ class StdoutOutputTest < Test::Unit::TestCase
37
37
  time = event_time()
38
38
  out = capture_log do
39
39
  d.run(default_tag: 'test') do
40
- d.feed(time, {'test' => 'test'})
40
+ d.feed(time, {'test' => 'test1'})
41
41
  end
42
42
  end
43
- assert_equal "#{Time.at(time).localtime} test: {\"test\":\"test\"}\n", out
43
+ assert_equal "#{Time.at(time).localtime} test: {\"test\":\"test1\"}\n", out
44
44
 
45
45
  if data == 'yajl'
46
46
  # NOTE: Float::NAN is not jsonable
@@ -56,10 +56,10 @@ class StdoutOutputTest < Test::Unit::TestCase
56
56
  time = event_time()
57
57
  out = capture_log do
58
58
  d.run(default_tag: 'test') do
59
- d.feed(time, {'test' => 'test'})
59
+ d.feed(time, {'test' => 'test2'})
60
60
  end
61
61
  end
62
- assert_equal "#{Time.at(time).localtime} test: {\"test\"=>\"test\"}\n", out
62
+ assert_equal "#{Time.at(time).localtime} test: {\"test\"=>\"test2\"}\n", out
63
63
 
64
64
  # NOTE: Float::NAN is not jsonable, but hash string can output it.
65
65
  out = capture_log { d.feed('test', time, {'test' => Float::NAN}) }
@@ -125,6 +125,57 @@ class BufferedOutputTest < Test::Unit::TestCase
125
125
  Timecop.return
126
126
  end
127
127
 
128
+ sub_test_case 'buffered output configured with many chunk keys' do
129
+ setup do
130
+ @stored_global_logger = $log
131
+ $log = Fluent::Test::TestLogger.new
132
+ @hash = {
133
+ 'flush_mode' => 'interval',
134
+ 'flush_thread_burst_interval' => 0.01,
135
+ 'chunk_limit_size' => 1024,
136
+ 'timekey' => 60,
137
+ }
138
+ @i = create_output(:buffered)
139
+ end
140
+ teardown do
141
+ $log = @stored_global_logger
142
+ end
143
+ test 'nothing are warned with less chunk keys' do
144
+ chunk_keys = 'time,key1,key2,key3'
145
+ @i.configure(config_element('ROOT','',{},[config_element('buffer',chunk_keys,@hash)]))
146
+ logs = @i.log.out.logs.dup
147
+ @i.start
148
+ assert{ logs.select{|log| log.include?('[warn]') }.size == 0 }
149
+ end
150
+
151
+ test 'a warning reported with 4 chunk keys' do
152
+ chunk_keys = 'key1,key2,key3,key4'
153
+ @i.configure(config_element('ROOT','',{},[config_element('buffer',chunk_keys,@hash)]))
154
+ logs = @i.log.out.logs.dup
155
+
156
+ @i.start # this calls `log.reset`... capturing logs about configure must be done before this line
157
+ assert_equal ['key1', 'key2', 'key3', 'key4'], @i.chunk_keys
158
+
159
+ assert{ logs.select{|log| log.include?('[warn]: many chunk keys specified, and it may cause too many chunks on your system.') }.size == 1 }
160
+ end
161
+
162
+ test 'a warning reported with 4 chunk keys including "tag"' do
163
+ chunk_keys = 'tag,key1,key2,key3'
164
+ @i.configure(config_element('ROOT','',{},[config_element('buffer',chunk_keys,@hash)]))
165
+ logs = @i.log.out.logs.dup
166
+ @i.start # this calls `log.reset`... capturing logs about configure must be done before this line
167
+ assert{ logs.select{|log| log.include?('[warn]: many chunk keys specified, and it may cause too many chunks on your system.') }.size == 1 }
168
+ end
169
+
170
+ test 'time key is not included for warned chunk keys' do
171
+ chunk_keys = 'time,key1,key2,key3'
172
+ @i.configure(config_element('ROOT','',{},[config_element('buffer',chunk_keys,@hash)]))
173
+ logs = @i.log.out.logs.dup
174
+ @i.start
175
+ assert{ logs.select{|log| log.include?('[warn]') }.size == 0 }
176
+ end
177
+ end
178
+
128
179
  sub_test_case 'buffered output feature without any buffer key, flush_mode: lazy' do
129
180
  setup do
130
181
  hash = {
@@ -134,6 +134,19 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
134
134
  end
135
135
  end
136
136
 
137
+ test 'uses same plugin type with primary if @type is missing in secondary' do
138
+ bufconf = config_element('buffer','tag',{'flush_interval' => 1, 'retry_type' => :periodic, 'retry_wait' => 3, 'retry_timeout' => 30, 'retry_randomize' => false})
139
+ secconf = config_element('secondary','',{})
140
+ priconf = config_element('ROOT', '', {'@type' => 'output_secondary_test'}, [bufconf, secconf])
141
+ i = create_output()
142
+ assert_nothing_raised do
143
+ i.configure(priconf)
144
+ end
145
+ logs = i.log.out.logs
146
+ assert{ logs.empty? }
147
+ assert{ i.secondary.is_a? FluentPluginOutputAsBufferedSecondaryTest::DummyFullFeatureOutput }
148
+ end
149
+
137
150
  test 'warns if secondary plugin is different type from primary one' do
138
151
  priconf = config_element('buffer','tag',{'flush_interval' => 1, 'retry_type' => :periodic, 'retry_wait' => 3, 'retry_timeout' => 30, 'retry_randomize' => false})
139
152
  secconf = config_element('secondary','',{'@type' => 'output_secondary_test2'})
@@ -0,0 +1,38 @@
1
+ require_relative '../helper'
2
+ require 'fluent/test/driver/parser'
3
+ require 'fluent/plugin/parser'
4
+
5
+ class ApacheParserTest < ::Test::Unit::TestCase
6
+ def setup
7
+ Fluent::Test.setup
8
+ @parser = Fluent::Test::Driver::Parser.new(Fluent::Plugin.new_parser('apache'))
9
+ end
10
+
11
+ data('parse' => :parse, 'call' => :call)
12
+ def test_call(method_name)
13
+ m = @parser.instance.method(method_name)
14
+ m.call('192.168.0.1 - - [28/Feb/2013:12:00:00 +0900] "GET / HTTP/1.1" 200 777') { |time, record|
15
+ assert_equal(event_time('28/Feb/2013:12:00:00 +0900', format: '%d/%b/%Y:%H:%M:%S %z'), time)
16
+ assert_equal({
17
+ 'user' => '-',
18
+ 'method' => 'GET',
19
+ 'code' => '200',
20
+ 'size' => '777',
21
+ 'host' => '192.168.0.1',
22
+ 'path' => '/'
23
+ }, record)
24
+ }
25
+ end
26
+
27
+ def test_parse_with_keep_time_key
28
+ parser = Fluent::Test::Driver::Parser.new(Fluent::Plugin.new_parser('apache'))
29
+ parser.instance.configure(
30
+ 'time_format'=>"%d/%b/%Y:%H:%M:%S %z",
31
+ 'keep_time_key'=>'true',
32
+ )
33
+ text = '192.168.0.1 - - [28/Feb/2013:12:00:00 +0900] "GET / HTTP/1.1" 200 777'
34
+ parser.instance.parse(text) do |time, record|
35
+ assert_equal "28/Feb/2013:12:00:00 +0900", record['time']
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ require_relative '../helper'
2
+ require 'fluent/test/driver/parser'
3
+ require 'fluent/plugin/parser'
4
+
5
+ class Apache2ParserTest < ::Test::Unit::TestCase
6
+ def setup
7
+ Fluent::Test.setup
8
+ @parser = Fluent::Test::Driver::Parser.new(Fluent::Plugin::Apache2Parser)
9
+ @expected = {
10
+ 'user' => nil,
11
+ 'method' => 'GET',
12
+ 'code' => 200,
13
+ 'size' => 777,
14
+ 'host' => '192.168.0.1',
15
+ 'path' => '/',
16
+ 'referer' => nil,
17
+ 'agent' => 'Opera/12.0'
18
+ }
19
+ end
20
+
21
+ def test_parse
22
+ @parser.instance.parse('192.168.0.1 - - [28/Feb/2013:12:00:00 +0900] "GET / HTTP/1.1" 200 777 "-" "Opera/12.0"') { |time, record|
23
+ assert_equal(event_time('28/Feb/2013:12:00:00 +0900', format: '%d/%b/%Y:%H:%M:%S %z'), time)
24
+ assert_equal(@expected, record)
25
+ }
26
+ assert_equal(Fluent::Plugin::Apache2Parser::REGEXP,
27
+ @parser.instance.patterns['format'])
28
+ assert_equal(Fluent::Plugin::Apache2Parser::TIME_FORMAT,
29
+ @parser.instance.patterns['time_format'])
30
+ end
31
+
32
+ def test_parse_without_http_version
33
+ @parser.instance.parse('192.168.0.1 - - [28/Feb/2013:12:00:00 +0900] "GET /" 200 777 "-" "Opera/12.0"') { |time, record|
34
+ assert_equal(event_time('28/Feb/2013:12:00:00 +0900', format: '%d/%b/%Y:%H:%M:%S %z'), time)
35
+ assert_equal(@expected, record)
36
+ }
37
+ end
38
+ end
@@ -0,0 +1,40 @@
1
+ require_relative '../helper'
2
+ require 'fluent/test/driver/parser'
3
+ require 'fluent/plugin/parser'
4
+
5
+ class ApacheErrorParserTest < ::Test::Unit::TestCase
6
+ def setup
7
+ Fluent::Test.setup
8
+ @parser = Fluent::Test::Driver::Parser.new(Fluent::Plugin.new_parser('apache_error'))
9
+ @parser.configure({})
10
+ @expected = {
11
+ 'level' => 'error',
12
+ 'client' => '127.0.0.1',
13
+ 'message' => 'client denied by server configuration'
14
+ }
15
+ end
16
+
17
+ def test_parse
18
+ @parser.instance.parse('[Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1] client denied by server configuration') { |time, record|
19
+ assert_equal(event_time('Wed Oct 11 14:32:52 2000'), time)
20
+ assert_equal(@expected, record)
21
+ }
22
+ end
23
+
24
+ def test_parse_with_pid
25
+ @parser.instance.parse('[Wed Oct 11 14:32:52 2000] [error] [pid 1000] [client 127.0.0.1] client denied by server configuration') { |time, record|
26
+ assert_equal(event_time('Wed Oct 11 14:32:52 2000'), time)
27
+ assert_equal(@expected.merge('pid' => '1000'), record)
28
+ }
29
+ end
30
+
31
+ def test_parse_without_client
32
+ @parser.instance.parse('[Wed Oct 11 14:32:52 2000] [notice] Apache/2.2.15 (Unix) DAV/2 configured -- resuming normal operations') { |time, record|
33
+ assert_equal(event_time('Wed Oct 11 14:32:52 2000'), time)
34
+ assert_equal({
35
+ 'level' => 'notice',
36
+ 'message' => 'Apache/2.2.15 (Unix) DAV/2 configured -- resuming normal operations'
37
+ }, record)
38
+ }
39
+ end
40
+ end
@@ -0,0 +1,32 @@
1
+ require_relative '../helper'
2
+ require 'fluent/test/driver/parser'
3
+ require 'fluent/plugin/parser'
4
+
5
+ module ParserTest
6
+ class BaseParserTest < ::Test::Unit::TestCase
7
+ def setup
8
+ Fluent::Test.setup
9
+ end
10
+
11
+ def create_driver(conf={})
12
+ Fluent::Test::Driver::Parser.new(Fluent::Plugin::Parser).configure(conf)
13
+ end
14
+
15
+ def test_init
16
+ d = create_driver
17
+ assert_true d.instance.estimate_current_event
18
+ end
19
+
20
+ def test_configure_against_string_literal
21
+ d = create_driver('keep_time_key true')
22
+ assert_true d.instance.keep_time_key
23
+ end
24
+
25
+ def test_parse
26
+ d = create_driver
27
+ assert_raise NotImplementedError do
28
+ d.instance.parse('')
29
+ end
30
+ end
31
+ end
32
+ end