fluentd 1.11.3 → 1.12.0
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/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
- data/.github/ISSUE_TEMPLATE/config.yml +5 -0
- data/.github/workflows/stale-actions.yml +22 -0
- data/.travis.yml +22 -2
- data/CHANGELOG.md +66 -0
- data/README.md +1 -1
- data/appveyor.yml +3 -0
- data/bin/fluent-cap-ctl +7 -0
- data/bin/fluent-ctl +7 -0
- data/fluentd.gemspec +2 -1
- data/lib/fluent/capability.rb +87 -0
- data/lib/fluent/command/cap_ctl.rb +174 -0
- data/lib/fluent/command/ctl.rb +177 -0
- data/lib/fluent/command/plugin_config_formatter.rb +2 -1
- data/lib/fluent/env.rb +4 -0
- data/lib/fluent/plugin.rb +5 -0
- data/lib/fluent/plugin/buffer.rb +2 -21
- data/lib/fluent/plugin/formatter.rb +24 -0
- data/lib/fluent/plugin/formatter_csv.rb +1 -1
- 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 +5 -3
- data/lib/fluent/plugin/formatter_out_file.rb +6 -4
- data/lib/fluent/plugin/formatter_single_value.rb +4 -2
- data/lib/fluent/plugin/formatter_tsv.rb +4 -2
- data/lib/fluent/plugin/in_http.rb +23 -2
- data/lib/fluent/plugin/in_tail.rb +109 -41
- data/lib/fluent/plugin/in_tail/position_file.rb +39 -14
- data/lib/fluent/plugin/in_tcp.rb +1 -0
- data/lib/fluent/plugin/out_http.rb +20 -2
- data/lib/fluent/plugin/output.rb +14 -6
- data/lib/fluent/plugin_helper/http_server/compat/server.rb +1 -1
- data/lib/fluent/plugin_helper/inject.rb +4 -1
- data/lib/fluent/plugin_helper/retry_state.rb +4 -0
- data/lib/fluent/supervisor.rb +140 -43
- data/lib/fluent/time.rb +1 -0
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/winsvc.rb +22 -4
- data/test/command/test_binlog_reader.rb +22 -6
- data/test/command/test_cap_ctl.rb +100 -0
- data/test/command/test_ctl.rb +57 -0
- data/test/command/test_plugin_config_formatter.rb +57 -2
- data/test/plugin/in_tail/test_position_file.rb +45 -25
- 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_in_http.rb +25 -0
- data/test/plugin/test_in_tail.rb +430 -30
- data/test/plugin/test_out_file.rb +23 -18
- data/test/plugin/test_output.rb +12 -0
- data/test/plugin/test_parser_syslog.rb +2 -2
- data/test/plugin_helper/test_compat_parameters.rb +7 -2
- data/test/plugin_helper/test_inject.rb +42 -0
- data/test/test_capability.rb +74 -0
- data/test/test_formatter.rb +34 -10
- data/test/test_output.rb +6 -1
- data/test/test_supervisor.rb +119 -1
- metadata +33 -4
@@ -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 %[
|
data/test/plugin/test_output.rb
CHANGED
@@ -378,6 +378,18 @@ class OutputTest < Test::Unit::TestCase
|
|
378
378
|
assert { logs.any? { |log| log.include?("${chunk_id} is not allowed in this plugin") } }
|
379
379
|
end
|
380
380
|
|
381
|
+
test '#extract_placeholders does not log for ${chunk_id} placeholder' do
|
382
|
+
@i.configure(config_element('ROOT', '', {}, [config_element('buffer', '')]))
|
383
|
+
tmpl = "/mypath/${chunk_id}/tail"
|
384
|
+
t = event_time('2016-04-11 20:30:00 +0900')
|
385
|
+
v = {key1: "value1", key2: "value2"}
|
386
|
+
c = create_chunk(timekey: t, tag: 'fluentd.test.output', variables: v)
|
387
|
+
@i.log.out.logs.clear
|
388
|
+
@i.extract_placeholders(tmpl, c)
|
389
|
+
logs = @i.log.out.logs
|
390
|
+
assert { logs.none? { |log| log.include?("${chunk_id}") } }
|
391
|
+
end
|
392
|
+
|
381
393
|
test '#extract_placeholders logs warn message with not replaced key' do
|
382
394
|
@i.configure(config_element('ROOT', '', {}, [config_element('buffer', '')]))
|
383
395
|
tmpl = "/mypath/${key1}/test"
|
@@ -38,7 +38,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
38
38
|
data('regexp' => 'regexp', 'string' => 'string')
|
39
39
|
def test_parse_with_time_format2(param)
|
40
40
|
@parser.configure('time_format' => '%Y-%m-%dT%H:%M:%SZ', 'parser_type' => param)
|
41
|
-
@parser.instance.parse(
|
41
|
+
@parser.instance.parse("#{Time.now.year}-03-03T10:14:29Z 192.168.0.1 fluentd[11111]: [error] Syslog test") { |time, record|
|
42
42
|
assert_equal(event_time('Mar 03 10:14:29', format: '%b %d %H:%M:%S'), time)
|
43
43
|
assert_equal(@expected, record)
|
44
44
|
}
|
@@ -47,7 +47,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
47
47
|
|
48
48
|
def test_parse_with_time_format_rfc5424
|
49
49
|
@parser.configure('time_format' => '%Y-%m-%dT%H:%M:%SZ', 'message_format' => 'rfc5424')
|
50
|
-
@parser.instance.parse(
|
50
|
+
@parser.instance.parse("#{Time.now.year}-03-03T10:14:29Z 192.168.0.1 fluentd 11111 - - [error] Syslog test") { |time, record|
|
51
51
|
assert_equal(event_time('Mar 03 10:14:29', format: '%b %d %H:%M:%S'), time)
|
52
52
|
assert_equal(@expected.merge('host' => '192.168.0.1', 'msgid' => '-', 'extradata' => '-'), record)
|
53
53
|
}
|
@@ -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
|
|
@@ -176,6 +176,48 @@ class InjectHelperTest < Test::Unit::TestCase
|
|
176
176
|
assert_equal record.merge({"timedata" => float_time}), @d.inject_values_to_record('tag', time, record)
|
177
177
|
end
|
178
178
|
|
179
|
+
test 'injects time as unix time millis into specified key' do
|
180
|
+
time_in_unix = Time.parse("2016-06-21 08:10:11 +0900").to_i
|
181
|
+
time_subsecond = 320_101_224
|
182
|
+
time = Fluent::EventTime.new(time_in_unix, time_subsecond)
|
183
|
+
unixtime_millis = 1466464211320
|
184
|
+
|
185
|
+
@d.configure(config_inject_section("time_key" => "timedata", "time_type" => "unixtime_millis"))
|
186
|
+
@d.start
|
187
|
+
|
188
|
+
record = {"key1" => "value1", "key2" => 2}
|
189
|
+
assert_equal record.merge({"timedata" => unixtime_millis}), @d.inject_values_to_record('tag', time, record)
|
190
|
+
assert_equal record.merge({"timedata" => time_in_unix * 1_000}), @d.inject_values_to_record('tag', time_in_unix, record)
|
191
|
+
end
|
192
|
+
|
193
|
+
test 'injects time as unix time micros into specified key' do
|
194
|
+
time_in_unix = Time.parse("2016-06-21 08:10:11 +0900").to_i
|
195
|
+
time_subsecond = 320_101_224
|
196
|
+
time = Fluent::EventTime.new(time_in_unix, time_subsecond)
|
197
|
+
unixtime_micros = 1466464211320101
|
198
|
+
|
199
|
+
@d.configure(config_inject_section("time_key" => "timedata", "time_type" => "unixtime_micros"))
|
200
|
+
@d.start
|
201
|
+
|
202
|
+
record = {"key1" => "value1", "key2" => 2}
|
203
|
+
assert_equal record.merge({"timedata" => unixtime_micros}), @d.inject_values_to_record('tag', time, record)
|
204
|
+
assert_equal record.merge({"timedata" => time_in_unix * 1_000_000}), @d.inject_values_to_record('tag', time_in_unix, record)
|
205
|
+
end
|
206
|
+
|
207
|
+
test 'injects time as unix time nanos into specified key' do
|
208
|
+
time_in_unix = Time.parse("2016-06-21 08:10:11 +0900").to_i
|
209
|
+
time_subsecond = 320_101_224
|
210
|
+
time = Fluent::EventTime.new(time_in_unix, time_subsecond)
|
211
|
+
unixtime_nanos = 1466464211320101224
|
212
|
+
|
213
|
+
@d.configure(config_inject_section("time_key" => "timedata", "time_type" => "unixtime_nanos"))
|
214
|
+
@d.start
|
215
|
+
|
216
|
+
record = {"key1" => "value1", "key2" => 2}
|
217
|
+
assert_equal record.merge({"timedata" => unixtime_nanos}), @d.inject_values_to_record('tag', time, record)
|
218
|
+
assert_equal record.merge({"timedata" => time_in_unix * 1_000_000_000}), @d.inject_values_to_record('tag', time_in_unix, record)
|
219
|
+
end
|
220
|
+
|
179
221
|
test 'injects time as unix time into specified key' do
|
180
222
|
time_in_unix = Time.parse("2016-06-21 08:10:11 +0900").to_i
|
181
223
|
time_subsecond = 320_101_224
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
require 'fluent/test'
|
3
|
+
require 'fluent/capability'
|
4
|
+
|
5
|
+
class FluentCapabilityTest < ::Test::Unit::TestCase
|
6
|
+
setup do
|
7
|
+
@capability = Fluent::Capability.new(:current_process)
|
8
|
+
omit "Fluent::Capability class is not usable on this environment" unless @capability.usable?
|
9
|
+
end
|
10
|
+
|
11
|
+
sub_test_case "check capability" do
|
12
|
+
test "effective" do
|
13
|
+
@capability.clear(:both)
|
14
|
+
assert_true @capability.update(:add, :effective, :dac_read_search)
|
15
|
+
assert_equal CapNG::Result::PARTIAL, @capability.have_capabilities?(:caps)
|
16
|
+
assert_nothing_raised do
|
17
|
+
@capability.apply(:caps)
|
18
|
+
end
|
19
|
+
assert_equal CapNG::Result::NONE, @capability.have_capabilities?(:bounds)
|
20
|
+
assert_true @capability.have_capability?(:effective, :dac_read_search)
|
21
|
+
assert_false @capability.have_capability?(:inheritable, :dac_read_search)
|
22
|
+
assert_false @capability.have_capability?(:permitted, :dac_read_search)
|
23
|
+
end
|
24
|
+
|
25
|
+
test "inheritable" do
|
26
|
+
@capability.clear(:both)
|
27
|
+
capabilities = [:chown, :dac_override]
|
28
|
+
assert_equal [true, true], @capability.update(:add, :inheritable, capabilities)
|
29
|
+
assert_equal CapNG::Result::NONE, @capability.have_capabilities?(:caps)
|
30
|
+
assert_nothing_raised do
|
31
|
+
@capability.apply(:caps)
|
32
|
+
end
|
33
|
+
assert_equal CapNG::Result::NONE, @capability.have_capabilities?(:bounds)
|
34
|
+
capabilities.each do |capability|
|
35
|
+
assert_false @capability.have_capability?(:effective, capability)
|
36
|
+
assert_true @capability.have_capability?(:inheritable, capability)
|
37
|
+
assert_false @capability.have_capability?(:permitted, capability)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
test "permitted" do
|
42
|
+
@capability.clear(:both)
|
43
|
+
capabilities = [:fowner, :fsetid, :kill]
|
44
|
+
assert_equal [true, true, true], @capability.update(:add, :permitted, capabilities)
|
45
|
+
assert_equal CapNG::Result::NONE, @capability.have_capabilities?(:caps)
|
46
|
+
assert_nothing_raised do
|
47
|
+
@capability.apply(:caps)
|
48
|
+
end
|
49
|
+
assert_equal CapNG::Result::NONE, @capability.have_capabilities?(:bounds)
|
50
|
+
capabilities.each do |capability|
|
51
|
+
assert_false @capability.have_capability?(:effective, capability)
|
52
|
+
assert_false @capability.have_capability?(:inheritable, capability)
|
53
|
+
assert_true @capability.have_capability?(:permitted, capability)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
test "effective/inheritable/permitted" do
|
58
|
+
@capability.clear(:both)
|
59
|
+
capabilities = [:setpcap, :net_admin, :net_raw, :sys_boot, :sys_time]
|
60
|
+
update_type = CapNG::Type::EFFECTIVE | CapNG::Type::INHERITABLE | CapNG::Type::PERMITTED
|
61
|
+
assert_equal [true, true, true, true, true], @capability.update(:add, update_type, capabilities)
|
62
|
+
assert_equal CapNG::Result::PARTIAL, @capability.have_capabilities?(:caps)
|
63
|
+
assert_nothing_raised do
|
64
|
+
@capability.apply(:caps)
|
65
|
+
end
|
66
|
+
assert_equal CapNG::Result::NONE, @capability.have_capabilities?(:bounds)
|
67
|
+
capabilities.each do |capability|
|
68
|
+
assert_true @capability.have_capability?(:effective, capability)
|
69
|
+
assert_true @capability.have_capability?(:inheritable, capability)
|
70
|
+
assert_true @capability.have_capability?(:permitted, capability)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
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
|
|