fluentd 1.11.4-x64-mingw32 → 1.11.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/fluentd.gemspec +1 -1
- data/lib/fluent/plugin/formatter.rb +24 -0
- data/lib/fluent/plugin/formatter_hash.rb +3 -1
- data/lib/fluent/plugin/formatter_json.rb +3 -1
- data/lib/fluent/plugin/formatter_ltsv.rb +3 -1
- data/lib/fluent/plugin/formatter_out_file.rb +3 -1
- data/lib/fluent/plugin/formatter_single_value.rb +3 -1
- data/lib/fluent/plugin/formatter_tsv.rb +3 -1
- data/lib/fluent/plugin/out_http.rb +19 -1
- data/lib/fluent/supervisor.rb +0 -1
- data/lib/fluent/version.rb +1 -1
- data/test/command/test_binlog_reader.rb +22 -6
- data/test/plugin/test_filter_stdout.rb +6 -1
- data/test/plugin/test_formatter_hash.rb +6 -3
- data/test/plugin/test_formatter_json.rb +14 -4
- data/test/plugin/test_formatter_ltsv.rb +13 -5
- data/test/plugin/test_formatter_out_file.rb +35 -14
- data/test/plugin/test_formatter_single_value.rb +12 -6
- data/test/plugin/test_formatter_tsv.rb +12 -4
- data/test/plugin/test_out_file.rb +23 -18
- data/test/plugin_helper/test_compat_parameters.rb +7 -2
- data/test/test_formatter.rb +34 -10
- data/test/test_output.rb +6 -1
- data/test/test_supervisor.rb +26 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c7597a09c1f3a135f154a80bd00d009afa0bbbc5ce5680bcad1ca4836e1aa9c
|
4
|
+
data.tar.gz: a0b906f189be4f654c013c5fdd2e1939626fe9c3a8a76571edea7299409f7c38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13b7168e7a01fe7d0622494be5ff56bc5ed79b1ab434684675909bea1bbd3e6bcac3a591ac11f7c9e3d9998edd3232758ef2b835612cfd14ea68bea7d2bc2e9f
|
7
|
+
data.tar.gz: 2f3271fec20740870291f976be1cb1afeacb88f4a0cce7ff90820d6c056a99f086f58fd0845a796db6b682aa8cae1fc79a1f52035193e6d3a35ef5c02556684c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# v1.11
|
2
2
|
|
3
|
+
## Release v1.11.5 - 2020/11/06
|
4
|
+
|
5
|
+
### Enhancement
|
6
|
+
|
7
|
+
* formatter: Provide `newline` parameter to support `CRLF`
|
8
|
+
https://github.com/fluent/fluentd/pull/3152
|
9
|
+
* out_http: adding support for intermediate certificates
|
10
|
+
https://github.com/fluent/fluentd/pull/3146
|
11
|
+
|
12
|
+
### Bug fix
|
13
|
+
|
14
|
+
* Fix a bug that windows service isn't stopped gracefuly
|
15
|
+
https://github.com/fluent/fluentd/pull/3156
|
16
|
+
|
3
17
|
## Release v1.11.4 - 2020/10/13
|
4
18
|
|
5
19
|
### Enhancement
|
data/fluentd.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_runtime_dependency("msgpack", [">= 1.3.1", "< 2.0.0"])
|
22
22
|
gem.add_runtime_dependency("yajl-ruby", ["~> 1.0"])
|
23
23
|
gem.add_runtime_dependency("cool.io", [">= 1.4.5", "< 2.0.0"])
|
24
|
-
gem.add_runtime_dependency("serverengine", [">= 2.
|
24
|
+
gem.add_runtime_dependency("serverengine", [">= 2.2.2", "< 3.0.0"])
|
25
25
|
gem.add_runtime_dependency("http_parser.rb", [">= 0.5.1", "< 0.7.0"])
|
26
26
|
gem.add_runtime_dependency("sigdump", ["~> 0.2.2"])
|
27
27
|
gem.add_runtime_dependency("tzinfo", [">= 1.0", "< 3.0"])
|
@@ -46,5 +46,29 @@ module Fluent
|
|
46
46
|
@proc.call(tag, time, record)
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
module Newline
|
51
|
+
module Mixin
|
52
|
+
include Fluent::Configurable
|
53
|
+
|
54
|
+
DEFAULT_NEWLINE = if Fluent.windows?
|
55
|
+
:crlf
|
56
|
+
else
|
57
|
+
:lf
|
58
|
+
end
|
59
|
+
|
60
|
+
config_param :newline, :enum, list: [:lf, :crlf], default: DEFAULT_NEWLINE
|
61
|
+
|
62
|
+
def configure(conf)
|
63
|
+
super
|
64
|
+
@newline = case newline
|
65
|
+
when :lf
|
66
|
+
"\n"
|
67
|
+
when :crlf
|
68
|
+
"\r\n"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
49
73
|
end
|
50
74
|
end
|
@@ -19,13 +19,15 @@ require 'fluent/plugin/formatter'
|
|
19
19
|
module Fluent
|
20
20
|
module Plugin
|
21
21
|
class HashFormatter < Formatter
|
22
|
+
include Fluent::Plugin::Newline::Mixin
|
23
|
+
|
22
24
|
Plugin.register_formatter('hash', self)
|
23
25
|
|
24
26
|
config_param :add_newline, :bool, default: true
|
25
27
|
|
26
28
|
def format(tag, time, record)
|
27
29
|
line = record.to_s
|
28
|
-
line <<
|
30
|
+
line << @newline.freeze if @add_newline
|
29
31
|
line
|
30
32
|
end
|
31
33
|
end
|
@@ -20,6 +20,8 @@ require 'fluent/env'
|
|
20
20
|
module Fluent
|
21
21
|
module Plugin
|
22
22
|
class JSONFormatter < Formatter
|
23
|
+
include Fluent::Plugin::Newline::Mixin
|
24
|
+
|
23
25
|
Plugin.register_formatter('json', self)
|
24
26
|
|
25
27
|
config_param :json_parser, :string, default: 'oj'
|
@@ -44,7 +46,7 @@ module Fluent
|
|
44
46
|
end
|
45
47
|
|
46
48
|
def format(tag, time, record)
|
47
|
-
"#{@dump_proc.call(record)}
|
49
|
+
"#{@dump_proc.call(record)}#{@newline}"
|
48
50
|
end
|
49
51
|
|
50
52
|
def format_without_nl(tag, time, record)
|
@@ -19,6 +19,8 @@ require 'fluent/plugin/formatter'
|
|
19
19
|
module Fluent
|
20
20
|
module Plugin
|
21
21
|
class LabeledTSVFormatter < Formatter
|
22
|
+
include Fluent::Plugin::Newline::Mixin
|
23
|
+
|
22
24
|
Plugin.register_formatter('ltsv', self)
|
23
25
|
|
24
26
|
# http://ltsv.org/
|
@@ -34,7 +36,7 @@ module Fluent
|
|
34
36
|
formatted << @delimiter if formatted.length.nonzero?
|
35
37
|
formatted << "#{label}#{@label_delimiter}#{value}"
|
36
38
|
end
|
37
|
-
formatted <<
|
39
|
+
formatted << @newline.freeze if @add_newline
|
38
40
|
formatted
|
39
41
|
end
|
40
42
|
end
|
@@ -21,6 +21,8 @@ require 'yajl'
|
|
21
21
|
module Fluent
|
22
22
|
module Plugin
|
23
23
|
class OutFileFormatter < Formatter
|
24
|
+
include Fluent::Plugin::Newline::Mixin
|
25
|
+
|
24
26
|
Plugin.register_formatter('out_file', self)
|
25
27
|
|
26
28
|
config_param :output_time, :bool, default: true
|
@@ -44,7 +46,7 @@ module Fluent
|
|
44
46
|
header = ''
|
45
47
|
header << "#{@timef.format(time)}#{@delimiter}" if @output_time
|
46
48
|
header << "#{tag}#{@delimiter}" if @output_tag
|
47
|
-
"#{header}#{Yajl.dump(record)}
|
49
|
+
"#{header}#{Yajl.dump(record)}#{@newline}"
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
@@ -19,6 +19,8 @@ require 'fluent/plugin/formatter'
|
|
19
19
|
module Fluent
|
20
20
|
module Plugin
|
21
21
|
class SingleValueFormatter < Formatter
|
22
|
+
include Fluent::Plugin::Newline::Mixin
|
23
|
+
|
22
24
|
Plugin.register_formatter('single_value', self)
|
23
25
|
|
24
26
|
config_param :message_key, :string, default: 'message'
|
@@ -26,7 +28,7 @@ module Fluent
|
|
26
28
|
|
27
29
|
def format(tag, time, record)
|
28
30
|
text = record[@message_key].to_s.dup
|
29
|
-
text <<
|
31
|
+
text << @newline.freeze if @add_newline
|
30
32
|
text
|
31
33
|
end
|
32
34
|
end
|
@@ -19,6 +19,8 @@ require 'fluent/plugin/formatter'
|
|
19
19
|
module Fluent
|
20
20
|
module Plugin
|
21
21
|
class TSVFormatter < Formatter
|
22
|
+
include Fluent::Plugin::Newline::Mixin
|
23
|
+
|
22
24
|
Plugin.register_formatter('tsv', self)
|
23
25
|
|
24
26
|
desc 'Field names included in each lines'
|
@@ -30,7 +32,7 @@ module Fluent
|
|
30
32
|
|
31
33
|
def format(tag, time, record)
|
32
34
|
formatted = @keys.map{|k| record[k].to_s }.join(@delimiter)
|
33
|
-
formatted <<
|
35
|
+
formatted << @newline.freeze if @add_newline
|
34
36
|
formatted
|
35
37
|
end
|
36
38
|
end
|
@@ -21,6 +21,16 @@ require 'fluent/tls'
|
|
21
21
|
require 'fluent/plugin/output'
|
22
22
|
require 'fluent/plugin_helper/socket'
|
23
23
|
|
24
|
+
# patch Net::HTTP to support extra_chain_cert which was added in Ruby feature #9758.
|
25
|
+
# see: https://github.com/ruby/ruby/commit/31af0dafba6d3769d2a39617c0dddedb97883712
|
26
|
+
unless Net::HTTP::SSL_IVNAMES.include?(:@extra_chain_cert)
|
27
|
+
class Net::HTTP
|
28
|
+
SSL_IVNAMES << :@extra_chain_cert
|
29
|
+
SSL_ATTRIBUTES << :extra_chain_cert
|
30
|
+
attr_accessor :extra_chain_cert
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
24
34
|
module Fluent::Plugin
|
25
35
|
class HTTPOutput < Output
|
26
36
|
Fluent::Plugin.register_output('http', self)
|
@@ -171,7 +181,15 @@ module Fluent::Plugin
|
|
171
181
|
end
|
172
182
|
if @tls_client_cert_path
|
173
183
|
raise Fluent::ConfigError, "tls_client_cert_path is wrong: #{@tls_client_cert_path}" unless File.file?(@tls_client_cert_path)
|
174
|
-
|
184
|
+
|
185
|
+
bundle = File.read(@tls_client_cert_path)
|
186
|
+
bundle_certs = bundle.scan(/-----BEGIN CERTIFICATE-----(?:.|\n)+?-----END CERTIFICATE-----/)
|
187
|
+
opt[:cert] = OpenSSL::X509::Certificate.new(bundle_certs[0])
|
188
|
+
|
189
|
+
intermediate_certs = bundle_certs[1..-1]
|
190
|
+
if intermediate_certs
|
191
|
+
opt[:extra_chain_cert] = intermediate_certs.map { |cert| OpenSSL::X509::Certificate.new(cert) }
|
192
|
+
end
|
175
193
|
end
|
176
194
|
if @tls_private_key_path
|
177
195
|
raise Fluent::ConfigError, "tls_private_key_path is wrong: #{@tls_private_key_path}" unless File.file?(@tls_private_key_path)
|
data/lib/fluent/supervisor.rb
CHANGED
data/lib/fluent/version.rb
CHANGED
@@ -82,6 +82,14 @@ class TestBaseCommand < ::Test::Unit::TestCase
|
|
82
82
|
end
|
83
83
|
|
84
84
|
class TestHead < TestBaseCommand
|
85
|
+
setup do
|
86
|
+
@default_newline = if Fluent.windows?
|
87
|
+
"\r\n"
|
88
|
+
else
|
89
|
+
"\n"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
85
93
|
sub_test_case 'initialize' do
|
86
94
|
data(
|
87
95
|
'file is not passed' => %w(),
|
@@ -138,7 +146,7 @@ class TestHead < TestBaseCommand
|
|
138
146
|
create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
|
139
147
|
head = BinlogReaderCommand::Head.new(argv)
|
140
148
|
out = capture_stdout { head.call }
|
141
|
-
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}
|
149
|
+
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}#{@default_newline}" * 5, out
|
142
150
|
end
|
143
151
|
end
|
144
152
|
|
@@ -149,7 +157,7 @@ class TestHead < TestBaseCommand
|
|
149
157
|
create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
|
150
158
|
head = BinlogReaderCommand::Head.new(argv)
|
151
159
|
out = capture_stdout { head.call }
|
152
|
-
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}
|
160
|
+
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}#{@default_newline}", out
|
153
161
|
end
|
154
162
|
end
|
155
163
|
|
@@ -169,7 +177,7 @@ class TestHead < TestBaseCommand
|
|
169
177
|
create_message_packed_file(@file_name, [event_time(@t).to_i], [@record])
|
170
178
|
head = BinlogReaderCommand::Head.new(argv)
|
171
179
|
out = capture_stdout { head.call }
|
172
|
-
assert_equal "#{Yajl.dump(@record)}
|
180
|
+
assert_equal "#{Yajl.dump(@record)}#{@default_newline}", out
|
173
181
|
end
|
174
182
|
end
|
175
183
|
|
@@ -198,6 +206,14 @@ class TestHead < TestBaseCommand
|
|
198
206
|
end
|
199
207
|
|
200
208
|
class TestCat < TestBaseCommand
|
209
|
+
setup do
|
210
|
+
@default_newline = if Fluent.windows?
|
211
|
+
"\r\n"
|
212
|
+
else
|
213
|
+
"\n"
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
201
217
|
sub_test_case 'initialize' do
|
202
218
|
data(
|
203
219
|
'file is not passed' => [],
|
@@ -254,7 +270,7 @@ class TestCat < TestBaseCommand
|
|
254
270
|
create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
|
255
271
|
head = BinlogReaderCommand::Cat.new(argv)
|
256
272
|
out = capture_stdout { head.call }
|
257
|
-
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}
|
273
|
+
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}#{@default_newline}" * 6, out
|
258
274
|
end
|
259
275
|
end
|
260
276
|
|
@@ -265,7 +281,7 @@ class TestCat < TestBaseCommand
|
|
265
281
|
create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
|
266
282
|
head = BinlogReaderCommand::Cat.new(argv)
|
267
283
|
out = capture_stdout { head.call }
|
268
|
-
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}
|
284
|
+
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}#{@default_newline}", out
|
269
285
|
end
|
270
286
|
end
|
271
287
|
|
@@ -276,7 +292,7 @@ class TestCat < TestBaseCommand
|
|
276
292
|
create_message_packed_file(@file_name, [event_time(@t).to_i], [@record])
|
277
293
|
head = BinlogReaderCommand::Cat.new(argv)
|
278
294
|
out = capture_stdout { head.call }
|
279
|
-
assert_equal "#{Yajl.dump(@record)}
|
295
|
+
assert_equal "#{Yajl.dump(@record)}#{@default_newline}", out
|
280
296
|
end
|
281
297
|
end
|
282
298
|
|
@@ -12,6 +12,11 @@ class StdoutFilterTest < Test::Unit::TestCase
|
|
12
12
|
@old_tz = ENV["TZ"]
|
13
13
|
ENV["TZ"] = "UTC"
|
14
14
|
Timecop.freeze
|
15
|
+
@default_newline = if Fluent.windows?
|
16
|
+
"\r\n"
|
17
|
+
else
|
18
|
+
"\n"
|
19
|
+
end
|
15
20
|
end
|
16
21
|
|
17
22
|
def teardown
|
@@ -106,7 +111,7 @@ class StdoutFilterTest < Test::Unit::TestCase
|
|
106
111
|
def test_format_json
|
107
112
|
d = create_driver(CONFIG + config_element("", "", { "format" => "json" }))
|
108
113
|
out = capture_log(d) { filter(d, event_time, {'test' => 'test'}) }
|
109
|
-
assert_equal "{\"test\":\"test\"}
|
114
|
+
assert_equal "{\"test\":\"test\"}#{@default_newline}", out
|
110
115
|
end
|
111
116
|
end
|
112
117
|
|
@@ -19,11 +19,14 @@ class HashFormatterTest < ::Test::Unit::TestCase
|
|
19
19
|
{'message' => 'awesome', 'greeting' => 'hello'}
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
data("newline (LF)" => ["lf", "\n"],
|
23
|
+
"newline (CRLF)" => ["crlf", "\r\n"])
|
24
|
+
def test_format(data)
|
25
|
+
newline_conf, newline = data
|
26
|
+
d = create_driver({"newline" => newline_conf})
|
24
27
|
formatted = d.instance.format(tag, @time, record)
|
25
28
|
|
26
|
-
assert_equal(%Q!{"message"=>"awesome", "greeting"=>"hello"}
|
29
|
+
assert_equal(%Q!{"message"=>"awesome", "greeting"=>"hello"}#{newline}!, formatted.encode(Encoding::UTF_8))
|
27
30
|
end
|
28
31
|
|
29
32
|
def test_format_without_newline
|
@@ -7,6 +7,11 @@ class JsonFormatterTest < ::Test::Unit::TestCase
|
|
7
7
|
|
8
8
|
def setup
|
9
9
|
@time = event_time
|
10
|
+
@default_newline = if Fluent.windows?
|
11
|
+
"\r\n"
|
12
|
+
else
|
13
|
+
"\n"
|
14
|
+
end
|
10
15
|
end
|
11
16
|
|
12
17
|
def create_driver(conf = "")
|
@@ -25,12 +30,17 @@ class JsonFormatterTest < ::Test::Unit::TestCase
|
|
25
30
|
{:message => :awesome}
|
26
31
|
end
|
27
32
|
|
28
|
-
data('oj' => 'oj',
|
33
|
+
data('oj with LF' => ['oj', "lf", "\n"],
|
34
|
+
'oj with CRLF' => ['oj', "crlf", "\r\n"],
|
35
|
+
'yajl with LF' => ['yajl', "lf", "\n"],
|
36
|
+
'yajl with CRLF' => ['yajl', "crlf", "\r\n"]
|
37
|
+
)
|
29
38
|
def test_format(data)
|
30
|
-
|
39
|
+
parser, newline_conf, newline = data
|
40
|
+
d = create_driver('json_parser' => parser, 'newline' => newline_conf)
|
31
41
|
formatted = d.instance.format(tag, @time, record)
|
32
42
|
|
33
|
-
assert_equal("#{JSON.generate(record)}
|
43
|
+
assert_equal("#{JSON.generate(record)}#{newline}", formatted)
|
34
44
|
end
|
35
45
|
|
36
46
|
data('oj' => 'oj', 'yajl' => 'yajl')
|
@@ -46,6 +56,6 @@ class JsonFormatterTest < ::Test::Unit::TestCase
|
|
46
56
|
d = create_driver('json_parser' => data)
|
47
57
|
formatted = d.instance.format(tag, @time, symbolic_record)
|
48
58
|
|
49
|
-
assert_equal("#{JSON.generate(record)}
|
59
|
+
assert_equal("#{JSON.generate(record)}#{@default_newline}", formatted)
|
50
60
|
end
|
51
61
|
end
|
@@ -36,11 +36,14 @@ class LabeledTSVFormatterTest < ::Test::Unit::TestCase
|
|
36
36
|
assert_equal false, d.instance.add_newline
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
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
|
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
|
-
|
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
|
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)}
|
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
|
-
|
58
|
-
|
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)}
|
69
|
+
assert_equal("#{time2str(@time)}\t#{tag}\t#{Yajl.dump(record)}#{newline}", formatted)
|
62
70
|
end
|
63
71
|
|
64
|
-
|
65
|
-
|
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)}
|
79
|
+
assert_equal("#{tag}\t#{Yajl.dump(record)}#{newline}", formatted)
|
69
80
|
end
|
70
81
|
|
71
|
-
|
72
|
-
|
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)}
|
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
|
-
|
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)}
|
99
|
+
assert_equal("#{Yajl.dump(record)}#{newline}", formatted)
|
83
100
|
end
|
84
101
|
|
85
|
-
|
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)}
|
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
|
-
|
21
|
-
|
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
|
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
|
-
|
33
|
-
|
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
|
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
|
-
|
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
|
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
|
-
|
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
|
74
|
+
assert_equal("awesome,hello#{newline}", formatted)
|
67
75
|
end
|
68
76
|
end
|
@@ -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}
|
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"}
|
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"}
|
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"}
|
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"}
|
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"}
|
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}
|
333
|
-
assert_equal %[2011-01-02T13:14:15Z\ttest\t{"a":2}
|
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}
|
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}
|
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}
|
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})}
|
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
|
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
|
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}
|
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}
|
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}
|
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}
|
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 %[
|
@@ -10,6 +10,11 @@ class CompatParameterTest < Test::Unit::TestCase
|
|
10
10
|
setup do
|
11
11
|
Fluent::Test.setup
|
12
12
|
@i = nil
|
13
|
+
@default_newline = if Fluent.windows?
|
14
|
+
"\r\n"
|
15
|
+
else
|
16
|
+
"\n"
|
17
|
+
end
|
13
18
|
end
|
14
19
|
|
15
20
|
teardown do
|
@@ -226,7 +231,7 @@ class CompatParameterTest < Test::Unit::TestCase
|
|
226
231
|
t = event_time('2016-06-24 16:05:01') # localtime
|
227
232
|
iso8601str = Time.at(t.to_i).iso8601
|
228
233
|
formatted = @i.f.format('tag.test', t, @i.inject_values_to_record('tag.test', t, {"value" => 1}))
|
229
|
-
assert_equal "value%1,tag%tag.test,time%#{iso8601str}
|
234
|
+
assert_equal "value%1,tag%tag.test,time%#{iso8601str}#{@default_newline}", formatted
|
230
235
|
end
|
231
236
|
|
232
237
|
test 'plugin helper setups time injecting as unix time (integer from epoch)' do
|
@@ -260,7 +265,7 @@ class CompatParameterTest < Test::Unit::TestCase
|
|
260
265
|
t = event_time('2016-06-24 16:05:01') # localtime
|
261
266
|
iso8601str = Time.at(t.to_i).iso8601
|
262
267
|
formatted = @i.f.format('tag.test', t, @i.inject_values_to_record('tag.test', t, {"value" => 1}))
|
263
|
-
assert_equal "value%1,tag%tag.test,time%#{iso8601str}
|
268
|
+
assert_equal "value%1,tag%tag.test,time%#{iso8601str}#{@default_newline}", formatted
|
264
269
|
end
|
265
270
|
end
|
266
271
|
|
data/test/test_formatter.rb
CHANGED
@@ -53,6 +53,11 @@ module FormatterTest
|
|
53
53
|
def setup
|
54
54
|
@formatter = Fluent::Test::FormatterTestDriver.new('out_file')
|
55
55
|
@time = Engine.now
|
56
|
+
@newline = if Fluent.windows?
|
57
|
+
"\r\n"
|
58
|
+
else
|
59
|
+
"\n"
|
60
|
+
end
|
56
61
|
end
|
57
62
|
|
58
63
|
def configure(conf)
|
@@ -63,28 +68,28 @@ module FormatterTest
|
|
63
68
|
configure({})
|
64
69
|
formatted = @formatter.format(tag, @time, record)
|
65
70
|
|
66
|
-
assert_equal("#{time2str(@time)}\t#{tag}\t#{Yajl.dump(record)}
|
71
|
+
assert_equal("#{time2str(@time)}\t#{tag}\t#{Yajl.dump(record)}#{@newline}", formatted)
|
67
72
|
end
|
68
73
|
|
69
74
|
def test_format_without_time
|
70
75
|
configure('output_time' => 'false')
|
71
76
|
formatted = @formatter.format(tag, @time, record)
|
72
77
|
|
73
|
-
assert_equal("#{tag}\t#{Yajl.dump(record)}
|
78
|
+
assert_equal("#{tag}\t#{Yajl.dump(record)}#{@newline}", formatted)
|
74
79
|
end
|
75
80
|
|
76
81
|
def test_format_without_tag
|
77
82
|
configure('output_tag' => 'false')
|
78
83
|
formatted = @formatter.format(tag, @time, record)
|
79
84
|
|
80
|
-
assert_equal("#{time2str(@time)}\t#{Yajl.dump(record)}
|
85
|
+
assert_equal("#{time2str(@time)}\t#{Yajl.dump(record)}#{@newline}", formatted)
|
81
86
|
end
|
82
87
|
|
83
88
|
def test_format_without_time_and_tag
|
84
89
|
configure('output_tag' => 'false', 'output_time' => 'false')
|
85
90
|
formatted = @formatter.format('tag', @time, record)
|
86
91
|
|
87
|
-
assert_equal("#{Yajl.dump(record)}
|
92
|
+
assert_equal("#{Yajl.dump(record)}#{@newline}", formatted)
|
88
93
|
end
|
89
94
|
|
90
95
|
def test_format_without_time_and_tag_against_string_literal_configure
|
@@ -95,7 +100,7 @@ module FormatterTest
|
|
95
100
|
])
|
96
101
|
formatted = @formatter.format('tag', @time, record)
|
97
102
|
|
98
|
-
assert_equal("#{Yajl.dump(record)}
|
103
|
+
assert_equal("#{Yajl.dump(record)}#{@newline}", formatted)
|
99
104
|
end
|
100
105
|
end
|
101
106
|
|
@@ -105,6 +110,11 @@ module FormatterTest
|
|
105
110
|
def setup
|
106
111
|
@formatter = Fluent::Test::FormatterTestDriver.new(TextFormatter::JSONFormatter)
|
107
112
|
@time = Engine.now
|
113
|
+
@newline = if Fluent.windows?
|
114
|
+
"\r\n"
|
115
|
+
else
|
116
|
+
"\n"
|
117
|
+
end
|
108
118
|
end
|
109
119
|
|
110
120
|
data('oj' => 'oj', 'yajl' => 'yajl')
|
@@ -112,7 +122,7 @@ module FormatterTest
|
|
112
122
|
@formatter.configure('json_parser' => data)
|
113
123
|
formatted = @formatter.format(tag, @time, record)
|
114
124
|
|
115
|
-
assert_equal("#{Yajl.dump(record)}
|
125
|
+
assert_equal("#{Yajl.dump(record)}#{@newline}", formatted)
|
116
126
|
end
|
117
127
|
end
|
118
128
|
|
@@ -138,6 +148,11 @@ module FormatterTest
|
|
138
148
|
def setup
|
139
149
|
@formatter = TextFormatter::LabeledTSVFormatter.new
|
140
150
|
@time = Engine.now
|
151
|
+
@newline = if Fluent.windows?
|
152
|
+
"\r\n"
|
153
|
+
else
|
154
|
+
"\n"
|
155
|
+
end
|
141
156
|
end
|
142
157
|
|
143
158
|
def test_config_params
|
@@ -157,7 +172,7 @@ module FormatterTest
|
|
157
172
|
@formatter.configure({})
|
158
173
|
formatted = @formatter.format(tag, @time, record)
|
159
174
|
|
160
|
-
assert_equal("message:awesome\tgreeting:hello
|
175
|
+
assert_equal("message:awesome\tgreeting:hello#{@newline}", formatted)
|
161
176
|
end
|
162
177
|
|
163
178
|
def test_format_with_customized_delimiters
|
@@ -167,7 +182,7 @@ module FormatterTest
|
|
167
182
|
)
|
168
183
|
formatted = @formatter.format(tag, @time, record)
|
169
184
|
|
170
|
-
assert_equal("message=awesome,greeting=hello
|
185
|
+
assert_equal("message=awesome,greeting=hello#{@newline}", formatted)
|
171
186
|
end
|
172
187
|
end
|
173
188
|
|
@@ -260,6 +275,14 @@ module FormatterTest
|
|
260
275
|
|
261
276
|
class SingleValueFormatterTest < ::Test::Unit::TestCase
|
262
277
|
include FormatterTest
|
278
|
+
def setup
|
279
|
+
@newline = if Fluent.windows?
|
280
|
+
"\r\n"
|
281
|
+
else
|
282
|
+
"\n"
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
263
286
|
|
264
287
|
def test_config_params
|
265
288
|
formatter = TextFormatter::SingleValueFormatter.new
|
@@ -271,8 +294,9 @@ module FormatterTest
|
|
271
294
|
|
272
295
|
def test_format
|
273
296
|
formatter = Fluent::Plugin.new_formatter('single_value')
|
297
|
+
formatter.configure({})
|
274
298
|
formatted = formatter.format('tag', Engine.now, {'message' => 'awesome'})
|
275
|
-
assert_equal("awesome
|
299
|
+
assert_equal("awesome#{@newline}", formatted)
|
276
300
|
end
|
277
301
|
|
278
302
|
def test_format_without_newline
|
@@ -287,7 +311,7 @@ module FormatterTest
|
|
287
311
|
formatter.configure('message_key' => 'foobar')
|
288
312
|
formatted = formatter.format('tag', Engine.now, {'foobar' => 'foo'})
|
289
313
|
|
290
|
-
assert_equal("foo
|
314
|
+
assert_equal("foo#{@newline}", formatted)
|
291
315
|
end
|
292
316
|
end
|
293
317
|
|
data/test/test_output.rb
CHANGED
@@ -230,6 +230,11 @@ module FluentOutputTest
|
|
230
230
|
setup do
|
231
231
|
@time = Time.parse("2011-01-02 13:14:15 UTC")
|
232
232
|
Timecop.freeze(@time)
|
233
|
+
@newline = if Fluent.windows?
|
234
|
+
"\r\n"
|
235
|
+
else
|
236
|
+
"\n"
|
237
|
+
end
|
233
238
|
end
|
234
239
|
|
235
240
|
teardown do
|
@@ -265,7 +270,7 @@ module FluentOutputTest
|
|
265
270
|
])
|
266
271
|
time = Time.parse("2016-11-08 12:00:00 UTC").to_i
|
267
272
|
d.emit({"a" => 1}, time)
|
268
|
-
d.expect_format %[2016-11-08T12:00:00Z\ttest\t{"a":1,"time":"2016-11-08T12:00:00Z"}
|
273
|
+
d.expect_format %[2016-11-08T12:00:00Z\ttest\t{"a":1,"time":"2016-11-08T12:00:00Z"}#{@newline}]
|
269
274
|
d.run
|
270
275
|
end
|
271
276
|
end
|
data/test/test_supervisor.rb
CHANGED
@@ -8,6 +8,10 @@ require 'net/http'
|
|
8
8
|
require 'uri'
|
9
9
|
require 'fileutils'
|
10
10
|
|
11
|
+
if Fluent.windows?
|
12
|
+
require 'win32/event'
|
13
|
+
end
|
14
|
+
|
11
15
|
class SupervisorTest < ::Test::Unit::TestCase
|
12
16
|
class DummyServer
|
13
17
|
include Fluent::ServerModule
|
@@ -128,6 +132,28 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
128
132
|
$log.out.reset if $log && $log.out && $log.out.respond_to?(:reset)
|
129
133
|
end
|
130
134
|
|
135
|
+
def test_windows_shutdown_event
|
136
|
+
omit "Only for Windows platform" unless Fluent.windows?
|
137
|
+
|
138
|
+
server = DummyServer.new
|
139
|
+
def server.config
|
140
|
+
{:signame => "TestFluentdEvent", :worker_pid => {0 => 1234}}
|
141
|
+
end
|
142
|
+
|
143
|
+
mock(server).stop(true)
|
144
|
+
stub(Process).kill.times(0)
|
145
|
+
|
146
|
+
server.before_run
|
147
|
+
server.install_windows_event_handler
|
148
|
+
sleep 0.1 # Wait for starting windows event thread
|
149
|
+
event = Win32::Event.open("TestFluentdEvent")
|
150
|
+
event.set
|
151
|
+
event.close
|
152
|
+
# Wait for stopping windows event thread. Should larger than 1 sec
|
153
|
+
# because the thread is awaked every 1 sec.
|
154
|
+
sleep 1.1
|
155
|
+
end
|
156
|
+
|
131
157
|
def test_rpc_server
|
132
158
|
omit "Windows cannot handle signals" if Fluent.windows?
|
133
159
|
|
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: 1.11.
|
4
|
+
version: 1.11.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: 2020-
|
11
|
+
date: 2020-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -70,7 +70,7 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: 2.
|
73
|
+
version: 2.2.2
|
74
74
|
- - "<"
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: 3.0.0
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
requirements:
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 2.
|
83
|
+
version: 2.2.2
|
84
84
|
- - "<"
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: 3.0.0
|