fluentd 0.14.17-x86-mingw32 → 1.3.1-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/.travis.yml +16 -5
- data/ADOPTERS.md +5 -0
- data/{ChangeLog → CHANGELOG.md} +495 -6
- data/CONTRIBUTING.md +5 -2
- data/GOVERNANCE.md +55 -0
- data/LICENSE +202 -0
- data/MAINTAINERS.md +7 -5
- data/README.md +17 -10
- data/bin/fluent-ca-generate +6 -0
- data/example/counter.conf +18 -0
- data/example/secondary_file.conf +3 -2
- data/fluentd.gemspec +3 -3
- data/lib/fluent/agent.rb +1 -1
- data/lib/fluent/command/binlog_reader.rb +11 -2
- data/lib/fluent/command/ca_generate.rb +181 -0
- data/lib/fluent/command/cat.rb +28 -15
- data/lib/fluent/command/debug.rb +4 -4
- data/lib/fluent/command/fluentd.rb +2 -2
- data/lib/fluent/command/plugin_config_formatter.rb +24 -2
- data/lib/fluent/command/plugin_generator.rb +26 -8
- data/lib/fluent/config/configure_proxy.rb +7 -1
- data/lib/fluent/config/dsl.rb +8 -5
- data/lib/fluent/config/element.rb +5 -0
- data/lib/fluent/config/literal_parser.rb +7 -1
- data/lib/fluent/config/types.rb +28 -2
- data/lib/fluent/config/v1_parser.rb +1 -2
- data/lib/fluent/configurable.rb +1 -0
- data/lib/fluent/counter.rb +23 -0
- data/lib/fluent/counter/base_socket.rb +46 -0
- data/lib/fluent/counter/client.rb +297 -0
- data/lib/fluent/counter/error.rb +86 -0
- data/lib/fluent/counter/mutex_hash.rb +163 -0
- data/lib/fluent/counter/server.rb +273 -0
- data/lib/fluent/counter/store.rb +205 -0
- data/lib/fluent/counter/validator.rb +145 -0
- data/lib/fluent/env.rb +1 -0
- data/lib/fluent/event_router.rb +1 -1
- data/lib/fluent/log.rb +119 -29
- data/lib/fluent/plugin/base.rb +12 -0
- data/lib/fluent/plugin/buf_file.rb +20 -16
- data/lib/fluent/plugin/buffer.rb +130 -32
- data/lib/fluent/plugin/buffer/file_chunk.rb +23 -4
- data/lib/fluent/plugin/compressable.rb +1 -1
- data/lib/fluent/plugin/filter_grep.rb +135 -21
- data/lib/fluent/plugin/filter_parser.rb +13 -2
- data/lib/fluent/plugin/filter_record_transformer.rb +16 -14
- data/lib/fluent/plugin/formatter_stdout.rb +3 -2
- data/lib/fluent/plugin/formatter_tsv.rb +5 -1
- data/lib/fluent/plugin/in_debug_agent.rb +8 -1
- data/lib/fluent/plugin/in_forward.rb +1 -1
- data/lib/fluent/plugin/in_http.rb +84 -3
- data/lib/fluent/plugin/in_monitor_agent.rb +7 -1
- data/lib/fluent/plugin/in_syslog.rb +31 -10
- data/lib/fluent/plugin/in_tail.rb +142 -53
- data/lib/fluent/plugin/in_tcp.rb +5 -6
- data/lib/fluent/plugin/in_udp.rb +6 -2
- data/lib/fluent/plugin/in_unix.rb +1 -1
- data/lib/fluent/plugin/multi_output.rb +1 -0
- data/lib/fluent/plugin/out_copy.rb +25 -2
- data/lib/fluent/plugin/out_file.rb +26 -7
- data/lib/fluent/plugin/out_forward.rb +81 -42
- data/lib/fluent/plugin/out_secondary_file.rb +2 -2
- data/lib/fluent/plugin/out_stdout.rb +0 -1
- data/lib/fluent/plugin/out_stream.rb +1 -1
- data/lib/fluent/plugin/output.rb +221 -57
- data/lib/fluent/plugin/parser_apache.rb +1 -1
- data/lib/fluent/plugin/parser_apache2.rb +5 -1
- data/lib/fluent/plugin/parser_apache_error.rb +1 -1
- data/lib/fluent/plugin/parser_json.rb +10 -3
- data/lib/fluent/plugin/parser_ltsv.rb +7 -0
- data/lib/fluent/plugin/parser_multiline.rb +2 -1
- data/lib/fluent/plugin/parser_nginx.rb +1 -1
- data/lib/fluent/plugin/parser_none.rb +1 -0
- data/lib/fluent/plugin/parser_regexp.rb +15 -14
- data/lib/fluent/plugin/parser_syslog.rb +9 -5
- data/lib/fluent/plugin_helper.rb +2 -0
- data/lib/fluent/plugin_helper/cert_option.rb +28 -9
- data/lib/fluent/plugin_helper/compat_parameters.rb +3 -1
- data/lib/fluent/plugin_helper/counter.rb +51 -0
- data/lib/fluent/plugin_helper/event_loop.rb +9 -0
- data/lib/fluent/plugin_helper/record_accessor.rb +210 -0
- data/lib/fluent/plugin_helper/retry_state.rb +15 -7
- data/lib/fluent/plugin_helper/server.rb +87 -25
- data/lib/fluent/plugin_helper/socket_option.rb +5 -2
- data/lib/fluent/plugin_helper/timer.rb +8 -7
- data/lib/fluent/root_agent.rb +18 -9
- data/lib/fluent/supervisor.rb +63 -23
- data/lib/fluent/system_config.rb +30 -2
- data/lib/fluent/test/helpers.rb +1 -1
- data/lib/fluent/time.rb +15 -7
- data/lib/fluent/timezone.rb +26 -2
- data/lib/fluent/version.rb +1 -1
- data/templates/new_gem/README.md.erb +2 -2
- data/templates/new_gem/lib/fluent/plugin/filter.rb.erb +1 -1
- data/templates/new_gem/lib/fluent/plugin/input.rb.erb +1 -1
- data/templates/new_gem/lib/fluent/plugin/output.rb.erb +1 -1
- data/templates/new_gem/lib/fluent/plugin/parser.rb.erb +4 -4
- data/test/command/test_ca_generate.rb +70 -0
- data/test/command/test_fluentd.rb +2 -2
- data/test/command/test_plugin_config_formatter.rb +8 -7
- data/test/command/test_plugin_generator.rb +65 -39
- data/test/config/test_config_parser.rb +7 -2
- data/test/config/test_configurable.rb +7 -2
- data/test/config/test_configure_proxy.rb +41 -3
- data/test/config/test_dsl.rb +10 -10
- data/test/config/test_element.rb +10 -0
- data/test/config/test_literal_parser.rb +8 -0
- data/test/config/test_plugin_configuration.rb +56 -0
- data/test/config/test_system_config.rb +19 -1
- data/test/config/test_types.rb +37 -0
- data/test/counter/test_client.rb +559 -0
- data/test/counter/test_error.rb +44 -0
- data/test/counter/test_mutex_hash.rb +179 -0
- data/test/counter/test_server.rb +589 -0
- data/test/counter/test_store.rb +258 -0
- data/test/counter/test_validator.rb +137 -0
- data/test/plugin/test_buf_file.rb +124 -0
- data/test/plugin/test_buffer.rb +3 -2
- data/test/plugin/test_filter_grep.rb +580 -2
- data/test/plugin/test_filter_parser.rb +33 -2
- data/test/plugin/test_filter_record_transformer.rb +22 -1
- data/test/plugin/test_formatter_ltsv.rb +3 -0
- data/test/plugin/test_formatter_tsv.rb +68 -0
- data/test/plugin/test_in_debug_agent.rb +21 -0
- data/test/plugin/test_in_exec.rb +3 -5
- data/test/plugin/test_in_http.rb +178 -0
- data/test/plugin/test_in_monitor_agent.rb +1 -1
- data/test/plugin/test_in_syslog.rb +64 -0
- data/test/plugin/test_in_tail.rb +116 -6
- data/test/plugin/test_in_tcp.rb +21 -0
- data/test/plugin/test_in_udp.rb +78 -0
- data/test/plugin/test_metadata.rb +89 -0
- data/test/plugin/test_out_copy.rb +31 -0
- data/test/plugin/test_out_file.rb +108 -2
- data/test/plugin/test_out_forward.rb +195 -2
- data/test/plugin/test_out_secondary_file.rb +14 -0
- data/test/plugin/test_output.rb +159 -45
- data/test/plugin/test_output_as_buffered.rb +19 -0
- data/test/plugin/test_output_as_buffered_backup.rb +307 -0
- data/test/plugin/test_output_as_buffered_retries.rb +70 -0
- data/test/plugin/test_output_as_buffered_secondary.rb +1 -1
- data/test/plugin/test_parser_apache2.rb +1 -0
- data/test/plugin/test_parser_labeled_tsv.rb +17 -0
- data/test/plugin/test_parser_nginx.rb +40 -0
- data/test/plugin/test_parser_regexp.rb +6 -7
- data/test/plugin/test_parser_syslog.rb +155 -5
- data/test/plugin_helper/test_child_process.rb +4 -4
- data/test/plugin_helper/test_compat_parameters.rb +22 -0
- data/test/plugin_helper/test_record_accessor.rb +197 -0
- data/test/plugin_helper/test_retry_state.rb +20 -0
- data/test/plugin_helper/test_server.rb +30 -2
- data/test/test_config.rb +3 -3
- data/test/test_configdsl.rb +2 -2
- data/test/test_log.rb +51 -1
- data/test/test_root_agent.rb +33 -0
- data/test/test_supervisor.rb +105 -0
- metadata +68 -8
- data/COPYING +0 -14
@@ -510,7 +510,7 @@ class ChildProcessTest < Test::Unit::TestCase
|
|
510
510
|
unless Fluent.windows?
|
511
511
|
test 'can specify subprocess name' do
|
512
512
|
io = IO.popen([["cat", "caaaaaaaaaaat"], '-'])
|
513
|
-
process_naming_enabled = (open("|ps"){|_io| _io.readlines }.select{|line| line.include?("caaaaaaaaaaat") }.size > 0)
|
513
|
+
process_naming_enabled = (open("|ps opid,cmd"){|_io| _io.readlines }.select{|line| line.include?("caaaaaaaaaaat") }.size > 0)
|
514
514
|
Process.kill(:TERM, io.pid) rescue nil
|
515
515
|
io.close rescue nil
|
516
516
|
|
@@ -527,15 +527,15 @@ class ChildProcessTest < Test::Unit::TestCase
|
|
527
527
|
m.lock
|
528
528
|
ran = true
|
529
529
|
pids << @d.child_process_id
|
530
|
-
proc_lines += open("|ps"){|_io| _io.readlines }
|
530
|
+
proc_lines += open("|ps opid,cmd"){|_io| _io.readlines }
|
531
531
|
m.unlock
|
532
532
|
readio.read
|
533
533
|
end
|
534
534
|
sleep TEST_WAIT_INTERVAL_FOR_BLOCK_RUNNING until m.locked? || ran
|
535
535
|
m.lock
|
536
536
|
pid = pids.first
|
537
|
-
#
|
538
|
-
assert{ proc_lines.select{|line| line =~ /^\s*#{pid}\s/ }.first.strip.split(/\s+/)[
|
537
|
+
# 16357 sleeeeeeeeeper -e sleep 10; puts "hello"
|
538
|
+
assert{ proc_lines.select{|line| line =~ /^\s*#{pid}\s/ }.first.strip.split(/\s+/)[1] == "sleeeeeeeeeper" }
|
539
539
|
@d.stop; @d.shutdown; @d.close; @d.terminate
|
540
540
|
end
|
541
541
|
end
|
@@ -328,4 +328,26 @@ class CompatParameterTest < Test::Unit::TestCase
|
|
328
328
|
# TODO:
|
329
329
|
end
|
330
330
|
end
|
331
|
+
|
332
|
+
sub_test_case 'parser plugins' do
|
333
|
+
test 'syslog parser parameters' do
|
334
|
+
hash = {
|
335
|
+
'format' => 'syslog',
|
336
|
+
'message_format' => 'rfc5424',
|
337
|
+
'with_priority' => 'true',
|
338
|
+
'rfc5424_time_format' => '%Y'
|
339
|
+
}
|
340
|
+
conf = config_element('ROOT', '', hash)
|
341
|
+
@i = DummyI0.new
|
342
|
+
@i.configure(conf)
|
343
|
+
@i.start
|
344
|
+
@i.after_start
|
345
|
+
|
346
|
+
parser = @i.parser
|
347
|
+
assert_kind_of(Fluent::Plugin::SyslogParser, parser)
|
348
|
+
assert_equal :rfc5424, parser.message_format
|
349
|
+
assert_equal true, parser.with_priority
|
350
|
+
assert_equal '%Y', parser.rfc5424_time_format
|
351
|
+
end
|
352
|
+
end
|
331
353
|
end
|
@@ -0,0 +1,197 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/plugin_helper/record_accessor'
|
3
|
+
require 'fluent/plugin/base'
|
4
|
+
|
5
|
+
require 'time'
|
6
|
+
|
7
|
+
class RecordAccessorHelperTest < Test::Unit::TestCase
|
8
|
+
class Dummy < Fluent::Plugin::TestBase
|
9
|
+
helpers :record_accessor
|
10
|
+
end
|
11
|
+
|
12
|
+
sub_test_case 'parse nested key expression' do
|
13
|
+
data('normal' => 'key1',
|
14
|
+
'space' => 'ke y2',
|
15
|
+
'dot key' => 'this.is.key3')
|
16
|
+
test 'parse single key' do |param|
|
17
|
+
result = Fluent::PluginHelper::RecordAccessor::Accessor.parse_parameter(param)
|
18
|
+
assert_equal param, result
|
19
|
+
end
|
20
|
+
|
21
|
+
test "nested bracket keys with dot" do
|
22
|
+
result = Fluent::PluginHelper::RecordAccessor::Accessor.parse_parameter("$['key1']['this.is.key3']")
|
23
|
+
assert_equal ['key1', 'this.is.key3'], result
|
24
|
+
end
|
25
|
+
|
26
|
+
data('dot' => '$.key1.key2[0]',
|
27
|
+
'bracket' => "$['key1']['key2'][0]",
|
28
|
+
'bracket w/ double quotes' => '$["key1"]["key2"][0]')
|
29
|
+
test "nested keys ['key1', 'key2', 0]" do |param|
|
30
|
+
result = Fluent::PluginHelper::RecordAccessor::Accessor.parse_parameter(param)
|
31
|
+
assert_equal ['key1', 'key2', 0], result
|
32
|
+
end
|
33
|
+
|
34
|
+
data('bracket' => "$['key1'][0]['ke y2']",
|
35
|
+
'bracket w/ double quotes' => '$["key1"][0]["ke y2"]')
|
36
|
+
test "nested keys ['key1', 0, 'ke y2']" do |param|
|
37
|
+
result = Fluent::PluginHelper::RecordAccessor::Accessor.parse_parameter(param)
|
38
|
+
assert_equal ['key1', 0, 'ke y2'], result
|
39
|
+
end
|
40
|
+
|
41
|
+
data('dot' => '$.[0].key1.[1].key2',
|
42
|
+
'bracket' => "$[0]['key1'][1]['key2']",
|
43
|
+
'bracket w/ double quotes' => '$[0]["key1"][1]["key2"]')
|
44
|
+
test "nested keys [0, 'key1', 1, 'key2']" do |param|
|
45
|
+
result = Fluent::PluginHelper::RecordAccessor::Accessor.parse_parameter(param)
|
46
|
+
assert_equal [0, 'key1', 1, 'key2'], result
|
47
|
+
end
|
48
|
+
|
49
|
+
data("missing ']'" => "$['key1'",
|
50
|
+
"missing array index with dot" => "$.hello[]",
|
51
|
+
"missing array index with braket" => "$[]",
|
52
|
+
"more chars" => "$.key1[0]foo",
|
53
|
+
"whitespace char included key in dot notation" => "$.key[0].ke y",
|
54
|
+
"empty keys with dot" => "$.",
|
55
|
+
"empty keys with bracket" => "$[",
|
56
|
+
"mismatched quotes1" => "$['key1']['key2\"]",
|
57
|
+
"mismatched quotes2" => '$["key1"]["key2\']')
|
58
|
+
test 'invalid syntax' do |param|
|
59
|
+
assert_raise Fluent::ConfigError do
|
60
|
+
Fluent::PluginHelper::RecordAccessor::Accessor.parse_parameter(param)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
sub_test_case 'attr_reader :keys' do
|
66
|
+
setup do
|
67
|
+
@d = Dummy.new
|
68
|
+
end
|
69
|
+
|
70
|
+
data('normal' => 'key1',
|
71
|
+
'space' => 'ke y2',
|
72
|
+
'dot key' => 'this.is.key3')
|
73
|
+
test 'access single key' do |param|
|
74
|
+
accessor = @d.record_accessor_create(param)
|
75
|
+
assert_equal param, accessor.keys
|
76
|
+
end
|
77
|
+
|
78
|
+
test "nested bracket keys with dot" do
|
79
|
+
accessor = @d.record_accessor_create("$['key1']['this.is.key3']")
|
80
|
+
assert_equal ['key1','this.is.key3'], accessor.keys
|
81
|
+
end
|
82
|
+
|
83
|
+
data('dot' => '$.key1.key2[0]',
|
84
|
+
'bracket' => "$['key1']['key2'][0]",
|
85
|
+
'bracket w/ double quotes' => '$["key1"]["key2"][0]')
|
86
|
+
test "nested keys ['key1', 'key2', 0]" do |param|
|
87
|
+
accessor = @d.record_accessor_create(param)
|
88
|
+
assert_equal ['key1', 'key2', 0], accessor.keys
|
89
|
+
end
|
90
|
+
|
91
|
+
data('bracket' => "$['key1'][0]['ke y2']",
|
92
|
+
'bracket w/ double quotes' => '$["key1"][0]["ke y2"]')
|
93
|
+
test "nested keys ['key1', 0, 'ke y2']" do |param|
|
94
|
+
accessor = @d.record_accessor_create(param)
|
95
|
+
assert_equal ['key1', 0, 'ke y2'], accessor.keys
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
sub_test_case Fluent::PluginHelper::RecordAccessor::Accessor do
|
100
|
+
setup do
|
101
|
+
@d = Dummy.new
|
102
|
+
end
|
103
|
+
|
104
|
+
data('normal' => 'key1',
|
105
|
+
'space' => 'ke y2',
|
106
|
+
'dot key' => 'this.is.key3')
|
107
|
+
test 'access single key' do |param|
|
108
|
+
r = {'key1' => 'v1', 'ke y2' => 'v2', 'this.is.key3' => 'v3'}
|
109
|
+
accessor = @d.record_accessor_create(param)
|
110
|
+
assert_equal r[param], accessor.call(r)
|
111
|
+
end
|
112
|
+
|
113
|
+
test "access single dot key using bracket style" do
|
114
|
+
r = {'key1' => 'v1', 'ke y2' => 'v2', 'this.is.key3' => 'v3'}
|
115
|
+
accessor = @d.record_accessor_create('$["this.is.key3"]')
|
116
|
+
assert_equal 'v3', accessor.call(r)
|
117
|
+
end
|
118
|
+
|
119
|
+
test "nested bracket keys with dot" do
|
120
|
+
r = {'key1' => {'this.is.key3' => 'value'}}
|
121
|
+
accessor = @d.record_accessor_create("$['key1']['this.is.key3']")
|
122
|
+
assert_equal 'value', accessor.call(r)
|
123
|
+
end
|
124
|
+
|
125
|
+
data('dot' => '$.key1.key2[0]',
|
126
|
+
'bracket' => "$['key1']['key2'][0]",
|
127
|
+
'bracket w/ double quotes' => '$["key1"]["key2"][0]')
|
128
|
+
test "nested keys ['key1', 'key2', 0]" do |param|
|
129
|
+
r = {'key1' => {'key2' => [1, 2, 3]}}
|
130
|
+
accessor = @d.record_accessor_create(param)
|
131
|
+
assert_equal 1, accessor.call(r)
|
132
|
+
end
|
133
|
+
|
134
|
+
data('bracket' => "$['key1'][0]['ke y2']",
|
135
|
+
'bracket w/ double quotes' => '$["key1"][0]["ke y2"]')
|
136
|
+
test "nested keys ['key1', 0, 'ke y2']" do |param|
|
137
|
+
r = {'key1' => [{'ke y2' => "value"}]}
|
138
|
+
accessor = @d.record_accessor_create(param)
|
139
|
+
assert_equal 'value', accessor.call(r)
|
140
|
+
end
|
141
|
+
|
142
|
+
data("missing ']'" => "$['key1'",
|
143
|
+
"missing array index with dot" => "$.hello[]",
|
144
|
+
"missing array index with braket" => "$['hello'][]",
|
145
|
+
"whitespace char included key in dot notation" => "$.key[0].ke y",
|
146
|
+
"more chars" => "$.key1[0]foo",
|
147
|
+
"empty keys with dot" => "$.",
|
148
|
+
"empty keys with bracket" => "$[",
|
149
|
+
"mismatched quotes1" => "$['key1']['key2\"]",
|
150
|
+
"mismatched quotes2" => '$["key1"]["key2\']')
|
151
|
+
test 'invalid syntax' do |param|
|
152
|
+
assert_raise Fluent::ConfigError do
|
153
|
+
@d.record_accessor_create(param)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
sub_test_case 'Fluent::PluginHelper::RecordAccessor::Accessor#delete' do
|
159
|
+
setup do
|
160
|
+
@d = Dummy.new
|
161
|
+
end
|
162
|
+
|
163
|
+
data('normal' => 'key1',
|
164
|
+
'space' => 'ke y2',
|
165
|
+
'dot key' => 'this.is.key3')
|
166
|
+
test 'delete top key' do |param|
|
167
|
+
r = {'key1' => 'v1', 'ke y2' => 'v2', 'this.is.key3' => 'v3'}
|
168
|
+
accessor = @d.record_accessor_create(param)
|
169
|
+
accessor.delete(r)
|
170
|
+
assert_not_include(r, param)
|
171
|
+
end
|
172
|
+
|
173
|
+
test "delete top key using bracket style" do
|
174
|
+
r = {'key1' => 'v1', 'ke y2' => 'v2', 'this.is.key3' => 'v3'}
|
175
|
+
accessor = @d.record_accessor_create('$["this.is.key3"]')
|
176
|
+
accessor.delete(r)
|
177
|
+
assert_not_include(r, 'this.is.key3')
|
178
|
+
end
|
179
|
+
|
180
|
+
data('bracket' => "$['key1'][0]['ke y2']",
|
181
|
+
'bracket w/ double quotes' => '$["key1"][0]["ke y2"]')
|
182
|
+
test "delete nested keys ['key1', 0, 'ke y2']" do |param|
|
183
|
+
r = {'key1' => [{'ke y2' => "value"}]}
|
184
|
+
accessor = @d.record_accessor_create(param)
|
185
|
+
accessor.delete(r)
|
186
|
+
assert_not_include(r['key1'][0], 'ke y2')
|
187
|
+
end
|
188
|
+
|
189
|
+
test "don't raise an error when unexpected record is coming" do
|
190
|
+
r = {'key1' => [{'key3' => "value"}]}
|
191
|
+
accessor = @d.record_accessor_create("$['key1']['key2']['key3']")
|
192
|
+
assert_nothing_raised do
|
193
|
+
assert_nil accessor.delete(r)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
@@ -419,4 +419,24 @@ class RetryStateHelperTest < Test::Unit::TestCase
|
|
419
419
|
assert_equal (dummy_current_time + 100), s.timeout_at
|
420
420
|
assert_equal (dummy_current_time + timeout * 0.8), s.secondary_transition_at
|
421
421
|
end
|
422
|
+
|
423
|
+
sub_test_case 'exponential backoff' do
|
424
|
+
test 'too big steps(check inf handling)' do
|
425
|
+
s = @d.retry_state_create(:t11, :exponential_backoff, 1, 300, randomize: false, forever: true, backoff_base: 2)
|
426
|
+
dummy_current_time = s.start
|
427
|
+
override_current_time(s, dummy_current_time)
|
428
|
+
|
429
|
+
i = 1
|
430
|
+
while i < 1027
|
431
|
+
if i >= 1025
|
432
|
+
# With this setting, 1025+ number causes inf in `calc_interval`, so 1024 value is used for next_time
|
433
|
+
assert_nothing_raised(FloatDomainError) { s.step }
|
434
|
+
assert_equal (dummy_current_time + (2 ** (1024 - 1))), s.next_time
|
435
|
+
else
|
436
|
+
s.step
|
437
|
+
end
|
438
|
+
i += 1
|
439
|
+
end
|
440
|
+
end
|
441
|
+
end
|
422
442
|
end
|
@@ -776,6 +776,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
776
776
|
def create_server_pair_signed_by_self(cert_path, private_key_path, passphrase)
|
777
777
|
cert, key, _ = CertUtil.cert_option_generate_server_pair_self_signed(create_server_options)
|
778
778
|
write_cert_and_key(cert_path, cert, private_key_path, key, passphrase)
|
779
|
+
return cert
|
779
780
|
end
|
780
781
|
|
781
782
|
def create_ca_pair_signed_by_self(cert_path, private_key_path, passphrase)
|
@@ -786,6 +787,7 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
786
787
|
def create_server_pair_signed_by_ca(ca_cert_path, ca_key_path, ca_key_passphrase, cert_path, private_key_path, passphrase)
|
787
788
|
cert, key, _ = CertUtil.cert_option_generate_server_pair_by_ca(ca_cert_path, ca_key_path, ca_key_passphrase, create_server_options)
|
788
789
|
write_cert_and_key(cert_path, cert, private_key_path, key, passphrase)
|
790
|
+
return cert
|
789
791
|
end
|
790
792
|
|
791
793
|
def create_server_pair_chained_with_root_ca(ca_cert_path, ca_key_path, ca_key_passphrase, cert_path, private_key_path, passphrase)
|
@@ -842,6 +844,20 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
842
844
|
sock.close rescue nil
|
843
845
|
end
|
844
846
|
|
847
|
+
def assert_certificate(cert, expected_extensions)
|
848
|
+
get_extension = lambda do |oid|
|
849
|
+
cert.extensions.detect { |e| e.oid == oid }
|
850
|
+
end
|
851
|
+
|
852
|
+
assert_true cert.serial > 1
|
853
|
+
assert_equal 2, cert.version
|
854
|
+
|
855
|
+
expected_extensions.each do |ext|
|
856
|
+
expected_oid, expected_value = ext
|
857
|
+
assert_equal expected_value, get_extension.call(expected_oid).value
|
858
|
+
end
|
859
|
+
end
|
860
|
+
|
845
861
|
sub_test_case '#server_create_tls with various certificate options' do
|
846
862
|
setup do
|
847
863
|
@d = Dummy.new # to get plugin not configured/started yet
|
@@ -896,7 +912,12 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
896
912
|
test 'load self-signed cert/key pair (files), verified from clients using cert files' do |private_key_passphrase|
|
897
913
|
cert_path = File.join(@server_cert_dir, "cert.pem")
|
898
914
|
private_key_path = File.join(@certs_dir, "server.key.pem")
|
899
|
-
create_server_pair_signed_by_self(cert_path, private_key_path, private_key_passphrase)
|
915
|
+
cert = create_server_pair_signed_by_self(cert_path, private_key_path, private_key_passphrase)
|
916
|
+
|
917
|
+
assert_certificate(cert,[
|
918
|
+
['basicConstraints', 'CA:FALSE'],
|
919
|
+
['nsCertType', 'SSL Server']
|
920
|
+
])
|
900
921
|
|
901
922
|
tls_options = {
|
902
923
|
protocol: :tls,
|
@@ -963,7 +984,14 @@ class ServerPluginHelperTest < Test::Unit::TestCase
|
|
963
984
|
|
964
985
|
cert_path = File.join(@server_cert_dir, "cert.pem")
|
965
986
|
private_key_path = File.join(@certs_dir, "server.key.pem")
|
966
|
-
create_server_pair_signed_by_ca(ca_cert_path, ca_key_path, ca_key_passphrase, cert_path, private_key_path, private_key_passphrase)
|
987
|
+
cert = create_server_pair_signed_by_ca(ca_cert_path, ca_key_path, ca_key_passphrase, cert_path, private_key_path, private_key_passphrase)
|
988
|
+
|
989
|
+
assert_certificate(cert,[
|
990
|
+
['basicConstraints', 'CA:FALSE'],
|
991
|
+
['nsCertType', 'SSL Server'],
|
992
|
+
['keyUsage', 'Digital Signature, Key Encipherment'],
|
993
|
+
['extendedKeyUsage', 'TLS Web Server Authentication']
|
994
|
+
])
|
967
995
|
|
968
996
|
tls_options = {
|
969
997
|
protocol: :tls,
|
data/test/test_config.rb
CHANGED
@@ -53,7 +53,7 @@ class ConfigTest < Test::Unit::TestCase
|
|
53
53
|
</elem2>
|
54
54
|
]
|
55
55
|
write_config "#{TMP_DIR}/dir/config_test_9.conf", %[
|
56
|
-
k9
|
56
|
+
k9 embedded
|
57
57
|
<elem3 name>
|
58
58
|
nested nested_value
|
59
59
|
include hoge
|
@@ -98,7 +98,7 @@ class ConfigTest < Test::Unit::TestCase
|
|
98
98
|
elem2 = c.elements.find { |e| e.name == 'elem2' }
|
99
99
|
assert_not_nil elem2
|
100
100
|
assert_equal 'name', elem2.arg
|
101
|
-
assert_equal '
|
101
|
+
assert_equal 'embedded', elem2['k9']
|
102
102
|
assert !elem2.has_key?('include')
|
103
103
|
|
104
104
|
elem3 = elem2.elements.find { |e| e.name == 'elem3' }
|
@@ -145,7 +145,7 @@ class ConfigTest < Test::Unit::TestCase
|
|
145
145
|
not_fetched = []; rule_conf.check_not_fetched {|key, e| not_fetched << key }
|
146
146
|
assert_equal %w[pattern replace], not_fetched
|
147
147
|
|
148
|
-
#
|
148
|
+
# repeatedly accessing should not grow memory usage
|
149
149
|
before_size = match_conf.unused.size
|
150
150
|
10.times { match_conf['type'] }
|
151
151
|
assert_equal before_size, match_conf.unused.size
|
data/test/test_configdsl.rb
CHANGED
@@ -65,13 +65,13 @@ match('aa')
|
|
65
65
|
e0 = root.elements[0]
|
66
66
|
assert_equal 'source', e0.name
|
67
67
|
assert_equal '', e0.arg
|
68
|
-
assert_equal 'forward', e0['type']
|
68
|
+
assert_equal 'forward', e0['@type']
|
69
69
|
assert_equal '24224', e0['port']
|
70
70
|
|
71
71
|
e1 = root.elements[1]
|
72
72
|
assert_equal 'match', e1.name
|
73
73
|
assert_equal 'test.**', e1.arg
|
74
|
-
assert_equal 'forward', e1['type']
|
74
|
+
assert_equal 'forward', e1['@type']
|
75
75
|
assert_equal '1s', e1['flush_interval']
|
76
76
|
assert_equal 2, e1.elements.size
|
77
77
|
e1s0 = e1.elements[0]
|
data/test/test_log.rb
CHANGED
@@ -379,6 +379,56 @@ class LogTest < Test::Unit::TestCase
|
|
379
379
|
assert_equal(Fluent::Log::LEVEL_TRACE, log2.level)
|
380
380
|
end
|
381
381
|
|
382
|
+
def test_format_json
|
383
|
+
logdev = @log_device
|
384
|
+
logger = ServerEngine::DaemonLogger.new(logdev)
|
385
|
+
log = Fluent::Log.new(logger)
|
386
|
+
log.format = :json
|
387
|
+
log.level = Fluent::Log::LEVEL_TRACE
|
388
|
+
log.trace "trace log"
|
389
|
+
log.debug "debug log"
|
390
|
+
log.info "info log"
|
391
|
+
log.warn "warn log"
|
392
|
+
log.error "error log"
|
393
|
+
log.fatal "fatal log"
|
394
|
+
expected = [
|
395
|
+
"#{@timestamp_str} [trace]: trace log\n",
|
396
|
+
"#{@timestamp_str} [debug]: debug log\n",
|
397
|
+
"#{@timestamp_str} [info]: info log\n",
|
398
|
+
"#{@timestamp_str} [warn]: warn log\n",
|
399
|
+
"#{@timestamp_str} [error]: error log\n",
|
400
|
+
"#{@timestamp_str} [fatal]: fatal log\n"
|
401
|
+
]
|
402
|
+
assert_equal(expected, log.out.logs.map { |l|
|
403
|
+
r = JSON.parse(l)
|
404
|
+
"#{r['time']} [#{r['level']}]: #{r['message']}\n"
|
405
|
+
})
|
406
|
+
end
|
407
|
+
|
408
|
+
def test_time_format
|
409
|
+
logdev = @log_device
|
410
|
+
logger = ServerEngine::DaemonLogger.new(logdev)
|
411
|
+
log = Fluent::Log.new(logger)
|
412
|
+
log.time_format = "%Y"
|
413
|
+
log.level = Fluent::Log::LEVEL_TRACE
|
414
|
+
log.trace "trace log"
|
415
|
+
log.debug "debug log"
|
416
|
+
log.info "info log"
|
417
|
+
log.warn "warn log"
|
418
|
+
log.error "error log"
|
419
|
+
log.fatal "fatal log"
|
420
|
+
timestamp_str = @timestamp.strftime("%Y")
|
421
|
+
expected = [
|
422
|
+
"#{timestamp_str} [trace]: trace log\n",
|
423
|
+
"#{timestamp_str} [debug]: debug log\n",
|
424
|
+
"#{timestamp_str} [info]: info log\n",
|
425
|
+
"#{timestamp_str} [warn]: warn log\n",
|
426
|
+
"#{timestamp_str} [error]: error log\n",
|
427
|
+
"#{timestamp_str} [fatal]: fatal log\n"
|
428
|
+
]
|
429
|
+
assert_equal(expected, log.out.logs)
|
430
|
+
end
|
431
|
+
|
382
432
|
def test_disable_events
|
383
433
|
dl_opts = {}
|
384
434
|
dl_opts[:log_level] = ServerEngine::DaemonLogger::TRACE
|
@@ -443,7 +493,7 @@ class LogTest < Test::Unit::TestCase
|
|
443
493
|
end
|
444
494
|
end
|
445
495
|
|
446
|
-
def
|
496
|
+
def test_log_rotates_specified_size_with_logdevio
|
447
497
|
with_timezone('utc') do
|
448
498
|
rotate_age = 2
|
449
499
|
rotate_size = 100
|