fluentd 1.10.4-x86-mingw32 → 1.11.4-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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +100 -0
- data/example/copy_roundrobin.conf +3 -3
- data/example/counter.conf +1 -1
- data/example/filter_stdout.conf +2 -2
- data/example/{in_dummy_blocks.conf → in_sample_blocks.conf} +4 -4
- data/example/{in_dummy_with_compression.conf → in_sample_with_compression.conf} +3 -3
- data/example/logevents.conf +5 -5
- data/example/multi_filters.conf +1 -1
- data/example/out_exec_filter.conf +2 -2
- data/example/out_forward.conf +1 -1
- data/example/out_forward_buf_file.conf +1 -1
- data/example/out_forward_client.conf +5 -5
- data/example/out_forward_heartbeat_none.conf +1 -1
- data/example/out_forward_sd.conf +1 -1
- data/example/out_forward_shared_key.conf +2 -2
- data/example/out_forward_tls.conf +1 -1
- data/example/out_forward_users.conf +3 -3
- data/example/out_null.conf +4 -4
- data/example/secondary_file.conf +1 -1
- data/fluentd.gemspec +5 -5
- data/lib/fluent/command/fluentd.rb +11 -0
- data/lib/fluent/log.rb +33 -3
- data/lib/fluent/match.rb +9 -0
- data/lib/fluent/plugin/buffer.rb +49 -40
- data/lib/fluent/plugin/buffer/chunk.rb +2 -1
- data/lib/fluent/plugin/in_dummy.rb +2 -123
- data/lib/fluent/plugin/in_exec.rb +4 -2
- data/lib/fluent/plugin/in_gc_stat.rb +16 -0
- data/lib/fluent/plugin/in_http.rb +148 -77
- data/lib/fluent/plugin/in_sample.rb +141 -0
- data/lib/fluent/plugin/in_tail.rb +2 -2
- data/lib/fluent/plugin/in_unix.rb +77 -77
- data/lib/fluent/plugin/out_http.rb +1 -1
- data/lib/fluent/plugin/output.rb +8 -5
- data/lib/fluent/plugin/parser_json.rb +5 -2
- data/lib/fluent/plugin/parser_syslog.rb +215 -54
- data/lib/fluent/plugin_helper/cert_option.rb +5 -8
- data/lib/fluent/plugin_helper/child_process.rb +3 -2
- data/lib/fluent/plugin_helper/inject.rb +2 -1
- data/lib/fluent/plugin_helper/socket.rb +1 -1
- data/lib/fluent/supervisor.rb +11 -5
- data/lib/fluent/system_config.rb +2 -1
- data/lib/fluent/version.rb +1 -1
- data/test/plugin/test_buffer.rb +4 -0
- data/test/plugin/test_in_exec.rb +18 -0
- data/test/plugin/test_in_gc_stat.rb +24 -1
- data/test/plugin/test_in_http.rb +57 -0
- data/test/plugin/{test_in_dummy.rb → test_in_sample.rb} +25 -25
- data/test/plugin/test_in_tail.rb +3 -0
- data/test/plugin/test_in_unix.rb +128 -72
- data/test/plugin/test_output.rb +12 -0
- data/test/plugin/test_parser_syslog.rb +66 -29
- data/test/plugin_helper/data/cert/empty.pem +0 -0
- data/test/plugin_helper/test_cert_option.rb +7 -0
- data/test/plugin_helper/test_child_process.rb +15 -0
- data/test/plugin_helper/test_http_server_helper.rb +5 -0
- data/test/plugin_helper/test_inject.rb +13 -0
- data/test/plugin_helper/test_server.rb +34 -0
- data/test/plugin_helper/test_socket.rb +8 -0
- data/test/test_log.rb +44 -0
- data/test/test_match.rb +11 -0
- data/test/test_static_config_analysis.rb +2 -2
- metadata +19 -16
@@ -27,13 +27,9 @@ module Fluent
|
|
27
27
|
cert, key, extra = cert_option_server_validate!(conf)
|
28
28
|
|
29
29
|
ctx = OpenSSL::SSL::SSLContext.new
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
ctx.set_params({})
|
34
|
-
|
35
|
-
ctx.ciphers = ciphers
|
36
|
-
end
|
30
|
+
# inject OpenSSL::SSL::SSLContext::DEFAULT_PARAMS
|
31
|
+
# https://bugs.ruby-lang.org/issues/9424
|
32
|
+
ctx.set_params({}) unless insecure
|
37
33
|
|
38
34
|
if conf.client_cert_auth
|
39
35
|
ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
|
@@ -56,6 +52,7 @@ module Fluent
|
|
56
52
|
end
|
57
53
|
|
58
54
|
Fluent::TLS.set_version_to_context(ctx, version, conf.min_version, conf.max_version)
|
55
|
+
ctx.ciphers = ciphers unless insecure
|
59
56
|
|
60
57
|
ctx
|
61
58
|
end
|
@@ -185,7 +182,7 @@ module Fluent
|
|
185
182
|
list = []
|
186
183
|
data.scan(pattern){|match| list << OpenSSL::X509::Certificate.new(match) }
|
187
184
|
if list.length == 0
|
188
|
-
|
185
|
+
raise Fluent::ConfigError, "cert_path does not contain a valid certificate"
|
189
186
|
end
|
190
187
|
list
|
191
188
|
end
|
@@ -259,6 +259,9 @@ module Fluent
|
|
259
259
|
|
260
260
|
if !mode.include?(:stderr) && !mode.include?(:read_with_stderr)
|
261
261
|
spawn_opts[:err] = IO::NULL if stderr == :discard
|
262
|
+
if !mode.include?(:read) && !mode.include?(:read_with_stderr)
|
263
|
+
spawn_opts[:out] = IO::NULL
|
264
|
+
end
|
262
265
|
writeio, readio, wait_thread = *Open3.popen2(*spawn_args, spawn_opts)
|
263
266
|
elsif mode.include?(:read_with_stderr)
|
264
267
|
writeio, readio, wait_thread = *Open3.popen2e(*spawn_args, spawn_opts)
|
@@ -275,8 +278,6 @@ module Fluent
|
|
275
278
|
if mode.include?(:read) || mode.include?(:read_with_stderr)
|
276
279
|
readio.set_encoding(external_encoding, internal_encoding, **encoding_options)
|
277
280
|
readio_in_use = true
|
278
|
-
else
|
279
|
-
readio.reopen(IO::NULL) if readio
|
280
281
|
end
|
281
282
|
if mode.include?(:stderr)
|
282
283
|
stderrio.set_encoding(external_encoding, internal_encoding, **encoding_options)
|
@@ -76,7 +76,7 @@ module Fluent
|
|
76
76
|
config_param :time_key, :string, default: nil
|
77
77
|
|
78
78
|
# To avoid defining :time_type twice
|
79
|
-
config_param :time_type, :enum, list: [:float, :unixtime, :string], default: :float
|
79
|
+
config_param :time_type, :enum, list: [:float, :unixtime, :unixtime_millis, :string], default: :float
|
80
80
|
|
81
81
|
Fluent::TimeMixin::TIME_PARAMETERS.each do |name, type, opts|
|
82
82
|
config_param(name, type, **opts)
|
@@ -132,6 +132,7 @@ module Fluent
|
|
132
132
|
if @_inject_time_key
|
133
133
|
@_inject_time_formatter = case @inject_config.time_type
|
134
134
|
when :float then ->(time){ time.to_r.truncate(+6).to_f } # microsecond floating point value
|
135
|
+
when :unixtime_millis then ->(time) { time.to_f.floor(3) * 1000 }
|
135
136
|
when :unixtime then ->(time){ time.to_i }
|
136
137
|
else
|
137
138
|
localtime = @inject_config.localtime && !@inject_config.utc
|
@@ -199,7 +199,7 @@ module Fluent
|
|
199
199
|
list = []
|
200
200
|
data.scan(pattern) { |match| list << OpenSSL::X509::Certificate.new(match) }
|
201
201
|
if list.length == 0
|
202
|
-
|
202
|
+
raise Fluent::ConfigError, "cert_path does not contain a valid certificate"
|
203
203
|
end
|
204
204
|
list
|
205
205
|
end
|
data/lib/fluent/supervisor.rb
CHANGED
@@ -302,6 +302,7 @@ module Fluent
|
|
302
302
|
log_level = params['log_level']
|
303
303
|
suppress_repeated_stacktrace = params['suppress_repeated_stacktrace']
|
304
304
|
ignore_repeated_log_interval = params['ignore_repeated_log_interval']
|
305
|
+
ignore_same_log_interval = params['ignore_same_log_interval']
|
305
306
|
|
306
307
|
log_path = params['log_path']
|
307
308
|
chuser = params['chuser']
|
@@ -309,7 +310,8 @@ module Fluent
|
|
309
310
|
log_rotate_age = params['log_rotate_age']
|
310
311
|
log_rotate_size = params['log_rotate_size']
|
311
312
|
|
312
|
-
log_opts = {suppress_repeated_stacktrace: suppress_repeated_stacktrace, ignore_repeated_log_interval: ignore_repeated_log_interval
|
313
|
+
log_opts = {suppress_repeated_stacktrace: suppress_repeated_stacktrace, ignore_repeated_log_interval: ignore_repeated_log_interval,
|
314
|
+
ignore_same_log_interval: ignore_same_log_interval}
|
313
315
|
logger_initializer = Supervisor::LoggerInitializer.new(
|
314
316
|
log_path, log_level, chuser, chgroup, log_opts,
|
315
317
|
log_rotate_age: log_rotate_age,
|
@@ -347,6 +349,7 @@ module Fluent
|
|
347
349
|
chumask: 0,
|
348
350
|
suppress_repeated_stacktrace: suppress_repeated_stacktrace,
|
349
351
|
ignore_repeated_log_interval: ignore_repeated_log_interval,
|
352
|
+
ignore_same_log_interval: ignore_same_log_interval,
|
350
353
|
daemonize: daemonize,
|
351
354
|
rpc_endpoint: params['rpc_endpoint'],
|
352
355
|
counter_server: params['counter_server'],
|
@@ -441,10 +444,11 @@ module Fluent
|
|
441
444
|
self
|
442
445
|
end
|
443
446
|
|
444
|
-
def apply_options(format: nil, time_format: nil, log_dir_perm: nil, ignore_repeated_log_interval: nil)
|
447
|
+
def apply_options(format: nil, time_format: nil, log_dir_perm: nil, ignore_repeated_log_interval: nil, ignore_same_log_interval: nil)
|
445
448
|
$log.format = format if format
|
446
449
|
$log.time_format = time_format if time_format
|
447
450
|
$log.ignore_repeated_log_interval = ignore_repeated_log_interval if ignore_repeated_log_interval
|
451
|
+
$log.ignore_same_log_interval = ignore_same_log_interval if ignore_same_log_interval
|
448
452
|
|
449
453
|
if @path && log_dir_perm
|
450
454
|
File.chmod(log_dir_perm || 0755, File.dirname(@path))
|
@@ -511,7 +515,8 @@ module Fluent
|
|
511
515
|
@cl_opt = opt
|
512
516
|
@conf = nil
|
513
517
|
|
514
|
-
log_opts = {suppress_repeated_stacktrace: opt[:suppress_repeated_stacktrace], ignore_repeated_log_interval: opt[:ignore_repeated_log_interval]
|
518
|
+
log_opts = {suppress_repeated_stacktrace: opt[:suppress_repeated_stacktrace], ignore_repeated_log_interval: opt[:ignore_repeated_log_interval],
|
519
|
+
ignore_same_log_interval: opt[:ignore_same_log_interval]}
|
515
520
|
@log = LoggerInitializer.new(
|
516
521
|
@log_path, opt[:log_level], @chuser, @chgroup, log_opts,
|
517
522
|
log_rotate_age: @log_rotate_age,
|
@@ -635,7 +640,8 @@ module Fluent
|
|
635
640
|
format: @system_config.log.format,
|
636
641
|
time_format: @system_config.log.time_format,
|
637
642
|
log_dir_perm: @system_config.dir_permission,
|
638
|
-
ignore_repeated_log_interval: @system_config.ignore_repeated_log_interval
|
643
|
+
ignore_repeated_log_interval: @system_config.ignore_repeated_log_interval,
|
644
|
+
ignore_same_log_interval: @system_config.ignore_same_log_interval
|
639
645
|
)
|
640
646
|
|
641
647
|
$log.info :supervisor, 'parsing config file is succeeded', path: @config_path
|
@@ -804,7 +810,7 @@ module Fluent
|
|
804
810
|
Fluent::Engine.reload_config(conf)
|
805
811
|
end
|
806
812
|
rescue => e
|
807
|
-
# it is
|
813
|
+
# it is guaranteed that config file is valid by supervisor side. but it's not atomic because of using signals to commnicate between worker and super
|
808
814
|
# So need this rescue code
|
809
815
|
$log.error("failed to reload config: #{e}")
|
810
816
|
next
|
data/lib/fluent/system_config.rb
CHANGED
@@ -24,7 +24,7 @@ module Fluent
|
|
24
24
|
SYSTEM_CONFIG_PARAMETERS = [
|
25
25
|
:workers, :root_dir, :log_level,
|
26
26
|
:suppress_repeated_stacktrace, :emit_error_log_interval, :suppress_config_dump,
|
27
|
-
:log_event_verbose, :ignore_repeated_log_interval,
|
27
|
+
:log_event_verbose, :ignore_repeated_log_interval, :ignore_same_log_interval,
|
28
28
|
:without_source, :rpc_endpoint, :enable_get_dump, :process_name,
|
29
29
|
:file_permission, :dir_permission, :counter_server, :counter_client,
|
30
30
|
:strict_config_value, :enable_msgpack_time_support
|
@@ -35,6 +35,7 @@ module Fluent
|
|
35
35
|
config_param :log_level, :enum, list: [:trace, :debug, :info, :warn, :error, :fatal], default: 'info'
|
36
36
|
config_param :suppress_repeated_stacktrace, :bool, default: nil
|
37
37
|
config_param :ignore_repeated_log_interval, :time, default: nil
|
38
|
+
config_param :ignore_same_log_interval, :time, default: nil
|
38
39
|
config_param :emit_error_log_interval, :time, default: nil
|
39
40
|
config_param :suppress_config_dump, :bool, default: nil
|
40
41
|
config_param :log_event_verbose, :bool, default: nil
|
data/lib/fluent/version.rb
CHANGED
data/test/plugin/test_buffer.rb
CHANGED
@@ -543,6 +543,8 @@ class BufferTest < Test::Unit::TestCase
|
|
543
543
|
assert_equal [@dm0,@dm1,@dm1], @p.queue.map(&:metadata)
|
544
544
|
assert_equal [@dm2,@dm3,m], @p.stage.keys
|
545
545
|
|
546
|
+
@p.update_timekeys
|
547
|
+
|
546
548
|
assert @p.timekeys.include?(timekey)
|
547
549
|
end
|
548
550
|
|
@@ -675,6 +677,8 @@ class BufferTest < Test::Unit::TestCase
|
|
675
677
|
assert_equal [@dm2,@dm3,m], @p.stage.keys
|
676
678
|
assert_equal 1, @p.stage[m].append_count
|
677
679
|
|
680
|
+
@p.update_timekeys
|
681
|
+
|
678
682
|
assert @p.timekeys.include?(timekey)
|
679
683
|
end
|
680
684
|
|
data/test/plugin/test_in_exec.rb
CHANGED
@@ -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
|
@@ -22,9 +22,14 @@ class GCStatInputTest < Test::Unit::TestCase
|
|
22
22
|
assert_equal("t1", d.instance.tag)
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def setup_gc_stat
|
26
26
|
stat = GC.stat
|
27
27
|
stub(GC).stat { stat }
|
28
|
+
stat
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_emit
|
32
|
+
stat = setup_gc_stat
|
28
33
|
|
29
34
|
d = create_driver
|
30
35
|
d.run(expect_emits: 2)
|
@@ -36,4 +41,22 @@ class GCStatInputTest < Test::Unit::TestCase
|
|
36
41
|
assert(events[i][1].is_a?(Fluent::EventTime))
|
37
42
|
}
|
38
43
|
end
|
44
|
+
|
45
|
+
def test_emit_with_use_symbol_keys_false
|
46
|
+
stat = setup_gc_stat
|
47
|
+
result = {}
|
48
|
+
stat.each_pair { |k, v|
|
49
|
+
result[k.to_s] = v
|
50
|
+
}
|
51
|
+
|
52
|
+
d = create_driver(CONFIG + "use_symbol_keys false")
|
53
|
+
d.run(expect_emits: 2)
|
54
|
+
|
55
|
+
events = d.events
|
56
|
+
assert(events.length > 0)
|
57
|
+
events.each_index {|i|
|
58
|
+
assert_equal(result, events[i][2])
|
59
|
+
assert(events[i][1].is_a?(Fluent::EventTime))
|
60
|
+
}
|
61
|
+
end
|
39
62
|
end
|
data/test/plugin/test_in_http.rb
CHANGED
@@ -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/
|
3
|
+
require 'fluent/plugin/in_sample'
|
4
4
|
require 'fileutils'
|
5
5
|
|
6
|
-
class
|
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::
|
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::
|
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
|
24
|
+
tag sample
|
25
25
|
])
|
26
|
-
assert_equal "
|
26
|
+
assert_equal "sample", d.instance.tag
|
27
27
|
end
|
28
28
|
|
29
29
|
config = %[
|
30
|
-
tag
|
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 '
|
47
|
+
test 'sample' do
|
48
48
|
# hash is okay
|
49
|
-
d = create_driver(config + %[
|
50
|
-
assert_equal [{"foo"=>"bar"}], d.instance.
|
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 + %[
|
54
|
-
assert_equal [{"foo"=>"bar"}], d.instance.
|
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 + %[
|
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 + %[
|
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
|
68
|
+
tag sample
|
69
69
|
rate 10
|
70
|
-
|
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("
|
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("
|
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', '
|
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
|
98
|
+
sub_test_case 'when sample plugin has storage which is not specified the path' do
|
99
99
|
config1 = {
|
100
|
-
'tag' => '
|
100
|
+
'tag' => 'sample',
|
101
101
|
'rate' => '0',
|
102
|
-
'
|
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
|
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' => '
|
147
|
+
'tag' => 'sample',
|
148
148
|
'rate' => '0',
|
149
|
-
'
|
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, [
|