fluentd 1.11.4-x86-mingw32 → 1.12.3-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/.deepsource.toml +13 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +1 -1
- data/.github/ISSUE_TEMPLATE/config.yml +5 -0
- data/.github/workflows/linux-test.yaml +36 -0
- data/.github/workflows/macos-test.yaml +30 -0
- data/.github/workflows/stale-actions.yml +22 -0
- data/.github/workflows/windows-test.yaml +35 -0
- data/.gitlab-ci.yml +41 -19
- data/CHANGELOG.md +166 -0
- data/MAINTAINERS.md +5 -2
- data/README.md +7 -4
- data/bin/fluent-cap-ctl +7 -0
- data/bin/fluent-ctl +7 -0
- data/fluentd.gemspec +7 -5
- data/lib/fluent/capability.rb +87 -0
- data/lib/fluent/command/bundler_injection.rb +1 -1
- data/lib/fluent/command/ca_generate.rb +6 -3
- data/lib/fluent/command/cap_ctl.rb +174 -0
- data/lib/fluent/command/cat.rb +0 -1
- data/lib/fluent/command/ctl.rb +177 -0
- data/lib/fluent/command/fluentd.rb +4 -0
- data/lib/fluent/command/plugin_config_formatter.rb +18 -2
- data/lib/fluent/command/plugin_generator.rb +31 -1
- data/lib/fluent/compat/parser.rb +2 -2
- data/lib/fluent/config/section.rb +2 -2
- data/lib/fluent/config/types.rb +2 -2
- data/lib/fluent/env.rb +4 -0
- data/lib/fluent/event.rb +3 -13
- data/lib/fluent/load.rb +0 -1
- data/lib/fluent/plugin.rb +5 -0
- data/lib/fluent/plugin/buffer.rb +2 -21
- data/lib/fluent/plugin/file_wrapper.rb +39 -3
- 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 +7 -5
- 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 +24 -3
- data/lib/fluent/plugin/in_monitor_agent.rb +1 -1
- data/lib/fluent/plugin/in_tail.rb +129 -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_copy.rb +18 -5
- data/lib/fluent/plugin/out_exec_filter.rb +3 -3
- data/lib/fluent/plugin/out_forward.rb +61 -28
- data/lib/fluent/plugin/out_http.rb +28 -3
- data/lib/fluent/plugin/output.rb +18 -10
- data/lib/fluent/plugin/parser_csv.rb +2 -2
- data/lib/fluent/plugin/parser_syslog.rb +2 -2
- data/lib/fluent/plugin/storage_local.rb +4 -4
- data/lib/fluent/plugin_helper/http_server/compat/server.rb +1 -1
- data/lib/fluent/plugin_helper/inject.rb +4 -2
- data/lib/fluent/plugin_helper/retry_state.rb +4 -0
- data/lib/fluent/plugin_helper/server.rb +4 -2
- data/lib/fluent/plugin_helper/socket_option.rb +2 -2
- data/lib/fluent/supervisor.rb +153 -48
- data/lib/fluent/system_config.rb +2 -1
- data/lib/fluent/time.rb +58 -1
- data/lib/fluent/version.rb +1 -1
- data/lib/fluent/winsvc.rb +22 -4
- data/templates/new_gem/fluent-plugin.gemspec.erb +3 -3
- data/templates/plugin_config_formatter/param.md-table.erb +10 -0
- 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_fluentd.rb +38 -0
- data/test/command/test_plugin_config_formatter.rb +124 -2
- data/test/config/test_configurable.rb +1 -1
- data/test/plugin/in_tail/test_position_file.rb +46 -26
- data/test/plugin/test_file_wrapper.rb +105 -0
- 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_exec.rb +1 -1
- data/test/plugin/test_in_http.rb +25 -0
- data/test/plugin/test_in_tail.rb +503 -42
- data/test/plugin/test_out_copy.rb +87 -0
- data/test/plugin/test_out_file.rb +23 -18
- data/test/plugin/test_out_forward.rb +94 -6
- data/test/plugin/test_out_http.rb +20 -1
- data/test/plugin/test_output.rb +15 -3
- data/test/plugin/test_output_as_buffered_backup.rb +2 -0
- data/test/plugin/test_parser_csv.rb +14 -0
- data/test/plugin/test_parser_syslog.rb +16 -2
- data/test/plugin/test_sd_file.rb +1 -1
- data/test/plugin_helper/service_discovery/test_manager.rb +1 -1
- data/test/plugin_helper/test_child_process.rb +5 -2
- data/test/plugin_helper/test_compat_parameters.rb +7 -2
- data/test/plugin_helper/test_http_server_helper.rb +4 -2
- data/test/plugin_helper/test_inject.rb +29 -0
- data/test/plugin_helper/test_server.rb +26 -7
- data/test/test_capability.rb +74 -0
- data/test/test_event.rb +16 -0
- data/test/test_formatter.rb +64 -10
- data/test/test_output.rb +8 -3
- data/test/test_supervisor.rb +150 -1
- data/test/test_time_parser.rb +109 -0
- metadata +87 -33
- data/.travis.yml +0 -57
- data/appveyor.yml +0 -28
@@ -173,6 +173,8 @@ class BufferedOutputBackupTest < Test::Unit::TestCase
|
|
173
173
|
waiting(5) {
|
174
174
|
target_dir = File.join(File.dirname(target_file), "*")
|
175
175
|
while Dir.glob(target_dir).size.zero?
|
176
|
+
# Avoid to lose globbed entries on Windows in busy loop
|
177
|
+
sleep 0.1 if Fluent.windows?
|
176
178
|
end
|
177
179
|
}
|
178
180
|
end
|
@@ -183,4 +183,18 @@ class CSVParserTest < ::Test::Unit::TestCase
|
|
183
183
|
# And more...
|
184
184
|
end
|
185
185
|
end
|
186
|
+
|
187
|
+
# "parser_type" config shouldn't hide Fluent::Plugin::Parser#plugin_type
|
188
|
+
# https://github.com/fluent/fluentd/issues/3296
|
189
|
+
data('normal' => :normal, 'fast' => :fast)
|
190
|
+
def test_parser_type_method(engine)
|
191
|
+
d = create_driver('keys' => '["time"]','time_key' => 'time', 'parser_type' => engine.to_s)
|
192
|
+
assert_equal(:text_per_line, d.instance.parser_type)
|
193
|
+
end
|
194
|
+
|
195
|
+
data('normal' => :normal, 'fast' => :fast)
|
196
|
+
def test_parser_engine(engine)
|
197
|
+
d = create_driver('keys' => '["time"]', 'time_key' => 'time', 'parser_engine' => engine.to_s)
|
198
|
+
assert_equal(engine, d.instance.parser_engine)
|
199
|
+
end
|
186
200
|
end
|
@@ -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
|
}
|
@@ -633,4 +633,18 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
633
633
|
end
|
634
634
|
end
|
635
635
|
end
|
636
|
+
|
637
|
+
# "parser_type" config shouldn't hide Fluent::Plugin::Parser#plugin_type
|
638
|
+
# https://github.com/fluent/fluentd/issues/3296
|
639
|
+
data('regexp' => :regexp, 'fast' => :string)
|
640
|
+
def test_parser_type_method(engine)
|
641
|
+
@parser.configure({'parser_type' => engine.to_s})
|
642
|
+
assert_equal(:text_per_line, @parser.instance.parser_type)
|
643
|
+
end
|
644
|
+
|
645
|
+
data('regexp' => :regexp, 'string' => :string)
|
646
|
+
def test_parser_engine(engine)
|
647
|
+
d = @parser.configure({'parser_engine' => engine.to_s})
|
648
|
+
assert_equal(engine, @parser.instance.parser_engine)
|
649
|
+
end
|
636
650
|
end
|
data/test/plugin/test_sd_file.rb
CHANGED
@@ -149,7 +149,7 @@ class FileServiceDiscoveryTest < ::Test::Unit::TestCase
|
|
149
149
|
assert_empty queue
|
150
150
|
end
|
151
151
|
|
152
|
-
test 'Skip if error is
|
152
|
+
test 'Skip if error is occurred' do
|
153
153
|
@sd_file.extend(TestStatEventHelperWrapper)
|
154
154
|
|
155
155
|
create_tmp_config('config.json', JSON.generate([{ port: 1233, host: '127.0.0.1' }]))
|
@@ -71,7 +71,7 @@ class TestServiceDiscoveryManager < ::Test::Unit::TestCase
|
|
71
71
|
test 'if new service added and deleted' do
|
72
72
|
sdm = Fluent::PluginHelper::ServiceDiscovery::Manager.new(log: $log)
|
73
73
|
t = TestSdPlugin.new
|
74
|
-
mock(Fluent::Plugin).new_sd(:sd_test, anything) { t }
|
74
|
+
mock(Fluent::Plugin).new_sd(:sd_test, parent: anything) { t }
|
75
75
|
sdm.configure([{ type: :sd_test, conf: config_element('service_discovery', '', {})}])
|
76
76
|
sdm.start
|
77
77
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
require_relative '../helper'
|
2
3
|
require 'fluent/plugin_helper/child_process'
|
3
4
|
require 'fluent/plugin/base'
|
@@ -269,10 +270,12 @@ class ChildProcessTest < Test::Unit::TestCase
|
|
269
270
|
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
|
270
271
|
ran = false
|
271
272
|
@d.child_process_execute(:t4, "ruby -e 'Signal.trap(:TERM, nil); while sleep 0.1; puts 1; STDOUT.flush rescue nil; end'", mode: [:read]) do |io|
|
272
|
-
m.lock
|
273
|
-
ran = true
|
274
273
|
begin
|
275
274
|
while line = io.readline
|
275
|
+
unless ran
|
276
|
+
m.lock
|
277
|
+
ran = true
|
278
|
+
end
|
276
279
|
ary << line
|
277
280
|
end
|
278
281
|
rescue
|
@@ -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
|
|
@@ -132,7 +132,9 @@ class HttpHelperTest < Test::Unit::TestCase
|
|
132
132
|
error = e
|
133
133
|
end
|
134
134
|
|
135
|
-
|
135
|
+
if response
|
136
|
+
resp = Response.new(response.status.to_s, response.body.read, response.headers)
|
137
|
+
end
|
136
138
|
end
|
137
139
|
|
138
140
|
if error
|
@@ -352,7 +354,7 @@ class HttpHelperTest < Test::Unit::TestCase
|
|
352
354
|
watcher.should_receive(:stop).once
|
353
355
|
end
|
354
356
|
|
355
|
-
stub(Fluent::PluginHelper::HttpServer::Server).new(anything) { server }
|
357
|
+
stub(Fluent::PluginHelper::HttpServer::Server).new(addr: anything, port: anything, logger: anything, default_app: anything) { server }
|
356
358
|
driver.http_server_create_http_server(:http_server_helper_test, addr: '127.0.0.1', port: PORT, logger: NULL_LOGGER) do
|
357
359
|
# nothing
|
358
360
|
end
|
@@ -187,6 +187,35 @@ class InjectHelperTest < Test::Unit::TestCase
|
|
187
187
|
|
188
188
|
record = {"key1" => "value1", "key2" => 2}
|
189
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)
|
190
219
|
end
|
191
220
|
|
192
221
|
test 'injects time as unix time into specified key' do
|
@@ -234,7 +234,13 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
234
234
|
assert_raise(ArgumentError.new("BUG: backlog is available for tcp/tls")) do
|
235
235
|
@d.__send__(m, :myserver, PORT, proto: proto, backlog: 500){|x| x }
|
236
236
|
end
|
237
|
-
|
237
|
+
end
|
238
|
+
|
239
|
+
data(
|
240
|
+
'server_create udp' => [:server_create, :udp],
|
241
|
+
)
|
242
|
+
test 'raise error if tcp/tls send_keepalive_packet option is specified for udp' do |(m, proto)|
|
243
|
+
assert_raise(ArgumentError.new("BUG: send_keepalive_packet is available for tcp/tls")) do
|
238
244
|
@d.__send__(m, :myserver, PORT, proto: proto, send_keepalive_packet: true){|x| x }
|
239
245
|
end
|
240
246
|
end
|
@@ -832,8 +838,9 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
832
838
|
chain_cert.sign(root_key, "sha256")
|
833
839
|
|
834
840
|
server_cert, server_key, _ = CertUtil.cert_option_generate_pair(create_server_options, chain_cert.subject)
|
835
|
-
|
836
|
-
server_cert.add_extension
|
841
|
+
factory = OpenSSL::X509::ExtensionFactory.new
|
842
|
+
server_cert.add_extension(factory.create_extension('basicConstraints', 'CA:FALSE'))
|
843
|
+
server_cert.add_extension(factory.create_extension('nsCertType', 'server'))
|
837
844
|
server_cert.sign(chain_key, "sha256")
|
838
845
|
|
839
846
|
# write chained cert
|
@@ -1299,7 +1306,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
1299
1306
|
|
1300
1307
|
test 'can accept all keyword arguments valid for tcp/tls server' do
|
1301
1308
|
assert_nothing_raised do
|
1302
|
-
@d.server_create_tls(:s, PORT, bind: '127.0.0.1', shared: false, resolve_name: true, linger_timeout: 10, backlog: 500, tls_options: @tls_options) do |data, conn|
|
1309
|
+
@d.server_create_tls(:s, PORT, bind: '127.0.0.1', shared: false, resolve_name: true, linger_timeout: 10, backlog: 500, tls_options: @tls_options, send_keepalive_packet: true) do |data, conn|
|
1303
1310
|
# ...
|
1304
1311
|
end
|
1305
1312
|
end
|
@@ -1494,8 +1501,13 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
1494
1501
|
test "can't connect with different TLS version" do
|
1495
1502
|
@d.server_create_tls(:s, PORT, tls_options: @tls_options) do |data, conn|
|
1496
1503
|
end
|
1504
|
+
if defined?(OpenSSL::SSL::TLS1_3_VERSION)
|
1505
|
+
version = :'TLS1_3'
|
1506
|
+
else
|
1507
|
+
version = :'TLS1_1'
|
1508
|
+
end
|
1497
1509
|
assert_raise(OpenSSL::SSL::SSLError, Errno::ECONNRESET) {
|
1498
|
-
open_tls_session('127.0.0.1', PORT, cert_path: @cert_path, version:
|
1510
|
+
open_tls_session('127.0.0.1', PORT, cert_path: @cert_path, version: version) do |sock|
|
1499
1511
|
end
|
1500
1512
|
}
|
1501
1513
|
end
|
@@ -1503,14 +1515,21 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
1503
1515
|
test "can specify multiple TLS versions by min_version/max_version" do
|
1504
1516
|
omit "min_version=/max_version= is not supported" unless Fluent::TLS::MIN_MAX_AVAILABLE
|
1505
1517
|
|
1506
|
-
|
1518
|
+
min_version = :'TLS1_2'
|
1519
|
+
if defined?(OpenSSL::SSL::TLS1_3_VERSION)
|
1520
|
+
max_version = :'TLS1_3'
|
1521
|
+
else
|
1522
|
+
max_version = :'TLS1_2'
|
1523
|
+
end
|
1524
|
+
|
1525
|
+
opts = @tls_options.merge(min_version: min_version, max_version: max_version)
|
1507
1526
|
@d.server_create_tls(:s, PORT, tls_options: opts) do |data, conn|
|
1508
1527
|
end
|
1509
1528
|
assert_raise(OpenSSL::SSL::SSLError, Errno::ECONNRESET) {
|
1510
1529
|
open_tls_session('127.0.0.1', PORT, cert_path: @cert_path, version: :'TLS1') do |sock|
|
1511
1530
|
end
|
1512
1531
|
}
|
1513
|
-
[
|
1532
|
+
[min_version, max_version].each { |ver|
|
1514
1533
|
assert_nothing_raised {
|
1515
1534
|
open_tls_session('127.0.0.1', PORT, cert_path: @cert_path, version: ver) do |sock|
|
1516
1535
|
end
|
@@ -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_event.rb
CHANGED
@@ -401,6 +401,22 @@ module EventTest
|
|
401
401
|
i += 1
|
402
402
|
}
|
403
403
|
end
|
404
|
+
|
405
|
+
# `any?` represents an Enumerable method which calls `each` internally
|
406
|
+
test 'size_after_any' do
|
407
|
+
@es.any?
|
408
|
+
|
409
|
+
assert_equal 2, @es.size
|
410
|
+
end
|
411
|
+
|
412
|
+
# `any?` represents an Enumerable method which calls `each` internally
|
413
|
+
test 'each_after_any' do
|
414
|
+
@es.any?
|
415
|
+
|
416
|
+
count = 0
|
417
|
+
@es.each { |time, record| count += 1 }
|
418
|
+
assert_equal 2, count
|
419
|
+
end
|
404
420
|
end
|
405
421
|
|
406
422
|
class CompressedMessagePackEventStreamTest < ::Test::Unit::TestCase
|
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,37 @@ 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)
|
186
|
+
end
|
187
|
+
|
188
|
+
def record_with_tab
|
189
|
+
{'message' => "awe\tsome", 'greeting' => "hello\t"}
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_format_suppresses_tab
|
193
|
+
@formatter.configure({})
|
194
|
+
formatted = @formatter.format(tag, @time, record_with_tab)
|
195
|
+
|
196
|
+
assert_equal("message:awe some\tgreeting:hello #{@newline}", formatted)
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_format_suppresses_tab_custom_replacement
|
200
|
+
@formatter.configure(
|
201
|
+
'replacement' => 'X',
|
202
|
+
)
|
203
|
+
formatted = @formatter.format(tag, @time, record_with_tab)
|
204
|
+
|
205
|
+
assert_equal("message:aweXsome\tgreeting:helloX#{@newline}", formatted)
|
206
|
+
end
|
207
|
+
|
208
|
+
def test_format_suppresses_custom_delimiter
|
209
|
+
@formatter.configure(
|
210
|
+
'delimiter' => 'w',
|
211
|
+
'label_delimiter' => '=',
|
212
|
+
)
|
213
|
+
formatted = @formatter.format(tag, @time, record)
|
214
|
+
|
215
|
+
assert_equal("message=a esomewgreeting=hello#{@newline}", formatted)
|
171
216
|
end
|
172
217
|
end
|
173
218
|
|
@@ -260,6 +305,14 @@ module FormatterTest
|
|
260
305
|
|
261
306
|
class SingleValueFormatterTest < ::Test::Unit::TestCase
|
262
307
|
include FormatterTest
|
308
|
+
def setup
|
309
|
+
@newline = if Fluent.windows?
|
310
|
+
"\r\n"
|
311
|
+
else
|
312
|
+
"\n"
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
263
316
|
|
264
317
|
def test_config_params
|
265
318
|
formatter = TextFormatter::SingleValueFormatter.new
|
@@ -271,8 +324,9 @@ module FormatterTest
|
|
271
324
|
|
272
325
|
def test_format
|
273
326
|
formatter = Fluent::Plugin.new_formatter('single_value')
|
327
|
+
formatter.configure({})
|
274
328
|
formatted = formatter.format('tag', Engine.now, {'message' => 'awesome'})
|
275
|
-
assert_equal("awesome
|
329
|
+
assert_equal("awesome#{@newline}", formatted)
|
276
330
|
end
|
277
331
|
|
278
332
|
def test_format_without_newline
|
@@ -287,7 +341,7 @@ module FormatterTest
|
|
287
341
|
formatter.configure('message_key' => 'foobar')
|
288
342
|
formatted = formatter.format('tag', Engine.now, {'foobar' => 'foo'})
|
289
343
|
|
290
|
-
assert_equal("foo
|
344
|
+
assert_equal("foo#{@newline}", formatted)
|
291
345
|
end
|
292
346
|
end
|
293
347
|
|