fluentd 0.14.5-x86-mingw32 → 0.14.7-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/ChangeLog +55 -0
- data/bin/fluent-binlog-reader +7 -0
- data/example/in_dummy_with_compression.conf +23 -0
- data/lib/fluent/agent.rb +8 -12
- data/lib/fluent/command/binlog_reader.rb +234 -0
- data/lib/fluent/command/fluentd.rb +17 -1
- data/lib/fluent/compat/file_util.rb +1 -1
- data/lib/fluent/compat/output.rb +5 -1
- data/lib/fluent/config/configure_proxy.rb +18 -3
- data/lib/fluent/config/element.rb +1 -1
- data/lib/fluent/config/section.rb +1 -1
- data/lib/fluent/config/v1_parser.rb +1 -1
- data/lib/fluent/env.rb +1 -0
- data/lib/fluent/event.rb +49 -2
- data/lib/fluent/event_router.rb +6 -2
- data/lib/fluent/label.rb +8 -0
- data/lib/fluent/log.rb +30 -1
- data/lib/fluent/plugin.rb +1 -1
- data/lib/fluent/plugin/base.rb +3 -0
- data/lib/fluent/plugin/buf_file.rb +2 -2
- data/lib/fluent/plugin/buf_memory.rb +1 -1
- data/lib/fluent/plugin/buffer.rb +12 -2
- data/lib/fluent/plugin/buffer/chunk.rb +68 -7
- data/lib/fluent/plugin/buffer/file_chunk.rb +4 -4
- data/lib/fluent/plugin/buffer/memory_chunk.rb +4 -4
- data/lib/fluent/plugin/compressable.rb +91 -0
- data/lib/fluent/plugin/filter_grep.rb +4 -4
- data/lib/fluent/plugin/formatter.rb +2 -2
- data/lib/fluent/plugin/formatter_json.rb +2 -1
- data/lib/fluent/plugin/formatter_out_file.rb +3 -30
- data/lib/fluent/plugin/in_forward.rb +6 -5
- data/lib/fluent/plugin/in_monitor_agent.rb +7 -21
- data/lib/fluent/plugin/in_syslog.rb +1 -1
- data/lib/fluent/plugin/in_tail.rb +11 -2
- data/lib/fluent/plugin/multi_output.rb +63 -3
- data/lib/fluent/plugin/out_exec.rb +1 -1
- data/lib/fluent/plugin/out_file.rb +5 -1
- data/lib/fluent/plugin/out_forward.rb +17 -5
- data/lib/fluent/plugin/out_stdout.rb +2 -1
- data/lib/fluent/plugin/output.rb +205 -19
- data/lib/fluent/plugin/parser.rb +5 -49
- data/lib/fluent/plugin/parser_apache2.rb +1 -1
- data/lib/fluent/plugin/parser_json.rb +4 -4
- data/lib/fluent/plugin/parser_multiline.rb +5 -5
- data/lib/fluent/plugin/parser_regexp.rb +1 -2
- data/lib/fluent/plugin/parser_syslog.rb +2 -2
- data/lib/fluent/plugin/storage_local.rb +2 -1
- data/lib/fluent/plugin_helper.rb +1 -0
- data/lib/fluent/plugin_helper/compat_parameters.rb +39 -21
- data/lib/fluent/plugin_helper/extract.rb +92 -0
- data/lib/fluent/plugin_helper/inject.rb +10 -12
- data/lib/fluent/plugin_helper/thread.rb +23 -3
- data/lib/fluent/registry.rb +1 -1
- data/lib/fluent/root_agent.rb +2 -1
- data/lib/fluent/supervisor.rb +28 -8
- data/lib/fluent/test/base.rb +0 -7
- data/lib/fluent/test/driver/base.rb +1 -0
- data/lib/fluent/test/driver/output.rb +3 -0
- data/lib/fluent/test/helpers.rb +18 -0
- data/lib/fluent/test/input_test.rb +4 -2
- data/lib/fluent/test/log.rb +3 -1
- data/lib/fluent/time.rb +232 -1
- data/lib/fluent/timezone.rb +1 -1
- data/lib/fluent/version.rb +1 -1
- data/test/command/test_binlog_reader.rb +351 -0
- data/test/config/test_config_parser.rb +6 -0
- data/test/config/test_configurable.rb +47 -1
- data/test/helper.rb +0 -1
- data/test/plugin/test_buffer.rb +22 -2
- data/test/plugin/test_buffer_chunk.rb +34 -4
- data/test/plugin/test_buffer_file_chunk.rb +73 -0
- data/test/plugin/test_buffer_memory_chunk.rb +73 -0
- data/test/plugin/test_compressable.rb +81 -0
- data/test/plugin/test_formatter_json.rb +14 -1
- data/test/plugin/test_in_forward.rb +67 -3
- data/test/plugin/test_in_monitor_agent.rb +17 -1
- data/test/plugin/test_in_tail.rb +8 -8
- data/test/plugin/test_out_file.rb +0 -8
- data/test/plugin/test_out_forward.rb +85 -0
- data/test/plugin/test_out_secondary_file.rb +20 -12
- data/test/plugin/test_out_stdout.rb +11 -10
- data/test/plugin/test_output.rb +234 -0
- data/test/plugin/test_output_as_buffered.rb +223 -0
- data/test/plugin/test_output_as_buffered_compress.rb +165 -0
- data/test/plugin/test_parser_json.rb +8 -0
- data/test/plugin/test_parser_regexp.rb +1 -1
- data/test/plugin_helper/test_child_process.rb +2 -2
- data/test/plugin_helper/test_extract.rb +195 -0
- data/test/plugin_helper/test_inject.rb +0 -7
- data/test/scripts/fluent/plugin/formatter1/formatter_test1.rb +7 -0
- data/test/scripts/fluent/plugin/formatter2/formatter_test2.rb +7 -0
- data/test/test_event.rb +186 -0
- data/test/test_event_router.rb +1 -1
- data/test/test_formatter.rb +0 -7
- data/test/test_log.rb +121 -0
- data/test/test_plugin_classes.rb +62 -0
- data/test/test_root_agent.rb +125 -0
- data/test/test_supervisor.rb +25 -2
- data/test/test_time_formatter.rb +103 -7
- data/test/test_time_parser.rb +211 -0
- metadata +22 -4
- data/test/plugin/test_parser_time.rb +0 -46
data/lib/fluent/timezone.rb
CHANGED
data/lib/fluent/version.rb
CHANGED
@@ -0,0 +1,351 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
|
3
|
+
require 'yajl'
|
4
|
+
require 'flexmock/test_unit'
|
5
|
+
|
6
|
+
require 'fluent/command/binlog_reader'
|
7
|
+
require 'fluent/event'
|
8
|
+
|
9
|
+
class TestFluentBinlogReader < ::Test::Unit::TestCase
|
10
|
+
module ::BinlogReaderCommand
|
11
|
+
class Dummy < Base
|
12
|
+
def call; end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def suppress_stdout
|
17
|
+
out = StringIO.new
|
18
|
+
$stdout = out
|
19
|
+
yield
|
20
|
+
ensure
|
21
|
+
$stdout = STDOUT
|
22
|
+
end
|
23
|
+
|
24
|
+
sub_test_case 'call' do
|
25
|
+
data(
|
26
|
+
empty: [],
|
27
|
+
invalid: %w(invalid packed.log),
|
28
|
+
)
|
29
|
+
test 'should fail when invalid command' do |argv|
|
30
|
+
fu = FluentBinlogReader.new(argv)
|
31
|
+
|
32
|
+
assert_raise(SystemExit) do
|
33
|
+
suppress_stdout { fu.call }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
data(
|
38
|
+
cat: %w(cat packed.log),
|
39
|
+
head: %w(head packed.log),
|
40
|
+
formats: %w(formats packed.log)
|
41
|
+
)
|
42
|
+
test 'should succeed when valid command' do |argv|
|
43
|
+
fu = FluentBinlogReader.new(argv)
|
44
|
+
|
45
|
+
flexstub(::BinlogReaderCommand) do |command|
|
46
|
+
command.should_receive(:const_get).once.and_return(::BinlogReaderCommand::Dummy)
|
47
|
+
assert_nothing_raised do
|
48
|
+
fu.call
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class TestBaseCommand < ::Test::Unit::TestCase
|
56
|
+
TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/../tmp/command/binlog_reader#{ENV['TEST_ENV_NUMBER']}")
|
57
|
+
|
58
|
+
def create_message_packed_file(path, times = [event_time], records = [{ 'message' => 'dummy' }])
|
59
|
+
es = Fluent::MultiEventStream.new(times, records)
|
60
|
+
v = es.to_msgpack_stream
|
61
|
+
File.open("#{TMP_DIR}/#{path}", 'w') do |f|
|
62
|
+
f.print(v)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def setup
|
67
|
+
FileUtils.rm_rf(TMP_DIR)
|
68
|
+
FileUtils.mkdir_p(TMP_DIR)
|
69
|
+
end
|
70
|
+
|
71
|
+
def timezone(timezone = 'UTC')
|
72
|
+
old = ENV['TZ']
|
73
|
+
ENV['TZ'] = timezone
|
74
|
+
yield
|
75
|
+
ensure
|
76
|
+
ENV['TZ'] = old
|
77
|
+
end
|
78
|
+
|
79
|
+
def capture_stdout
|
80
|
+
out = StringIO.new
|
81
|
+
$stdout = out
|
82
|
+
yield
|
83
|
+
out.string.force_encoding('utf-8')
|
84
|
+
ensure
|
85
|
+
$stdout = STDOUT
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
class TestHead < TestBaseCommand
|
90
|
+
sub_test_case 'initialize' do
|
91
|
+
data(
|
92
|
+
'file is not passed' => %w(),
|
93
|
+
'file is not found' => %w(invalid_path.log)
|
94
|
+
)
|
95
|
+
test 'should fail if file is invalid' do |argv|
|
96
|
+
assert_raise(SystemExit) do
|
97
|
+
capture_stdout { BinlogReaderCommand::Head.new(argv) }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
test 'should succeed if a file is valid' do
|
102
|
+
file_name = 'packed.log'
|
103
|
+
argv = ["#{TMP_DIR}/#{file_name}"]
|
104
|
+
create_message_packed_file(file_name)
|
105
|
+
|
106
|
+
assert_nothing_raised do
|
107
|
+
BinlogReaderCommand::Head.new(argv)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
test 'should fail when config_params format is invalid' do
|
112
|
+
file_name = 'packed.log'
|
113
|
+
argv = ["#{TMP_DIR}/#{file_name}", '--format=csv', '-e', 'only_key']
|
114
|
+
create_message_packed_file(file_name)
|
115
|
+
|
116
|
+
assert_raise(SystemExit) do
|
117
|
+
capture_stdout { BinlogReaderCommand::Head.new(argv) }
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
test 'should succeed if config_params format is valid' do
|
122
|
+
file_name = 'packed.log'
|
123
|
+
argv = ["#{TMP_DIR}/#{file_name}", '--format=csv', '-e', 'fields=message']
|
124
|
+
create_message_packed_file(file_name)
|
125
|
+
|
126
|
+
assert_nothing_raised do
|
127
|
+
capture_stdout { BinlogReaderCommand::Head.new(argv) }
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
sub_test_case 'call' do
|
133
|
+
setup do
|
134
|
+
@file_name = 'packed.log'
|
135
|
+
@t = '2011-01-02 13:14:15 UTC'
|
136
|
+
@record = { 'message' => 'dummy' }
|
137
|
+
end
|
138
|
+
|
139
|
+
test 'should output the beginning of the file with default format (out_file)' do
|
140
|
+
argv = ["#{TMP_DIR}/#{@file_name}"]
|
141
|
+
|
142
|
+
timezone do
|
143
|
+
create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
|
144
|
+
head = BinlogReaderCommand::Head.new(argv)
|
145
|
+
out = capture_stdout { head.call }
|
146
|
+
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}\n" * 5, out
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
test 'should set the number of lines to display' do
|
151
|
+
argv = ["#{TMP_DIR}/#{@file_name}", '-n', '1']
|
152
|
+
|
153
|
+
timezone do
|
154
|
+
create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
|
155
|
+
head = BinlogReaderCommand::Head.new(argv)
|
156
|
+
out = capture_stdout { head.call }
|
157
|
+
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}\n", out
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
test 'should fail when the number of lines is invalid' do
|
162
|
+
argv = ["#{TMP_DIR}/#{@file_name}", '-n', '0']
|
163
|
+
|
164
|
+
create_message_packed_file(@file_name)
|
165
|
+
assert_raise(SystemExit) do
|
166
|
+
capture_stdout { BinlogReaderCommand::Head.new(argv) }
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
test 'should output content of a file with json format' do
|
171
|
+
argv = ["#{TMP_DIR}/#{@file_name}", '--format=json']
|
172
|
+
|
173
|
+
timezone do
|
174
|
+
create_message_packed_file(@file_name, [event_time(@t).to_i], [@record])
|
175
|
+
head = BinlogReaderCommand::Head.new(argv)
|
176
|
+
out = capture_stdout { head.call }
|
177
|
+
assert_equal "#{Yajl.dump(@record)}\n", out
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
test 'should fail with an invalid format' do
|
182
|
+
argv = ["#{TMP_DIR}/#{@file_name}", '--format=invalid']
|
183
|
+
|
184
|
+
timezone do
|
185
|
+
create_message_packed_file(@file_name, [event_time(@t).to_i], [@record])
|
186
|
+
head = BinlogReaderCommand::Head.new(argv)
|
187
|
+
|
188
|
+
assert_raise(SystemExit) do
|
189
|
+
capture_stdout { head.call }
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
test 'should succeed if multiple config_params format' do
|
195
|
+
file_name = 'packed.log'
|
196
|
+
argv = ["#{TMP_DIR}/#{file_name}", '--format=csv', '-e', 'fields=message,fo', '-e', 'delimiter=|']
|
197
|
+
create_message_packed_file(file_name, [event_time], [{ 'message' => 'dummy', 'fo' => 'dummy2' }])
|
198
|
+
|
199
|
+
head = BinlogReaderCommand::Head.new(argv)
|
200
|
+
assert_equal "\"dummy\"|\"dummy2\"\n", capture_stdout { head.call }
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
class TestCat < TestBaseCommand
|
206
|
+
sub_test_case 'initialize' do
|
207
|
+
data(
|
208
|
+
'file is not passed' => [],
|
209
|
+
'file is not found' => %w(invalid_path.log)
|
210
|
+
)
|
211
|
+
test 'should fail if a file is invalid' do |argv|
|
212
|
+
assert_raise(SystemExit) do
|
213
|
+
capture_stdout { BinlogReaderCommand::Head.new(argv) }
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
test 'should succeed if a file is valid' do
|
218
|
+
file_name = 'packed.log'
|
219
|
+
argv = ["#{TMP_DIR}/#{file_name}"]
|
220
|
+
create_message_packed_file(file_name)
|
221
|
+
|
222
|
+
assert_nothing_raised do
|
223
|
+
BinlogReaderCommand::Cat.new(argv)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
test 'should fail when config_params format is invalid' do
|
228
|
+
file_name = 'packed.log'
|
229
|
+
argv = ["#{TMP_DIR}/#{file_name}", '--format=json', '-e', 'only_key']
|
230
|
+
create_message_packed_file(file_name)
|
231
|
+
|
232
|
+
assert_raise(SystemExit) do
|
233
|
+
capture_stdout { BinlogReaderCommand::Cat.new(argv) }
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
test 'should succeed when config_params format is valid' do
|
238
|
+
file_name = 'packed.log'
|
239
|
+
argv = ["#{TMP_DIR}/#{file_name}", '--format=csv', '-e', 'fields=message']
|
240
|
+
create_message_packed_file(file_name)
|
241
|
+
|
242
|
+
assert_nothing_raised do
|
243
|
+
capture_stdout { BinlogReaderCommand::Cat.new(argv) }
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
sub_test_case 'call' do
|
249
|
+
setup do
|
250
|
+
@file_name = 'packed.log'
|
251
|
+
@t = '2011-01-02 13:14:15 UTC'
|
252
|
+
@record = { 'message' => 'dummy' }
|
253
|
+
end
|
254
|
+
|
255
|
+
test 'should output the file with default format(out_file)' do
|
256
|
+
argv = ["#{TMP_DIR}/#{@file_name}"]
|
257
|
+
|
258
|
+
timezone do
|
259
|
+
create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
|
260
|
+
head = BinlogReaderCommand::Cat.new(argv)
|
261
|
+
out = capture_stdout { head.call }
|
262
|
+
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}\n" * 6, out
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
test 'should set the number of lines to display' do
|
267
|
+
argv = ["#{TMP_DIR}/#{@file_name}", '-n', '1']
|
268
|
+
|
269
|
+
timezone do
|
270
|
+
create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
|
271
|
+
head = BinlogReaderCommand::Cat.new(argv)
|
272
|
+
out = capture_stdout { head.call }
|
273
|
+
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}\n", out
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
test 'should output content of a file with json format' do
|
278
|
+
argv = ["#{TMP_DIR}/#{@file_name}", '--format=json']
|
279
|
+
|
280
|
+
timezone do
|
281
|
+
create_message_packed_file(@file_name, [event_time(@t).to_i], [@record])
|
282
|
+
head = BinlogReaderCommand::Cat.new(argv)
|
283
|
+
out = capture_stdout { head.call }
|
284
|
+
assert_equal "#{Yajl.dump(@record)}\n", out
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
test 'should fail with an invalid format' do
|
289
|
+
argv = ["#{TMP_DIR}/#{@file_name}", '--format=invalid']
|
290
|
+
|
291
|
+
timezone do
|
292
|
+
create_message_packed_file(@file_name, [event_time(@t).to_i], [@record])
|
293
|
+
head = BinlogReaderCommand::Cat.new(argv)
|
294
|
+
|
295
|
+
assert_raise(SystemExit) do
|
296
|
+
capture_stdout { head.call }
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
test 'should succeed if multiple config_params format' do
|
302
|
+
file_name = 'packed.log'
|
303
|
+
argv = ["#{TMP_DIR}/#{file_name}", '--format=csv', '-e', 'fields=message,fo', '-e', 'delimiter=|']
|
304
|
+
create_message_packed_file(file_name, [event_time], [{ 'message' => 'dummy', 'fo' => 'dummy2' }])
|
305
|
+
|
306
|
+
head = BinlogReaderCommand::Cat.new(argv)
|
307
|
+
assert_equal "\"dummy\"|\"dummy2\"\n", capture_stdout { head.call }
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
class TestFormats < TestBaseCommand
|
313
|
+
test 'parse_option!' do
|
314
|
+
assert_raise(SystemExit) do
|
315
|
+
capture_stdout do
|
316
|
+
BinlogReaderCommand::Formats.new(['--plugin=invalid_dir_path'])
|
317
|
+
end
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
sub_test_case 'call' do
|
322
|
+
test 'display available plugins' do
|
323
|
+
f = BinlogReaderCommand::Formats.new
|
324
|
+
out = capture_stdout { f.call }
|
325
|
+
assert out.include?('json')
|
326
|
+
assert out.include?('csv')
|
327
|
+
end
|
328
|
+
|
329
|
+
test 'add new plugins using --plugin option' do
|
330
|
+
dir_path = File.expand_path(File.dirname(__FILE__) + '/../scripts/fluent/plugin/formatter1')
|
331
|
+
|
332
|
+
f = BinlogReaderCommand::Formats.new(["--plugin=#{dir_path}"])
|
333
|
+
out = capture_stdout { f.call }
|
334
|
+
assert out.include?('json')
|
335
|
+
assert out.include?('csv')
|
336
|
+
assert out.include?('test1')
|
337
|
+
end
|
338
|
+
|
339
|
+
test 'add multiple plugins using --plugin option' do
|
340
|
+
dir_path1 = File.expand_path(File.dirname(__FILE__) + '/../scripts/fluent/plugin/formatter1')
|
341
|
+
dir_path2 = File.expand_path(File.dirname(__FILE__) + '/../scripts/fluent/plugin/formatter2')
|
342
|
+
|
343
|
+
f = BinlogReaderCommand::Formats.new(["--plugin=#{dir_path1}", '-p', dir_path2])
|
344
|
+
out = capture_stdout { f.call }
|
345
|
+
assert out.include?('json')
|
346
|
+
assert out.include?('csv')
|
347
|
+
assert out.include?('test1')
|
348
|
+
assert out.include?('test2')
|
349
|
+
end
|
350
|
+
end
|
351
|
+
end
|
@@ -86,6 +86,12 @@ module Fluent::Config
|
|
86
86
|
assert_text_parsed_as(e('ROOT', '', {"k1" => "a b c"}), "k1 a b c")
|
87
87
|
end
|
88
88
|
|
89
|
+
test "parses value into empty string if only key exists" do
|
90
|
+
# value parser parses empty string as true for bool type
|
91
|
+
assert_text_parsed_as(e('ROOT', '', {"k1" => ""}), "k1\n")
|
92
|
+
assert_text_parsed_as(e('ROOT', '', {"k1" => ""}), "k1")
|
93
|
+
end
|
94
|
+
|
89
95
|
sub_test_case 'non-quoted string' do
|
90
96
|
test "remains text starting with '#'" do
|
91
97
|
assert_text_parsed_as(e('ROOT', '', {"k1" => "#not_comment"}), " k1 #not_comment")
|
@@ -159,6 +159,11 @@ module ConfigurableSpec
|
|
159
159
|
config_param :obj2, :array, default: []
|
160
160
|
end
|
161
161
|
|
162
|
+
class Example7
|
163
|
+
include Fluent::Configurable
|
164
|
+
config_param :name, :string, default: 'example7', skip_accessor: true
|
165
|
+
end
|
166
|
+
|
162
167
|
module Overwrite
|
163
168
|
class Base
|
164
169
|
include Fluent::Configurable
|
@@ -720,7 +725,8 @@ module Fluent::Config
|
|
720
725
|
assert_nothing_raised { init0.configure(conf) }
|
721
726
|
assert init0.sec1
|
722
727
|
assert_equal "sec1", init0.sec1.name
|
723
|
-
assert_equal
|
728
|
+
assert_equal 1, init0.sec2.size
|
729
|
+
assert_equal "sec1", init0.sec2.first.name
|
724
730
|
end
|
725
731
|
|
726
732
|
test 'accepts configuration values as string representation' do
|
@@ -1108,6 +1114,18 @@ module Fluent::Config
|
|
1108
1114
|
end
|
1109
1115
|
end
|
1110
1116
|
end
|
1117
|
+
|
1118
|
+
sub_test_case ':skip_accessor option' do
|
1119
|
+
test 'it does not create accessor methods for parameters' do
|
1120
|
+
@example = ConfigurableSpec::Example7.new
|
1121
|
+
@example.configure(config_element('ROOT'))
|
1122
|
+
assert_equal 'example7', @example.instance_variable_get(:@name)
|
1123
|
+
assert_raise NoMethodError.new("undefined method `name' for #{@example}") do
|
1124
|
+
@example.name
|
1125
|
+
end
|
1126
|
+
end
|
1127
|
+
end
|
1128
|
+
|
1111
1129
|
sub_test_case 'non-required options for config_param' do
|
1112
1130
|
test 'desc must be a string if specified' do
|
1113
1131
|
assert_raise ArgumentError.new("key: desc must be a String, but Symbol") do
|
@@ -1125,6 +1143,20 @@ module Fluent::Config
|
|
1125
1143
|
end
|
1126
1144
|
end
|
1127
1145
|
end
|
1146
|
+
test 'secret must be true or false if specified' do
|
1147
|
+
assert_raise ArgumentError.new("key: secret must be true or false, but NilClass") do
|
1148
|
+
class InvalidSecretClass
|
1149
|
+
include Fluent::Configurable
|
1150
|
+
config_param :key, :string, default: '', secret: nil
|
1151
|
+
end
|
1152
|
+
end
|
1153
|
+
assert_raise ArgumentError.new("key: secret must be true or false, but String") do
|
1154
|
+
class InvalidSecret2Class
|
1155
|
+
include Fluent::Configurable
|
1156
|
+
config_param :key, :string, default: '', secret: 'yes'
|
1157
|
+
end
|
1158
|
+
end
|
1159
|
+
end
|
1128
1160
|
test 'deprecated must be a string if specified' do
|
1129
1161
|
assert_raise ArgumentError.new("key: deprecated must be a String, but TrueClass") do
|
1130
1162
|
class InvalidDeprecatedClass
|
@@ -1157,6 +1189,20 @@ module Fluent::Config
|
|
1157
1189
|
end
|
1158
1190
|
end
|
1159
1191
|
end
|
1192
|
+
test 'skip_accessor must be true or false if specified' do
|
1193
|
+
assert_raise ArgumentError.new("key: skip_accessor must be true or false, but NilClass") do
|
1194
|
+
class InvalidSkipAccessorClass
|
1195
|
+
include Fluent::Configurable
|
1196
|
+
config_param :key, :string, default: '', skip_accessor: nil
|
1197
|
+
end
|
1198
|
+
end
|
1199
|
+
assert_raise ArgumentError.new("key: skip_accessor must be true or false, but String") do
|
1200
|
+
class InvalidSkipAccessor2Class
|
1201
|
+
include Fluent::Configurable
|
1202
|
+
config_param :key, :string, default: '', skip_accessor: 'yes'
|
1203
|
+
end
|
1204
|
+
end
|
1205
|
+
end
|
1160
1206
|
end
|
1161
1207
|
sub_test_case 'enum parameters' do
|
1162
1208
|
test 'list must be specified as an array of symbols'
|