fluentd 1.11.5-x64-mingw32 → 1.12.4-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.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 +158 -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 +6 -4
- 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 +2 -2
- data/lib/fluent/plugin/formatter_csv.rb +1 -1
- data/lib/fluent/plugin/formatter_hash.rb +1 -1
- data/lib/fluent/plugin/formatter_ltsv.rb +5 -5
- data/lib/fluent/plugin/formatter_out_file.rb +3 -3
- data/lib/fluent/plugin/formatter_single_value.rb +2 -2
- data/lib/fluent/plugin/formatter_tsv.rb +2 -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 +53 -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 +9 -2
- 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 -47
- 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_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 +100 -26
- data/test/plugin/test_file_wrapper.rb +105 -0
- 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_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_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 +30 -0
- data/test/test_output.rb +2 -2
- data/test/test_supervisor.rb +133 -10
- data/test/test_time_parser.rb +109 -0
- metadata +85 -31
- data/.travis.yml +0 -57
- data/appveyor.yml +0 -28
@@ -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
@@ -184,6 +184,36 @@ module FormatterTest
|
|
184
184
|
|
185
185
|
assert_equal("message=awesome,greeting=hello#{@newline}", formatted)
|
186
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)
|
216
|
+
end
|
187
217
|
end
|
188
218
|
|
189
219
|
class CsvFormatterTest < ::Test::Unit::TestCase
|
data/test/test_output.rb
CHANGED
@@ -117,7 +117,7 @@ module FluentOutputTest
|
|
117
117
|
end
|
118
118
|
|
119
119
|
mock(d.instance.log).warn("Use different plugin for secondary. Check the plugin works with primary like secondary_file",
|
120
|
-
|
120
|
+
primary: d.instance.class.to_s, secondary: "Fluent::Plugin::Test2Output")
|
121
121
|
d.configure(CONFIG + %[
|
122
122
|
<secondary>
|
123
123
|
type test2
|
@@ -133,7 +133,7 @@ module FluentOutputTest
|
|
133
133
|
d = Fluent::Test::BufferedOutputTestDriver.new(Fluent::ObjectBufferedOutput)
|
134
134
|
|
135
135
|
mock(d.instance.log).warn("Use different plugin for secondary. Check the plugin works with primary like secondary_file",
|
136
|
-
|
136
|
+
primary: d.instance.class.to_s, secondary: "Fluent::Plugin::Test2Output").never
|
137
137
|
d.configure(CONFIG + %[
|
138
138
|
<secondary>
|
139
139
|
type test2
|
data/test/test_supervisor.rb
CHANGED
@@ -111,6 +111,32 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
111
111
|
$log.out.reset if $log && $log.out && $log.out.respond_to?(:reset)
|
112
112
|
end
|
113
113
|
|
114
|
+
def test_main_process_command_handlers
|
115
|
+
omit "Only for Windows, alternative to UNIX signals" unless Fluent.windows?
|
116
|
+
|
117
|
+
create_info_dummy_logger
|
118
|
+
|
119
|
+
opts = Fluent::Supervisor.default_options
|
120
|
+
sv = Fluent::Supervisor.new(opts)
|
121
|
+
r, w = IO.pipe
|
122
|
+
$stdin = r
|
123
|
+
sv.send(:install_main_process_signal_handlers)
|
124
|
+
|
125
|
+
begin
|
126
|
+
w.write("GRACEFUL_RESTART\n")
|
127
|
+
w.flush
|
128
|
+
ensure
|
129
|
+
$stdin = STDIN
|
130
|
+
end
|
131
|
+
|
132
|
+
sleep 1
|
133
|
+
|
134
|
+
info_msg = '[info]: force flushing buffered events' + "\n"
|
135
|
+
assert{ $log.out.logs.first.end_with?(info_msg) }
|
136
|
+
ensure
|
137
|
+
$log.out.reset if $log && $log.out && $log.out.respond_to?(:reset)
|
138
|
+
end
|
139
|
+
|
114
140
|
def test_supervisor_signal_handler
|
115
141
|
omit "Windows cannot handle signals" if Fluent.windows?
|
116
142
|
|
@@ -137,21 +163,53 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
137
163
|
|
138
164
|
server = DummyServer.new
|
139
165
|
def server.config
|
140
|
-
{:signame => "TestFluentdEvent"
|
166
|
+
{:signame => "TestFluentdEvent"}
|
141
167
|
end
|
142
168
|
|
143
169
|
mock(server).stop(true)
|
144
170
|
stub(Process).kill.times(0)
|
145
171
|
|
146
|
-
server.before_run
|
147
172
|
server.install_windows_event_handler
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
173
|
+
begin
|
174
|
+
sleep 0.1 # Wait for starting windows event thread
|
175
|
+
event = Win32::Event.open("TestFluentdEvent")
|
176
|
+
event.set
|
177
|
+
event.close
|
178
|
+
ensure
|
179
|
+
server.stop_windows_event_thread
|
180
|
+
end
|
181
|
+
|
182
|
+
debug_msg = '[debug]: Got Win32 event "TestFluentdEvent"'
|
183
|
+
logs = $log.out.logs
|
184
|
+
assert{ logs.any?{|log| log.include?(debug_msg) } }
|
185
|
+
ensure
|
186
|
+
$log.out.reset if $log && $log.out && $log.out.respond_to?(:reset)
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_supervisor_event_handler
|
190
|
+
omit "Only for Windows, alternative to UNIX signals" unless Fluent.windows?
|
191
|
+
|
192
|
+
create_debug_dummy_logger
|
193
|
+
|
194
|
+
server = DummyServer.new
|
195
|
+
def server.config
|
196
|
+
{:signame => "TestFluentdEvent"}
|
197
|
+
end
|
198
|
+
server.install_windows_event_handler
|
199
|
+
begin
|
200
|
+
sleep 0.1 # Wait for starting windows event thread
|
201
|
+
event = Win32::Event.open("TestFluentdEvent_USR1")
|
202
|
+
event.set
|
203
|
+
event.close
|
204
|
+
ensure
|
205
|
+
server.stop_windows_event_thread
|
206
|
+
end
|
207
|
+
|
208
|
+
debug_msg = '[debug]: Got Win32 event "TestFluentdEvent_USR1"'
|
209
|
+
logs = $log.out.logs
|
210
|
+
assert{ logs.any?{|log| log.include?(debug_msg) } }
|
211
|
+
ensure
|
212
|
+
$log.out.reset if $log && $log.out && $log.out.respond_to?(:reset)
|
155
213
|
end
|
156
214
|
|
157
215
|
def test_rpc_server
|
@@ -176,7 +234,7 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
176
234
|
server.run_rpc_server
|
177
235
|
|
178
236
|
sv.send(:install_main_process_signal_handlers)
|
179
|
-
Net::HTTP.get
|
237
|
+
response = Net::HTTP.get(URI.parse('http://127.0.0.1:24447/api/plugins.flushBuffers'))
|
180
238
|
info_msg = '[info]: force flushing buffered events' + "\n"
|
181
239
|
|
182
240
|
server.stop_rpc_server
|
@@ -185,11 +243,45 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
185
243
|
# This test will be passed in such environment.
|
186
244
|
pend unless $log.out.logs.first
|
187
245
|
|
246
|
+
assert_equal('{"ok":true}', response)
|
188
247
|
assert{ $log.out.logs.first.end_with?(info_msg) }
|
189
248
|
ensure
|
190
249
|
$log.out.reset if $log.out.is_a?(Fluent::Test::DummyLogDevice)
|
191
250
|
end
|
192
251
|
|
252
|
+
def test_rpc_server_windows
|
253
|
+
omit "Only for windows platform" unless Fluent.windows?
|
254
|
+
|
255
|
+
create_info_dummy_logger
|
256
|
+
|
257
|
+
opts = Fluent::Supervisor.default_options
|
258
|
+
sv = Fluent::Supervisor.new(opts)
|
259
|
+
conf_data = <<-EOC
|
260
|
+
<system>
|
261
|
+
rpc_endpoint 0.0.0.0:24447
|
262
|
+
</system>
|
263
|
+
EOC
|
264
|
+
conf = Fluent::Config.parse(conf_data, "(test)", "(test_dir)", true)
|
265
|
+
sys_conf = sv.__send__(:build_system_config, conf)
|
266
|
+
|
267
|
+
server = DummyServer.new
|
268
|
+
def server.config
|
269
|
+
{
|
270
|
+
:signame => "TestFluentdEvent",
|
271
|
+
:worker_pid => 5963,
|
272
|
+
}
|
273
|
+
end
|
274
|
+
server.rpc_endpoint = sys_conf.rpc_endpoint
|
275
|
+
|
276
|
+
server.run_rpc_server
|
277
|
+
|
278
|
+
mock(server).restart(true) { nil }
|
279
|
+
response = Net::HTTP.get(URI.parse('http://127.0.0.1:24447/api/plugins.flushBuffers'))
|
280
|
+
|
281
|
+
server.stop_rpc_server
|
282
|
+
assert_equal('{"ok":true}', response)
|
283
|
+
end
|
284
|
+
|
193
285
|
def test_load_config
|
194
286
|
tmp_dir = "#{TMP_DIR}/dir/test_load_config.conf"
|
195
287
|
conf_info_str = %[
|
@@ -425,6 +517,37 @@ class SupervisorTest < ::Test::Unit::TestCase
|
|
425
517
|
assert_equal Fluent::Log::LEVEL_ERROR, $log.level
|
426
518
|
end
|
427
519
|
|
520
|
+
def test_enable_shared_socket
|
521
|
+
server = DummyServer.new
|
522
|
+
begin
|
523
|
+
ENV.delete('SERVERENGINE_SOCKETMANAGER_PATH')
|
524
|
+
server.before_run
|
525
|
+
sleep 0.1 if Fluent.windows? # Wait for starting windows event thread
|
526
|
+
assert_not_nil(ENV['SERVERENGINE_SOCKETMANAGER_PATH'])
|
527
|
+
ensure
|
528
|
+
server.after_run
|
529
|
+
ENV.delete('SERVERENGINE_SOCKETMANAGER_PATH')
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
533
|
+
def test_disable_shared_socket
|
534
|
+
server = DummyServer.new
|
535
|
+
def server.config
|
536
|
+
{
|
537
|
+
:disable_shared_socket => true,
|
538
|
+
}
|
539
|
+
end
|
540
|
+
begin
|
541
|
+
ENV.delete('SERVERENGINE_SOCKETMANAGER_PATH')
|
542
|
+
server.before_run
|
543
|
+
sleep 0.1 if Fluent.windows? # Wait for starting windows event thread
|
544
|
+
assert_nil(ENV['SERVERENGINE_SOCKETMANAGER_PATH'])
|
545
|
+
ensure
|
546
|
+
server.after_run
|
547
|
+
ENV.delete('SERVERENGINE_SOCKETMANAGER_PATH')
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
428
551
|
def create_debug_dummy_logger
|
429
552
|
dl_opts = {}
|
430
553
|
dl_opts[:log_level] = ServerEngine::DaemonLogger::DEBUG
|