fluentd 1.11.0-x86-mingw32 → 1.11.5-x86-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 (78) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +92 -1
  3. data/example/copy_roundrobin.conf +3 -3
  4. data/example/counter.conf +1 -1
  5. data/example/filter_stdout.conf +2 -2
  6. data/example/{in_dummy_blocks.conf → in_sample_blocks.conf} +4 -4
  7. data/example/{in_dummy_with_compression.conf → in_sample_with_compression.conf} +3 -3
  8. data/example/logevents.conf +5 -5
  9. data/example/multi_filters.conf +1 -1
  10. data/example/out_exec_filter.conf +2 -2
  11. data/example/out_forward.conf +1 -1
  12. data/example/out_forward_buf_file.conf +1 -1
  13. data/example/out_forward_client.conf +5 -5
  14. data/example/out_forward_heartbeat_none.conf +1 -1
  15. data/example/out_forward_sd.conf +1 -1
  16. data/example/out_forward_shared_key.conf +2 -2
  17. data/example/out_forward_tls.conf +1 -1
  18. data/example/out_forward_users.conf +3 -3
  19. data/example/out_null.conf +4 -4
  20. data/example/secondary_file.conf +1 -1
  21. data/fluentd.gemspec +6 -6
  22. data/lib/fluent/command/fluentd.rb +11 -0
  23. data/lib/fluent/log.rb +33 -3
  24. data/lib/fluent/match.rb +9 -0
  25. data/lib/fluent/plugin/buffer.rb +49 -40
  26. data/lib/fluent/plugin/buffer/chunk.rb +2 -1
  27. data/lib/fluent/plugin/formatter.rb +24 -0
  28. data/lib/fluent/plugin/formatter_hash.rb +3 -1
  29. data/lib/fluent/plugin/formatter_json.rb +3 -1
  30. data/lib/fluent/plugin/formatter_ltsv.rb +3 -1
  31. data/lib/fluent/plugin/formatter_out_file.rb +3 -1
  32. data/lib/fluent/plugin/formatter_single_value.rb +3 -1
  33. data/lib/fluent/plugin/formatter_tsv.rb +3 -1
  34. data/lib/fluent/plugin/in_dummy.rb +2 -123
  35. data/lib/fluent/plugin/in_exec.rb +4 -2
  36. data/lib/fluent/plugin/in_http.rb +148 -77
  37. data/lib/fluent/plugin/in_sample.rb +141 -0
  38. data/lib/fluent/plugin/in_tail.rb +2 -2
  39. data/lib/fluent/plugin/out_http.rb +20 -2
  40. data/lib/fluent/plugin/output.rb +8 -5
  41. data/lib/fluent/plugin/parser_json.rb +5 -2
  42. data/lib/fluent/plugin_helper/cert_option.rb +5 -8
  43. data/lib/fluent/plugin_helper/child_process.rb +3 -2
  44. data/lib/fluent/plugin_helper/inject.rb +2 -1
  45. data/lib/fluent/plugin_helper/socket.rb +1 -1
  46. data/lib/fluent/supervisor.rb +11 -6
  47. data/lib/fluent/system_config.rb +2 -1
  48. data/lib/fluent/version.rb +1 -1
  49. data/test/command/test_binlog_reader.rb +22 -6
  50. data/test/plugin/test_buffer.rb +4 -0
  51. data/test/plugin/test_filter_stdout.rb +6 -1
  52. data/test/plugin/test_formatter_hash.rb +6 -3
  53. data/test/plugin/test_formatter_json.rb +14 -4
  54. data/test/plugin/test_formatter_ltsv.rb +13 -5
  55. data/test/plugin/test_formatter_out_file.rb +35 -14
  56. data/test/plugin/test_formatter_single_value.rb +12 -6
  57. data/test/plugin/test_formatter_tsv.rb +12 -4
  58. data/test/plugin/test_in_exec.rb +18 -0
  59. data/test/plugin/test_in_http.rb +57 -0
  60. data/test/plugin/{test_in_dummy.rb → test_in_sample.rb} +25 -25
  61. data/test/plugin/test_in_tail.rb +3 -0
  62. data/test/plugin/test_out_file.rb +23 -18
  63. data/test/plugin/test_output.rb +12 -0
  64. data/test/plugin_helper/data/cert/empty.pem +0 -0
  65. data/test/plugin_helper/test_cert_option.rb +7 -0
  66. data/test/plugin_helper/test_child_process.rb +15 -0
  67. data/test/plugin_helper/test_compat_parameters.rb +7 -2
  68. data/test/plugin_helper/test_http_server_helper.rb +5 -0
  69. data/test/plugin_helper/test_inject.rb +13 -0
  70. data/test/plugin_helper/test_server.rb +34 -0
  71. data/test/plugin_helper/test_socket.rb +8 -0
  72. data/test/test_formatter.rb +34 -10
  73. data/test/test_log.rb +44 -0
  74. data/test/test_match.rb +11 -0
  75. data/test/test_output.rb +6 -1
  76. data/test/test_static_config_analysis.rb +2 -2
  77. data/test/test_supervisor.rb +26 -0
  78. metadata +21 -18
@@ -36,11 +36,14 @@ class LabeledTSVFormatterTest < ::Test::Unit::TestCase
36
36
  assert_equal false, d.instance.add_newline
37
37
  end
38
38
 
39
- def test_format
40
- d = create_driver({})
39
+ data("newline (LF)" => ["lf", "\n"],
40
+ "newline (CRLF)" => ["crlf", "\r\n"])
41
+ def test_format(data)
42
+ newline_conf, newline = data
43
+ d = create_driver({"newline" => newline_conf})
41
44
  formatted = d.instance.format(tag, @time, record)
42
45
 
43
- assert_equal("message:awesome\tgreeting:hello\n", formatted)
46
+ assert_equal("message:awesome\tgreeting:hello#{newline}", formatted)
44
47
  end
45
48
 
46
49
  def test_format_without_newline
@@ -50,13 +53,18 @@ class LabeledTSVFormatterTest < ::Test::Unit::TestCase
50
53
  assert_equal("message:awesome\tgreeting:hello", formatted)
51
54
  end
52
55
 
53
- def test_format_with_customized_delimiters
56
+ data("newline (LF)" => ["lf", "\n"],
57
+ "newline (CRLF)" => ["crlf", "\r\n"])
58
+ def test_format_with_customized_delimiters(data)
59
+ newline_conf, newline = data
60
+
54
61
  d = create_driver(
55
62
  'delimiter' => ',',
56
63
  'label_delimiter' => '=',
64
+ 'newline' => newline_conf,
57
65
  )
58
66
  formatted = d.instance.format(tag, @time, record)
59
67
 
60
- assert_equal("message=awesome,greeting=hello\n", formatted)
68
+ assert_equal("message=awesome,greeting=hello#{newline}", formatted)
61
69
  end
62
70
  end
@@ -5,6 +5,11 @@ require 'fluent/plugin/formatter_out_file'
5
5
  class OutFileFormatterTest < ::Test::Unit::TestCase
6
6
  def setup
7
7
  @time = event_time
8
+ @default_newline = if Fluent.windows?
9
+ "\r\n"
10
+ else
11
+ "\n"
12
+ end
8
13
  end
9
14
 
10
15
  def create_driver(conf = {})
@@ -48,48 +53,64 @@ class OutFileFormatterTest < ::Test::Unit::TestCase
48
53
  oldtz, ENV['TZ'] = ENV['TZ'], "UTC+07"
49
54
  d = create_driver(config_element('ROOT', '', {key => value}))
50
55
  tag = 'test'
51
- assert_equal "#{expected}\t#{tag}\t#{Yajl.dump(record)}\n", d.instance.format(tag, time, record)
56
+ assert_equal "#{expected}\t#{tag}\t#{Yajl.dump(record)}#{@default_newline}", d.instance.format(tag, time, record)
52
57
  ensure
53
58
  ENV['TZ'] = oldtz
54
59
  end
55
60
  end
56
61
 
57
- def test_format
58
- d = create_driver({})
62
+ data("newline (LF)" => ["lf", "\n"],
63
+ "newline (CRLF)" => ["crlf", "\r\n"])
64
+ def test_format(data)
65
+ newline_conf, newline = data
66
+ d = create_driver({"newline" => newline_conf})
59
67
  formatted = d.instance.format(tag, @time, record)
60
68
 
61
- assert_equal("#{time2str(@time)}\t#{tag}\t#{Yajl.dump(record)}\n", formatted)
69
+ assert_equal("#{time2str(@time)}\t#{tag}\t#{Yajl.dump(record)}#{newline}", formatted)
62
70
  end
63
71
 
64
- def test_format_without_time
65
- d = create_driver('output_time' => 'false')
72
+ data("newline (LF)" => ["lf", "\n"],
73
+ "newline (CRLF)" => ["crlf", "\r\n"])
74
+ def test_format_without_time(data)
75
+ newline_conf, newline = data
76
+ d = create_driver('output_time' => 'false', 'newline' => newline_conf)
66
77
  formatted = d.instance.format(tag, @time, record)
67
78
 
68
- assert_equal("#{tag}\t#{Yajl.dump(record)}\n", formatted)
79
+ assert_equal("#{tag}\t#{Yajl.dump(record)}#{newline}", formatted)
69
80
  end
70
81
 
71
- def test_format_without_tag
72
- d = create_driver('output_tag' => 'false')
82
+ data("newline (LF)" => ["lf", "\n"],
83
+ "newline (CRLF)" => ["crlf", "\r\n"])
84
+ def test_format_without_tag(data)
85
+ newline_conf, newline = data
86
+ d = create_driver('output_tag' => 'false', 'newline' => newline_conf)
73
87
  formatted = d.instance.format(tag, @time, record)
74
88
 
75
- assert_equal("#{time2str(@time)}\t#{Yajl.dump(record)}\n", formatted)
89
+ assert_equal("#{time2str(@time)}\t#{Yajl.dump(record)}#{newline}", formatted)
76
90
  end
77
91
 
92
+ data("newline (LF)" => ["lf", "\n"],
93
+ "newline (CRLF)" => ["crlf", "\r\n"])
78
94
  def test_format_without_time_and_tag
79
- d = create_driver('output_tag' => 'false', 'output_time' => 'false')
95
+ newline_conf, newline = data
96
+ d = create_driver('output_tag' => 'false', 'output_time' => 'false', 'newline' => newline_conf)
80
97
  formatted = d.instance.format('tag', @time, record)
81
98
 
82
- assert_equal("#{Yajl.dump(record)}\n", formatted)
99
+ assert_equal("#{Yajl.dump(record)}#{newline}", formatted)
83
100
  end
84
101
 
85
- def test_format_without_time_and_tag_against_string_literal_configure
102
+ data("newline (LF)" => ["lf", "\n"],
103
+ "newline (CRLF)" => ["crlf", "\r\n"])
104
+ def test_format_without_time_and_tag_against_string_literal_configure(data)
105
+ newline_conf, newline = data
86
106
  d = create_driver(%[
87
107
  utc true
88
108
  output_tag false
89
109
  output_time false
110
+ newline #{newline_conf}
90
111
  ])
91
112
  formatted = d.instance.format('tag', @time, record)
92
113
 
93
- assert_equal("#{Yajl.dump(record)}\n", formatted)
114
+ assert_equal("#{Yajl.dump(record)}#{newline}", formatted)
94
115
  end
95
116
  end
@@ -17,10 +17,13 @@ class SingleValueFormatterTest < ::Test::Unit::TestCase
17
17
  assert_equal "foobar", d.instance.message_key
18
18
  end
19
19
 
20
- def test_format
21
- d = create_driver
20
+ data("newline (LF)" => ["lf", "\n"],
21
+ "newline (CRLF)" => ["crlf", "\r\n"])
22
+ def test_format(data)
23
+ newline_conf, newline = data
24
+ d = create_driver('newline' => newline_conf)
22
25
  formatted = d.instance.format('tag', event_time, {'message' => 'awesome'})
23
- assert_equal("awesome\n", formatted)
26
+ assert_equal("awesome#{newline}", formatted)
24
27
  end
25
28
 
26
29
  def test_format_without_newline
@@ -29,10 +32,13 @@ class SingleValueFormatterTest < ::Test::Unit::TestCase
29
32
  assert_equal("awesome", formatted)
30
33
  end
31
34
 
32
- def test_format_with_message_key
33
- d = create_driver('message_key' => 'foobar')
35
+ data("newline (LF)" => ["lf", "\n"],
36
+ "newline (CRLF)" => ["crlf", "\r\n"])
37
+ def test_format_with_message_key(data)
38
+ newline_conf, newline = data
39
+ d = create_driver('message_key' => 'foobar', 'newline' => newline_conf)
34
40
  formatted = d.instance.format('tag', event_time, {'foobar' => 'foo'})
35
41
 
36
- assert_equal("foo\n", formatted)
42
+ assert_equal("foo#{newline}", formatted)
37
43
  end
38
44
  end
@@ -37,13 +37,17 @@ class TSVFormatterTest < ::Test::Unit::TestCase
37
37
  assert_equal false, d.instance.add_newline
38
38
  end
39
39
 
40
- def test_format
40
+ data("newline (LF)" => ["lf", "\n"],
41
+ "newline (CRLF)" => ["crlf", "\r\n"])
42
+ def test_format(data)
43
+ newline_conf, newline = data
41
44
  d = create_driver(
42
45
  'keys' => 'message,greeting',
46
+ 'newline' => newline_conf
43
47
  )
44
48
  formatted = d.instance.format(tag, @time, record)
45
49
 
46
- assert_equal("awesome\thello\n", formatted)
50
+ assert_equal("awesome\thello#{newline}", formatted)
47
51
  end
48
52
 
49
53
  def test_format_without_newline
@@ -56,13 +60,17 @@ class TSVFormatterTest < ::Test::Unit::TestCase
56
60
  assert_equal("awesome\thello", formatted)
57
61
  end
58
62
 
59
- def test_format_with_customized_delimiters
63
+ data("newline (LF)" => ["lf", "\n"],
64
+ "newline (CRLF)" => ["crlf", "\r\n"])
65
+ def test_format_with_customized_delimiters(data)
66
+ newline_conf, newline = data
60
67
  d = create_driver(
61
68
  'keys' => 'message,greeting',
62
69
  'delimiter' => ',',
70
+ 'newline' => newline_conf,
63
71
  )
64
72
  formatted = d.instance.format(tag, @time, record)
65
73
 
66
- assert_equal("awesome,hello\n", formatted)
74
+ assert_equal("awesome,hello#{newline}", formatted)
67
75
  end
68
76
  end
@@ -240,4 +240,22 @@ EOC
240
240
  assert_equal [tag, time, record], event
241
241
  }
242
242
  end
243
+
244
+ test 'emit error message with read_with_stderr' do
245
+ d = create_driver %[
246
+ tag test
247
+ command ruby #{File.join(File.dirname(SCRIPT_PATH), 'foo_bar_baz_no_existence.rb')}
248
+ connect_mode read_with_stderr
249
+ <parse>
250
+ @type none
251
+ </parse>
252
+ ]
253
+ d.run(expect_records: 1, timeout: 10)
254
+
255
+ assert{ d.events.length > 0 }
256
+ d.events.each do |event|
257
+ assert_equal 'test', event[0]
258
+ assert_match /LoadError/, event[2]['message']
259
+ end
260
+ end
243
261
  end
@@ -116,6 +116,36 @@ class HttpInputTest < Test::Unit::TestCase
116
116
  assert_equal_event_time time, d.events[1][1]
117
117
  end
118
118
 
119
+ data('json' => ['json', :to_json],
120
+ 'msgpack' => ['msgpack', :to_msgpack])
121
+ def test_default_with_time_format(data)
122
+ param, method_name = data
123
+ d = create_driver(CONFIG + %[
124
+ <parse>
125
+ keep_time_key
126
+ time_format %iso8601
127
+ </parse>
128
+ ])
129
+
130
+ time = event_time("2020-06-10T01:14:27+00:00")
131
+ events = [
132
+ ["tag1", time, {"a" => 1, "time" => '2020-06-10T01:14:27+00:00'}],
133
+ ["tag2", time, {"a" => 2, "time" => '2020-06-10T01:14:27+00:00'}],
134
+ ]
135
+ res_codes = []
136
+
137
+ d.run(expect_records: 2) do
138
+ events.each do |tag, t, record|
139
+ res = post("/#{tag}", {param => record.__send__(method_name)})
140
+ res_codes << res.code
141
+ end
142
+ end
143
+ assert_equal ["200", "200"], res_codes
144
+ assert_equal events, d.events
145
+ assert_equal_event_time time, d.events[0][1]
146
+ assert_equal_event_time time, d.events[1][1]
147
+ end
148
+
119
149
  def test_multi_json
120
150
  d = create_driver
121
151
  time = event_time("2011-01-02 13:14:15 UTC")
@@ -163,6 +193,33 @@ class HttpInputTest < Test::Unit::TestCase
163
193
  assert_equal_event_time time, d.events[1][1]
164
194
  end
165
195
 
196
+ data('json' => ['json', :to_json],
197
+ 'msgpack' => ['msgpack', :to_msgpack])
198
+ def test_default_multi_with_time_format(data)
199
+ param, method_name = data
200
+ d = create_driver(CONFIG + %[
201
+ <parse>
202
+ keep_time_key
203
+ time_format %iso8601
204
+ </parse>
205
+ ])
206
+ time = event_time("2020-06-10T01:14:27+00:00")
207
+ events = [
208
+ ["tag1", time, {'a' => 1, 'time' => "2020-06-10T01:14:27+00:00"}],
209
+ ["tag1", time, {'a' => 2, 'time' => "2020-06-10T01:14:27+00:00"}],
210
+ ]
211
+ tag = "tag1"
212
+ res_codes = []
213
+ d.run(expect_records: 2, timeout: 5) do
214
+ res = post("/#{tag}", {param => events.map { |e| e[2] }.__send__(method_name)})
215
+ res_codes << res.code
216
+ end
217
+ assert_equal ["200"], res_codes
218
+ assert_equal events, d.events
219
+ assert_equal_event_time time, d.events[0][1]
220
+ assert_equal_event_time time, d.events[1][1]
221
+ end
222
+
166
223
  def test_multi_json_with_nonexistent_time_key
167
224
  d = create_driver(CONFIG + %[
168
225
  <parse>
@@ -1,33 +1,33 @@
1
1
  require_relative '../helper'
2
2
  require 'fluent/test/driver/input'
3
- require 'fluent/plugin/in_dummy'
3
+ require 'fluent/plugin/in_sample'
4
4
  require 'fileutils'
5
5
 
6
- class DummyTest < Test::Unit::TestCase
6
+ class SampleTest < Test::Unit::TestCase
7
7
  def setup
8
8
  Fluent::Test.setup
9
9
  end
10
10
 
11
11
  def create_driver(conf)
12
- Fluent::Test::Driver::Input.new(Fluent::Plugin::DummyInput).configure(conf)
12
+ Fluent::Test::Driver::Input.new(Fluent::Plugin::SampleInput).configure(conf)
13
13
  end
14
14
 
15
15
  sub_test_case 'configure' do
16
16
  test 'required parameters' do
17
17
  assert_raise_message("'tag' parameter is required") do
18
- Fluent::Plugin::DummyInput.new.configure(config_element('ROOT',''))
18
+ Fluent::Plugin::SampleInput.new.configure(config_element('ROOT',''))
19
19
  end
20
20
  end
21
21
 
22
22
  test 'tag' do
23
23
  d = create_driver(%[
24
- tag dummy
24
+ tag sample
25
25
  ])
26
- assert_equal "dummy", d.instance.tag
26
+ assert_equal "sample", d.instance.tag
27
27
  end
28
28
 
29
29
  config = %[
30
- tag dummy
30
+ tag sample
31
31
  ]
32
32
 
33
33
  test 'auto_increment_key' do
@@ -44,30 +44,30 @@ class DummyTest < Test::Unit::TestCase
44
44
  assert_equal 10, d.instance.rate
45
45
  end
46
46
 
47
- test 'dummy' do
47
+ test 'sample' do
48
48
  # hash is okay
49
- d = create_driver(config + %[dummy {"foo":"bar"}])
50
- assert_equal [{"foo"=>"bar"}], d.instance.dummy
49
+ d = create_driver(config + %[sample {"foo":"bar"}])
50
+ assert_equal [{"foo"=>"bar"}], d.instance.sample
51
51
 
52
52
  # array of hash is okay
53
- d = create_driver(config + %[dummy [{"foo":"bar"}]])
54
- assert_equal [{"foo"=>"bar"}], d.instance.dummy
53
+ d = create_driver(config + %[sample [{"foo":"bar"}]])
54
+ assert_equal [{"foo"=>"bar"}], d.instance.sample
55
55
 
56
56
  assert_raise_message(/JSON::ParserError|got incomplete JSON/) do
57
- create_driver(config + %[dummy "foo"])
57
+ create_driver(config + %[sample "foo"])
58
58
  end
59
59
 
60
60
  assert_raise_message(/is not a hash/) do
61
- create_driver(config + %[dummy ["foo"]])
61
+ create_driver(config + %[sample ["foo"]])
62
62
  end
63
63
  end
64
64
  end
65
65
 
66
66
  sub_test_case "emit" do
67
67
  config = %[
68
- tag dummy
68
+ tag sample
69
69
  rate 10
70
- dummy {"foo":"bar"}
70
+ sample {"foo":"bar"}
71
71
  ]
72
72
 
73
73
  test 'simple' do
@@ -75,7 +75,7 @@ class DummyTest < Test::Unit::TestCase
75
75
  d.run(timeout: 0.5)
76
76
 
77
77
  d.events.each do |tag, time, record|
78
- assert_equal("dummy", tag)
78
+ assert_equal("sample", tag)
79
79
  assert_equal({"foo"=>"bar"}, record)
80
80
  assert(time.is_a?(Fluent::EventTime))
81
81
  end
@@ -86,20 +86,20 @@ class DummyTest < Test::Unit::TestCase
86
86
  d.run(timeout: 0.5)
87
87
 
88
88
  d.events.each_with_index do |(tag, _time, record), i|
89
- assert_equal("dummy", tag)
89
+ assert_equal("sample", tag)
90
90
  assert_equal({"foo"=>"bar", "id"=>i}, record)
91
91
  end
92
92
  end
93
93
  end
94
94
 
95
- TEST_PLUGIN_STORAGE_PATH = File.join( File.dirname(File.dirname(__FILE__)), 'tmp', 'in_dummy', 'store' )
95
+ TEST_PLUGIN_STORAGE_PATH = File.join( File.dirname(File.dirname(__FILE__)), 'tmp', 'in_sample', 'store' )
96
96
  FileUtils.mkdir_p TEST_PLUGIN_STORAGE_PATH
97
97
 
98
- sub_test_case 'when dummy plugin has storage which is not specified the path' do
98
+ sub_test_case 'when sample plugin has storage which is not specified the path' do
99
99
  config1 = {
100
- 'tag' => 'dummy',
100
+ 'tag' => 'sample',
101
101
  'rate' => '0',
102
- 'dummy' => '[{"x": 1, "y": "1"}, {"x": 2, "y": "2"}, {"x": 3, "y": "3"}]',
102
+ 'sample' => '[{"x": 1, "y": "1"}, {"x": 2, "y": "2"}, {"x": 3, "y": "3"}]',
103
103
  'auto_increment_key' => 'id',
104
104
  }
105
105
  conf1 = config_element('ROOT', '', config1, [])
@@ -135,7 +135,7 @@ class DummyTest < Test::Unit::TestCase
135
135
  end
136
136
  end
137
137
 
138
- sub_test_case 'when dummy plugin has storage which is specified the path' do
138
+ sub_test_case 'when sample plugin has storage which is specified the path' do
139
139
  setup do
140
140
  FileUtils.rm_rf(TEST_PLUGIN_STORAGE_PATH)
141
141
  FileUtils.mkdir_p(File.join(TEST_PLUGIN_STORAGE_PATH, 'json'))
@@ -144,9 +144,9 @@ class DummyTest < Test::Unit::TestCase
144
144
 
145
145
  config2 = {
146
146
  '@id' => 'test-02',
147
- 'tag' => 'dummy',
147
+ 'tag' => 'sample',
148
148
  'rate' => '0',
149
- 'dummy' => '[{"x": 1, "y": "1"}, {"x": 2, "y": "2"}, {"x": 3, "y": "3"}]',
149
+ 'sample' => '[{"x": 1, "y": "1"}, {"x": 2, "y": "2"}, {"x": 3, "y": "3"}]',
150
150
  'auto_increment_key' => 'id',
151
151
  }
152
152
  conf2 = config_element('ROOT', '', config2, [
@@ -1403,6 +1403,9 @@ class TailInputTest < Test::Unit::TestCase
1403
1403
  end
1404
1404
 
1405
1405
  def test_tail_path_with_multiline_with_multiple_paths
1406
+ if ENV["APPVEYOR"] && Fluent.windows?
1407
+ omit "This testcase is unstable on AppVeyor."
1408
+ end
1406
1409
  files = ["#{TMP_DIR}/tail1.txt", "#{TMP_DIR}/tail2.txt"]
1407
1410
  files.each { |file| File.open(file, "wb") { |f| } }
1408
1411
 
@@ -11,6 +11,11 @@ class FileOutputTest < Test::Unit::TestCase
11
11
  Fluent::Test.setup
12
12
  FileUtils.rm_rf(TMP_DIR)
13
13
  FileUtils.mkdir_p(TMP_DIR)
14
+ @default_newline = if Fluent.windows?
15
+ "\r\n"
16
+ else
17
+ "\n"
18
+ end
14
19
  end
15
20
 
16
21
  TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/../tmp/out_file#{ENV['TEST_ENV_NUMBER']}")
@@ -91,7 +96,7 @@ class FileOutputTest < Test::Unit::TestCase
91
96
  end
92
97
  end
93
98
  assert_equal 1, d.formatted.size
94
- assert_equal %[2011-01-02T21:14:15+08:00\ttest\t{"a":1}\n], d.formatted[0]
99
+ assert_equal %[2011-01-02T21:14:15+08:00\ttest\t{"a":1}#{@default_newline}], d.formatted[0]
95
100
  end
96
101
 
97
102
  test 'no configuration error raised for basic configuration using "*" (v0.12 style)' do
@@ -296,11 +301,11 @@ class FileOutputTest < Test::Unit::TestCase
296
301
 
297
302
  assert_equal 5, d.formatted.size
298
303
 
299
- r1 = %!2016-10-03 23:58:09 +0000,my.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"my.data","time":"2016/10/04 08:58:09 +0900"}\n!
300
- r2 = %!2016-10-03 23:59:33 +0000,my.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"my.data","time":"2016/10/04 08:59:33 +0900"}\n!
301
- r3 = %!2016-10-03 23:59:57 +0000,your.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"your.data","time":"2016/10/04 08:59:57 +0900"}\n!
302
- r4 = %!2016-10-04 00:00:17 +0000,my.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"my.data","time":"2016/10/04 09:00:17 +0900"}\n!
303
- r5 = %!2016-10-04 00:01:59 +0000,your.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"your.data","time":"2016/10/04 09:01:59 +0900"}\n!
304
+ r1 = %!2016-10-03 23:58:09 +0000,my.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"my.data","time":"2016/10/04 08:58:09 +0900"}#{@default_newline}!
305
+ r2 = %!2016-10-03 23:59:33 +0000,my.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"my.data","time":"2016/10/04 08:59:33 +0900"}#{@default_newline}!
306
+ r3 = %!2016-10-03 23:59:57 +0000,your.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"your.data","time":"2016/10/04 08:59:57 +0900"}#{@default_newline}!
307
+ r4 = %!2016-10-04 00:00:17 +0000,my.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"my.data","time":"2016/10/04 09:00:17 +0900"}#{@default_newline}!
308
+ r5 = %!2016-10-04 00:01:59 +0000,your.data,{"type":"a","message":"data raw content","hostname":"testing.local","tag":"your.data","time":"2016/10/04 09:01:59 +0900"}#{@default_newline}!
304
309
  assert_equal r1, d.formatted[0]
305
310
  assert_equal r2, d.formatted[1]
306
311
  assert_equal r3, d.formatted[2]
@@ -329,8 +334,8 @@ class FileOutputTest < Test::Unit::TestCase
329
334
  d.feed(time, {"a"=>2})
330
335
  end
331
336
  assert_equal 2, d.formatted.size
332
- assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n], d.formatted[0]
333
- assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n], d.formatted[1]
337
+ assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":1}#{@default_newline}], d.formatted[0]
338
+ assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":2}#{@default_newline}], d.formatted[1]
334
339
  end
335
340
 
336
341
  test 'time formatted with specified timezone, using area name' do
@@ -344,7 +349,7 @@ class FileOutputTest < Test::Unit::TestCase
344
349
  d.feed(time, {"a"=>1})
345
350
  end
346
351
  assert_equal 1, d.formatted.size
347
- assert_equal %[2011-01-02T21:14:15+08:00\ttest\t{"a":1}\n], d.formatted[0]
352
+ assert_equal %[2011-01-02T21:14:15+08:00\ttest\t{"a":1}#{@default_newline}], d.formatted[0]
348
353
  end
349
354
 
350
355
  test 'time formatted with specified timezone, using offset' do
@@ -358,7 +363,7 @@ class FileOutputTest < Test::Unit::TestCase
358
363
  d.feed(time, {"a"=>1})
359
364
  end
360
365
  assert_equal 1, d.formatted.size
361
- assert_equal %[2011-01-02T09:44:15-03:30\ttest\t{"a":1}\n], d.formatted[0]
366
+ assert_equal %[2011-01-02T09:44:15-03:30\ttest\t{"a":1}#{@default_newline}], d.formatted[0]
362
367
  end
363
368
 
364
369
  test 'configuration error raised for invalid timezone' do
@@ -402,7 +407,7 @@ class FileOutputTest < Test::Unit::TestCase
402
407
  end
403
408
 
404
409
  assert File.exist?("#{TMP_DIR}/out_file_test.20110102_0.log.gz")
405
- check_gzipped_result("#{TMP_DIR}/out_file_test.20110102_0.log.gz", %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n])
410
+ check_gzipped_result("#{TMP_DIR}/out_file_test.20110102_0.log.gz", %[2011-01-02T13:14:15Z\ttest\t{"a":1}#{@default_newline}] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}#{@default_newline}])
406
411
  end
407
412
  end
408
413
 
@@ -469,7 +474,7 @@ class FileOutputTest < Test::Unit::TestCase
469
474
  end
470
475
 
471
476
  path = d.instance.last_written_path
472
- check_gzipped_result(path, %[#{Yajl.dump({"a" => 1, 'time' => time.to_i})}\n] + %[#{Yajl.dump({"a" => 2, 'time' => time.to_i})}\n])
477
+ check_gzipped_result(path, %[#{Yajl.dump({"a" => 1, 'time' => time.to_i})}#{@default_newline}] + %[#{Yajl.dump({"a" => 2, 'time' => time.to_i})}#{@default_newline}])
473
478
  end
474
479
 
475
480
  test 'ltsv' do
@@ -482,7 +487,7 @@ class FileOutputTest < Test::Unit::TestCase
482
487
  end
483
488
 
484
489
  path = d.instance.last_written_path
485
- check_gzipped_result(path, %[a:1\ttime:2011-01-02T13:14:15Z\n] + %[a:2\ttime:2011-01-02T13:14:15Z\n])
490
+ check_gzipped_result(path, %[a:1\ttime:2011-01-02T13:14:15Z#{@default_newline}] + %[a:2\ttime:2011-01-02T13:14:15Z#{@default_newline}])
486
491
  end
487
492
 
488
493
  test 'single_value' do
@@ -495,13 +500,13 @@ class FileOutputTest < Test::Unit::TestCase
495
500
  end
496
501
 
497
502
  path = d.instance.last_written_path
498
- check_gzipped_result(path, %[1\n] + %[2\n])
503
+ check_gzipped_result(path, %[1#{@default_newline}] + %[2#{@default_newline}])
499
504
  end
500
505
  end
501
506
 
502
507
  test 'path with index number' do
503
508
  time = event_time("2011-01-02 13:14:15 UTC")
504
- formatted_lines = %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n]
509
+ formatted_lines = %[2011-01-02T13:14:15Z\ttest\t{"a":1}#{@default_newline}] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}#{@default_newline}]
505
510
 
506
511
  write_once = ->(){
507
512
  d = create_driver
@@ -532,7 +537,7 @@ class FileOutputTest < Test::Unit::TestCase
532
537
 
533
538
  test 'append' do
534
539
  time = event_time("2011-01-02 13:14:15 UTC")
535
- formatted_lines = %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n]
540
+ formatted_lines = %[2011-01-02T13:14:15Z\ttest\t{"a":1}#{@default_newline}] + %[2011-01-02T13:14:15Z\ttest\t{"a":2}#{@default_newline}]
536
541
 
537
542
  write_once = ->(){
538
543
  d = create_driver %[
@@ -567,7 +572,7 @@ class FileOutputTest < Test::Unit::TestCase
567
572
  test 'append when JST' do
568
573
  with_timezone(Fluent.windows? ? "JST-9" : "Asia/Tokyo") do
569
574
  time = event_time("2011-01-02 03:14:15+09:00")
570
- formatted_lines = %[2011-01-02T03:14:15+09:00\ttest\t{"a":1}\n] + %[2011-01-02T03:14:15+09:00\ttest\t{"a":2}\n]
575
+ formatted_lines = %[2011-01-02T03:14:15+09:00\ttest\t{"a":1}#{@default_newline}] + %[2011-01-02T03:14:15+09:00\ttest\t{"a":2}#{@default_newline}]
571
576
 
572
577
  write_once = ->(){
573
578
  d = create_driver %[
@@ -603,7 +608,7 @@ class FileOutputTest < Test::Unit::TestCase
603
608
  test 'append when UTC-02 but timekey_zone is +0900' do
604
609
  with_timezone("UTC-02") do # +0200
605
610
  time = event_time("2011-01-02 17:14:15+02:00")
606
- formatted_lines = %[2011-01-02T17:14:15+02:00\ttest\t{"a":1}\n] + %[2011-01-02T17:14:15+02:00\ttest\t{"a":2}\n]
611
+ formatted_lines = %[2011-01-02T17:14:15+02:00\ttest\t{"a":1}#{@default_newline}] + %[2011-01-02T17:14:15+02:00\ttest\t{"a":2}#{@default_newline}]
607
612
 
608
613
  write_once = ->(){
609
614
  d = create_driver %[