fluentd 1.10.3 → 1.11.3
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 +102 -0
- data/CONTRIBUTING.md +1 -1
- 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_forward.rb +2 -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_monitor_agent.rb +1 -1
- 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_file.rb +1 -1
- data/lib/fluent/plugin/out_forward.rb +1 -1
- data/lib/fluent/plugin/out_forward/load_balancer.rb +1 -1
- data/lib/fluent/plugin/out_http.rb +15 -2
- data/lib/fluent/plugin/output.rb +1 -0
- 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/socket.rb +1 -1
- data/lib/fluent/supervisor.rb +15 -6
- data/lib/fluent/system_config.rb +2 -1
- data/lib/fluent/test/filter_test.rb +2 -2
- data/lib/fluent/test/output_test.rb +3 -3
- data/lib/fluent/version.rb +1 -1
- data/test/plugin/out_forward/test_load_balancer.rb +46 -0
- 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 -73
- data/test/plugin/test_out_http.rb +38 -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_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 +9 -6
@@ -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,
|
@@ -593,7 +598,10 @@ module Fluent
|
|
593
598
|
|
594
599
|
main_process do
|
595
600
|
create_socket_manager if @standalone_worker
|
596
|
-
|
601
|
+
if @standalone_worker
|
602
|
+
ServerEngine::Privilege.change(@chuser, @chgroup)
|
603
|
+
File.umask(0)
|
604
|
+
end
|
597
605
|
MessagePackFactory.init(enable_time_support: @system_config.enable_msgpack_time_support)
|
598
606
|
Fluent::Engine.init(@system_config)
|
599
607
|
Fluent::Engine.run_configure(@conf)
|
@@ -632,7 +640,8 @@ module Fluent
|
|
632
640
|
format: @system_config.log.format,
|
633
641
|
time_format: @system_config.log.time_format,
|
634
642
|
log_dir_perm: @system_config.dir_permission,
|
635
|
-
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
|
636
645
|
)
|
637
646
|
|
638
647
|
$log.info :supervisor, 'parsing config file is succeeded', path: @config_path
|
@@ -801,7 +810,7 @@ module Fluent
|
|
801
810
|
Fluent::Engine.reload_config(conf)
|
802
811
|
end
|
803
812
|
rescue => e
|
804
|
-
# 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
|
805
814
|
# So need this rescue code
|
806
815
|
$log.error("failed to reload config: #{e}")
|
807
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
|
@@ -30,12 +30,12 @@ module Fluent
|
|
30
30
|
attr_reader :filtered
|
31
31
|
attr_accessor :tag
|
32
32
|
|
33
|
-
def emit(record, time =
|
33
|
+
def emit(record, time = EventTime.now)
|
34
34
|
emit_with_tag(@tag, record, time)
|
35
35
|
end
|
36
36
|
alias_method :filter, :emit
|
37
37
|
|
38
|
-
def emit_with_tag(tag, record, time =
|
38
|
+
def emit_with_tag(tag, record, time = EventTime.now)
|
39
39
|
@events[tag] ||= MultiEventStream.new
|
40
40
|
@events[tag].add(time, record)
|
41
41
|
end
|
@@ -41,7 +41,7 @@ module Fluent
|
|
41
41
|
|
42
42
|
attr_accessor :tag
|
43
43
|
|
44
|
-
def emit(record, time=
|
44
|
+
def emit(record, time=EventTime.now)
|
45
45
|
es = OneEventStream.new(time, record)
|
46
46
|
@instance.emit_events(@tag, es)
|
47
47
|
end
|
@@ -62,7 +62,7 @@ module Fluent
|
|
62
62
|
|
63
63
|
attr_accessor :tag
|
64
64
|
|
65
|
-
def emit(record, time=
|
65
|
+
def emit(record, time=EventTime.now)
|
66
66
|
@entries << [time, record]
|
67
67
|
self
|
68
68
|
end
|
@@ -110,7 +110,7 @@ module Fluent
|
|
110
110
|
|
111
111
|
attr_accessor :tag
|
112
112
|
|
113
|
-
def emit(record, time=
|
113
|
+
def emit(record, time=EventTime.now)
|
114
114
|
@entries << [time, record]
|
115
115
|
self
|
116
116
|
end
|
data/lib/fluent/version.rb
CHANGED
@@ -49,6 +49,44 @@ class LoadBalancerTest < Test::Unit::TestCase
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
test 'call like round robin without weight=0 node' do
|
53
|
+
lb = Fluent::Plugin::ForwardOutput::LoadBalancer.new($log)
|
54
|
+
n1 = flexmock('node', :'standby?' => false, :'available?' => true, weight: 1)
|
55
|
+
n2 = flexmock('node', :'standby?' => false, :'available?' => true, weight: 1)
|
56
|
+
n3 = flexmock('node', :'standby?' => false, :'available?' => true, weight: 0)
|
57
|
+
|
58
|
+
lb.rebuild_weight_array([n1, n2, n3])
|
59
|
+
|
60
|
+
lb.select_healthy_node do |node|
|
61
|
+
# to handle random choice
|
62
|
+
if node == n1
|
63
|
+
lb.select_healthy_node do |node|
|
64
|
+
assert_equal(node, n2)
|
65
|
+
end
|
66
|
+
|
67
|
+
lb.select_healthy_node do |node|
|
68
|
+
assert_equal(node, n1)
|
69
|
+
end
|
70
|
+
|
71
|
+
lb.select_healthy_node do |node|
|
72
|
+
assert_equal(node, n2)
|
73
|
+
end
|
74
|
+
else
|
75
|
+
lb.select_healthy_node do |node|
|
76
|
+
assert_equal(node, n1)
|
77
|
+
end
|
78
|
+
|
79
|
+
lb.select_healthy_node do |node|
|
80
|
+
assert_equal(node, n2)
|
81
|
+
end
|
82
|
+
|
83
|
+
lb.select_healthy_node do |node|
|
84
|
+
assert_equal(node, n1)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
52
90
|
test 'raise an error if all node are unavialble' do
|
53
91
|
lb = Fluent::Plugin::ForwardOutput::LoadBalancer.new($log)
|
54
92
|
lb.rebuild_weight_array([flexmock('node', :'standby?' => false, :'available?' => false, weight: 1)])
|
@@ -56,5 +94,13 @@ class LoadBalancerTest < Test::Unit::TestCase
|
|
56
94
|
lb.select_healthy_node
|
57
95
|
end
|
58
96
|
end
|
97
|
+
|
98
|
+
test 'it regards weight=0 node as unavialble' do
|
99
|
+
lb = Fluent::Plugin::ForwardOutput::LoadBalancer.new($log)
|
100
|
+
lb.rebuild_weight_array([flexmock('node', :'standby?' => false, :'available?' => true, weight: 0)])
|
101
|
+
assert_raise(Fluent::Plugin::ForwardOutput::NoNodesAvailable) do
|
102
|
+
lb.select_healthy_node
|
103
|
+
end
|
104
|
+
end
|
59
105
|
end
|
60
106
|
end
|
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, [
|