fluentd 1.13.0-x86-mingw32 → 1.14.0-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/.github/ISSUE_TEMPLATE/bug_report.yaml +69 -0
- data/.github/ISSUE_TEMPLATE/feature_request.yaml +38 -0
- data/.github/workflows/linux-test.yaml +1 -1
- data/.github/workflows/windows-test.yaml +4 -4
- data/.gitlab-ci.yml +0 -22
- data/CHANGELOG.md +131 -0
- data/README.md +2 -2
- data/example/v0_12_filter.conf +2 -2
- data/fluentd.gemspec +1 -1
- data/lib/fluent/command/fluentd.rb +8 -0
- data/lib/fluent/command/plugin_generator.rb +15 -5
- data/lib/fluent/compat/output.rb +9 -6
- data/lib/fluent/config/section.rb +5 -0
- data/lib/fluent/config/types.rb +15 -0
- data/lib/fluent/config/v1_parser.rb +3 -2
- data/lib/fluent/config.rb +1 -1
- data/lib/fluent/env.rb +2 -1
- data/lib/fluent/event_router.rb +28 -1
- data/lib/fluent/oj_options.rb +62 -0
- data/lib/fluent/plugin/bare_output.rb +49 -8
- data/lib/fluent/plugin/buffer.rb +84 -22
- data/lib/fluent/plugin/file_wrapper.rb +22 -0
- data/lib/fluent/plugin/filter.rb +35 -1
- data/lib/fluent/plugin/formatter.rb +1 -0
- data/lib/fluent/plugin/formatter_json.rb +9 -7
- data/lib/fluent/plugin/in_http.rb +21 -2
- data/lib/fluent/plugin/in_monitor_agent.rb +4 -2
- data/lib/fluent/plugin/in_syslog.rb +13 -1
- data/lib/fluent/plugin/in_tail/position_file.rb +20 -18
- data/lib/fluent/plugin/in_tail.rb +45 -4
- data/lib/fluent/plugin/input.rb +39 -1
- data/lib/fluent/plugin/metrics.rb +119 -0
- data/lib/fluent/plugin/metrics_local.rb +96 -0
- data/lib/fluent/plugin/multi_output.rb +43 -6
- data/lib/fluent/plugin/out_forward.rb +1 -3
- data/lib/fluent/plugin/output.rb +74 -33
- data/lib/fluent/plugin/parser_json.rb +2 -3
- data/lib/fluent/plugin/service_discovery.rb +0 -15
- data/lib/fluent/plugin.rb +10 -1
- data/lib/fluent/plugin_helper/event_emitter.rb +8 -1
- data/lib/fluent/plugin_helper/http_server/router.rb +1 -1
- data/lib/fluent/plugin_helper/metrics.rb +129 -0
- data/lib/fluent/plugin_helper/server.rb +4 -2
- data/lib/fluent/plugin_helper.rb +1 -0
- data/lib/fluent/root_agent.rb +6 -0
- data/lib/fluent/supervisor.rb +2 -0
- data/lib/fluent/system_config.rb +9 -1
- data/lib/fluent/test/driver/storage.rb +30 -0
- data/lib/fluent/version.rb +1 -1
- data/templates/new_gem/lib/fluent/plugin/storage.rb.erb +40 -0
- data/templates/new_gem/test/plugin/test_storage.rb.erb +18 -0
- data/test/command/test_cat.rb +11 -8
- data/test/command/test_plugin_generator.rb +2 -1
- data/test/config/test_section.rb +9 -0
- data/test/config/test_system_config.rb +6 -0
- data/test/config/test_types.rb +7 -0
- data/test/plugin/in_tail/test_position_file.rb +48 -8
- data/test/plugin/test_bare_output.rb +13 -0
- data/test/plugin/test_buffer.rb +8 -2
- data/test/plugin/test_file_wrapper.rb +11 -0
- data/test/plugin/test_filter.rb +11 -0
- data/test/plugin/test_in_forward.rb +59 -83
- data/test/plugin/test_in_http.rb +86 -43
- data/test/plugin/test_in_monitor_agent.rb +214 -8
- data/test/plugin/test_in_syslog.rb +101 -56
- data/test/plugin/test_in_tail.rb +149 -48
- data/test/plugin/test_in_tcp.rb +45 -32
- data/test/plugin/test_in_udp.rb +47 -33
- data/test/plugin/test_input.rb +11 -0
- data/test/plugin/test_metrics.rb +294 -0
- data/test/plugin/test_metrics_local.rb +96 -0
- data/test/plugin/test_multi_output.rb +25 -1
- data/test/plugin/test_out_forward.rb +103 -89
- data/test/plugin/test_out_stream.rb +18 -8
- data/test/plugin/test_output.rb +16 -0
- data/test/plugin_helper/http_server/test_route.rb +1 -1
- data/test/plugin_helper/test_child_process.rb +1 -1
- data/test/plugin_helper/test_event_emitter.rb +29 -0
- data/test/plugin_helper/test_http_server_helper.rb +33 -26
- data/test/plugin_helper/test_metrics.rb +137 -0
- data/test/plugin_helper/test_server.rb +137 -138
- data/test/plugin_helper/test_socket.rb +16 -9
- data/test/test_event_time.rb +2 -2
- data/test/test_oj_options.rb +55 -0
- data/test/test_plugin_classes.rb +102 -0
- data/test/test_root_agent.rb +30 -1
- metadata +22 -7
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -40
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -23
@@ -52,20 +52,30 @@ end
|
|
52
52
|
class TcpOutputTest < Test::Unit::TestCase
|
53
53
|
include StreamOutputTest
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
port
|
58
|
-
|
59
|
-
send_timeout 51
|
60
|
-
]
|
55
|
+
def setup
|
56
|
+
super
|
57
|
+
@port = unused_port
|
58
|
+
end
|
61
59
|
|
62
|
-
def
|
60
|
+
def teardown
|
61
|
+
@port = nil
|
62
|
+
end
|
63
|
+
|
64
|
+
def config
|
65
|
+
%[
|
66
|
+
port #{@port}
|
67
|
+
host 127.0.0.1
|
68
|
+
send_timeout 51
|
69
|
+
]
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_driver(conf=config)
|
63
73
|
super(Fluent::TcpOutput, conf)
|
64
74
|
end
|
65
75
|
|
66
76
|
def test_configure
|
67
77
|
d = create_driver
|
68
|
-
assert_equal
|
78
|
+
assert_equal @port, d.instance.port
|
69
79
|
assert_equal '127.0.0.1', d.instance.host
|
70
80
|
assert_equal 51, d.instance.send_timeout
|
71
81
|
end
|
data/test/plugin/test_output.rb
CHANGED
@@ -223,6 +223,22 @@ class OutputTest < Test::Unit::TestCase
|
|
223
223
|
assert @i.terminated?
|
224
224
|
end
|
225
225
|
|
226
|
+
test 'can use metrics plugins and fallback methods' do
|
227
|
+
@i.configure(config_element())
|
228
|
+
|
229
|
+
%w[num_errors_metrics emit_count_metrics emit_size_metrics emit_records_metrics
|
230
|
+
write_count_metrics rollback_count_metrics flush_time_count_metrics slow_flush_count_metrics].each do |metric_name|
|
231
|
+
assert_true @i.instance_variable_get(:"@#{metric_name}").is_a?(Fluent::Plugin::Metrics)
|
232
|
+
end
|
233
|
+
|
234
|
+
assert_equal 0, @i.num_errors
|
235
|
+
assert_equal 0, @i.emit_count
|
236
|
+
assert_equal 0, @i.emit_size
|
237
|
+
assert_equal 0, @i.emit_records
|
238
|
+
assert_equal 0, @i.write_count
|
239
|
+
assert_equal 0, @i.rollback_count
|
240
|
+
end
|
241
|
+
|
226
242
|
data(:new_api => :chunk,
|
227
243
|
:old_api => :metadata)
|
228
244
|
test '#extract_placeholders does nothing if chunk key is not specified' do |api|
|
@@ -20,7 +20,7 @@ unless skip
|
|
20
20
|
test 'use default app if path is not found' do
|
21
21
|
router = Fluent::PluginHelper::HttpServer::Router.new
|
22
22
|
req = flexmock('request', path: 'path/')
|
23
|
-
assert_equal(router.route!(:get, '/path/', req), [404, { 'Content-Type' => 'text/plain' }, "404 Not Found
|
23
|
+
assert_equal(router.route!(:get, '/path/', req), [404, { 'Content-Type' => 'text/plain' }, "404 Not Found\n"])
|
24
24
|
end
|
25
25
|
|
26
26
|
test 'default app is configurable' do
|
@@ -560,7 +560,7 @@ class ChildProcessTest < Test::Unit::TestCase
|
|
560
560
|
proc_lines = []
|
561
561
|
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
|
562
562
|
ran = false
|
563
|
-
@d.child_process_execute(:t14, "
|
563
|
+
@d.child_process_execute(:t14, "/bin/sh", arguments:['-c', 'sleep 10; echo "hello"'], subprocess_name: "sleeeeeeeeeper", mode: [:read]) do |readio|
|
564
564
|
m.lock
|
565
565
|
ran = true
|
566
566
|
pids << @d.child_process_id
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative '../helper'
|
2
2
|
require 'fluent/plugin_helper/event_emitter'
|
3
3
|
require 'fluent/plugin/base'
|
4
|
+
require 'flexmock/test_unit'
|
4
5
|
|
5
6
|
class EventEmitterTest < Test::Unit::TestCase
|
6
7
|
setup do
|
@@ -48,4 +49,32 @@ class EventEmitterTest < Test::Unit::TestCase
|
|
48
49
|
|
49
50
|
d1.terminate
|
50
51
|
end
|
52
|
+
|
53
|
+
test 'should not have event_emitter_router' do
|
54
|
+
d0 = Dummy0.new
|
55
|
+
assert !d0.respond_to?(:event_emitter_router)
|
56
|
+
end
|
57
|
+
|
58
|
+
test 'should have event_emitter_router' do
|
59
|
+
d = Dummy.new
|
60
|
+
assert d.respond_to?(:event_emitter_router)
|
61
|
+
end
|
62
|
+
|
63
|
+
test 'get router' do
|
64
|
+
router_mock = flexmock('mytest')
|
65
|
+
label_mock = flexmock('mylabel')
|
66
|
+
label_mock.should_receive(:event_router).twice.and_return(router_mock)
|
67
|
+
Fluent::Engine.root_agent.labels['@mytest'] = label_mock
|
68
|
+
|
69
|
+
d = Dummy.new
|
70
|
+
d.configure(config_element('ROOT', '', {'@label' => '@mytest'}))
|
71
|
+
router = d.event_emitter_router("@mytest")
|
72
|
+
assert_equal router_mock, router
|
73
|
+
end
|
74
|
+
|
75
|
+
test 'get root router' do
|
76
|
+
d = Dummy.new
|
77
|
+
router = d.event_emitter_router("@ROOT")
|
78
|
+
assert_equal Fluent::Engine.root_agent.event_router, router
|
79
|
+
end
|
51
80
|
end
|
@@ -9,11 +9,18 @@ require 'openssl'
|
|
9
9
|
require 'async'
|
10
10
|
|
11
11
|
class HttpHelperTest < Test::Unit::TestCase
|
12
|
-
PORT = unused_port
|
13
12
|
NULL_LOGGER = Logger.new(nil)
|
14
13
|
CERT_DIR = File.expand_path(File.dirname(__FILE__) + '/data/cert/without_ca')
|
15
14
|
CERT_CA_DIR = File.expand_path(File.dirname(__FILE__) + '/data/cert/with_ca')
|
16
15
|
|
16
|
+
def setup
|
17
|
+
@port = unused_port
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
@port = nil
|
22
|
+
end
|
23
|
+
|
17
24
|
class Dummy < Fluent::Plugin::TestBase
|
18
25
|
helpers :http_server
|
19
26
|
end
|
@@ -147,7 +154,7 @@ class HttpHelperTest < Test::Unit::TestCase
|
|
147
154
|
sub_test_case 'Create a HTTP server' do
|
148
155
|
test 'monunt given path' do
|
149
156
|
on_driver do |driver|
|
150
|
-
driver.http_server_create_http_server(:http_server_helper_test, addr: '127.0.0.1', port:
|
157
|
+
driver.http_server_create_http_server(:http_server_helper_test, addr: '127.0.0.1', port: @port, logger: NULL_LOGGER) do |s|
|
151
158
|
s.get('/example/hello') { [200, { 'Content-Type' => 'text/plain' }, 'hello get'] }
|
152
159
|
s.post('/example/hello') { [200, { 'Content-Type' => 'text/plain' }, 'hello post'] }
|
153
160
|
s.head('/example/hello') { [200, { 'Content-Type' => 'text/plain' }, 'hello head'] }
|
@@ -158,13 +165,13 @@ class HttpHelperTest < Test::Unit::TestCase
|
|
158
165
|
s.options('/example/hello') { [200, { 'Content-Type' => 'text/plain' }, 'hello options'] }
|
159
166
|
end
|
160
167
|
|
161
|
-
resp = head("http://127.0.0.1:#{
|
168
|
+
resp = head("http://127.0.0.1:#{@port}/example/hello")
|
162
169
|
assert_equal('200', resp.code)
|
163
170
|
assert_equal(nil, resp.body)
|
164
171
|
assert_equal('text/plain', resp['Content-Type'])
|
165
172
|
|
166
173
|
%w[get put post put delete options trace].each do |n|
|
167
|
-
resp = send(n, "http://127.0.0.1:#{
|
174
|
+
resp = send(n, "http://127.0.0.1:#{@port}/example/hello")
|
168
175
|
assert_equal('200', resp.code)
|
169
176
|
assert_equal("hello #{n}", resp.body)
|
170
177
|
assert_equal('text/plain', resp['Content-Type'])
|
@@ -174,44 +181,44 @@ class HttpHelperTest < Test::Unit::TestCase
|
|
174
181
|
|
175
182
|
test 'when path does not start with `/` or ends with `/`' do
|
176
183
|
on_driver do |driver|
|
177
|
-
driver.http_server_create_http_server(:http_server_helper_test, addr: '127.0.0.1', port:
|
184
|
+
driver.http_server_create_http_server(:http_server_helper_test, addr: '127.0.0.1', port: @port, logger: NULL_LOGGER) do |s|
|
178
185
|
s.get('example/hello') { [200, { 'Content-Type' => 'text/plain' }, 'hello get'] }
|
179
186
|
s.get('/example/hello2/') { [200, { 'Content-Type' => 'text/plain' }, 'hello get'] }
|
180
187
|
end
|
181
188
|
|
182
|
-
resp = get("http://127.0.0.1:#{
|
189
|
+
resp = get("http://127.0.0.1:#{@port}/example/hello")
|
183
190
|
assert_equal('404', resp.code)
|
184
191
|
|
185
|
-
resp = get("http://127.0.0.1:#{
|
192
|
+
resp = get("http://127.0.0.1:#{@port}/example/hello2")
|
186
193
|
assert_equal('200', resp.code)
|
187
194
|
end
|
188
195
|
end
|
189
196
|
|
190
197
|
test 'when error raised' do
|
191
198
|
on_driver do |driver|
|
192
|
-
driver.http_server_create_http_server(:http_server_helper_test, addr: '127.0.0.1', port:
|
199
|
+
driver.http_server_create_http_server(:http_server_helper_test, addr: '127.0.0.1', port: @port, logger: NULL_LOGGER) do |s|
|
193
200
|
s.get('/example/hello') { raise 'error!' }
|
194
201
|
end
|
195
202
|
|
196
|
-
resp = get("http://127.0.0.1:#{
|
203
|
+
resp = get("http://127.0.0.1:#{@port}/example/hello")
|
197
204
|
assert_equal('500', resp.code)
|
198
205
|
end
|
199
206
|
end
|
200
207
|
|
201
208
|
test 'when path is not found' do
|
202
209
|
on_driver do |driver|
|
203
|
-
driver.http_server_create_http_server(:http_server_helper_test, addr: '127.0.0.1', port:
|
210
|
+
driver.http_server_create_http_server(:http_server_helper_test, addr: '127.0.0.1', port: @port, logger: NULL_LOGGER) do |s|
|
204
211
|
s.get('/example/hello') { [200, { 'Content-Type' => 'text/plain' }, 'hello get'] }
|
205
212
|
end
|
206
213
|
|
207
|
-
resp = get("http://127.0.0.1:#{
|
214
|
+
resp = get("http://127.0.0.1:#{@port}/example/hello/not_found")
|
208
215
|
assert_equal('404', resp.code)
|
209
216
|
end
|
210
217
|
end
|
211
218
|
|
212
219
|
test 'params and body' do
|
213
220
|
on_driver do |driver|
|
214
|
-
driver.http_server_create_http_server(:http_server_helper_test, addr: '127.0.0.1', port:
|
221
|
+
driver.http_server_create_http_server(:http_server_helper_test, addr: '127.0.0.1', port: @port, logger: NULL_LOGGER) do |s|
|
215
222
|
s.get('/example/hello') do |req|
|
216
223
|
assert_equal(req.query_string, nil)
|
217
224
|
assert_equal(req.body, nil)
|
@@ -237,16 +244,16 @@ class HttpHelperTest < Test::Unit::TestCase
|
|
237
244
|
end
|
238
245
|
end
|
239
246
|
|
240
|
-
resp = get("http://127.0.0.1:#{
|
247
|
+
resp = get("http://127.0.0.1:#{@port}/example/hello")
|
241
248
|
assert_equal('200', resp.code)
|
242
249
|
|
243
|
-
resp = post("http://127.0.0.1:#{
|
250
|
+
resp = post("http://127.0.0.1:#{@port}/example/hello", 'this is body')
|
244
251
|
assert_equal('200', resp.code)
|
245
252
|
|
246
|
-
resp = get("http://127.0.0.1:#{
|
253
|
+
resp = get("http://127.0.0.1:#{@port}/example/hello/params?test=true")
|
247
254
|
assert_equal('200', resp.code)
|
248
255
|
|
249
|
-
resp = post("http://127.0.0.1:#{
|
256
|
+
resp = post("http://127.0.0.1:#{@port}/example/hello/params?test=true", 'this is body')
|
250
257
|
assert_equal('200', resp.code)
|
251
258
|
end
|
252
259
|
end
|
@@ -265,11 +272,11 @@ class HttpHelperTest < Test::Unit::TestCase
|
|
265
272
|
test 'can overwrite settings by using tls_context' do
|
266
273
|
on_driver_transport({ 'insecure' => 'false' }) do |driver|
|
267
274
|
tls = { 'insecure' => 'true' } # overwrite
|
268
|
-
driver.http_server_create_https_server(:http_server_helper_test_tls, addr: '127.0.0.1', port:
|
275
|
+
driver.http_server_create_https_server(:http_server_helper_test_tls, addr: '127.0.0.1', port: @port, logger: NULL_LOGGER, tls_opts: tls) do |s|
|
269
276
|
s.get('/example/hello') { [200, { 'Content-Type' => 'text/plain' }, 'hello get'] }
|
270
277
|
end
|
271
278
|
|
272
|
-
resp = secure_get("https://127.0.0.1:#{
|
279
|
+
resp = secure_get("https://127.0.0.1:#{@port}/example/hello", verify: false)
|
273
280
|
assert_equal('200', resp.code)
|
274
281
|
assert_equal('hello get', resp.body)
|
275
282
|
end
|
@@ -277,17 +284,17 @@ class HttpHelperTest < Test::Unit::TestCase
|
|
277
284
|
|
278
285
|
test 'with insecure in transport section' do
|
279
286
|
on_driver_transport({ 'insecure' => 'true' }) do |driver|
|
280
|
-
driver.http_server_create_https_server(:http_server_helper_test_tls, addr: '127.0.0.1', port:
|
287
|
+
driver.http_server_create_https_server(:http_server_helper_test_tls, addr: '127.0.0.1', port: @port, logger: NULL_LOGGER) do |s|
|
281
288
|
s.get('/example/hello') { [200, { 'Content-Type' => 'text/plain' }, 'hello get'] }
|
282
289
|
end
|
283
290
|
omit "TLS connection should be aborted due to `Errno::ECONNABORTED`. Need to debug." if Fluent.windows?
|
284
291
|
|
285
|
-
resp = secure_get("https://127.0.0.1:#{
|
292
|
+
resp = secure_get("https://127.0.0.1:#{@port}/example/hello", verify: false)
|
286
293
|
assert_equal('200', resp.code)
|
287
294
|
assert_equal('hello get', resp.body)
|
288
295
|
|
289
296
|
assert_raise OpenSSL::SSL::SSLError do
|
290
|
-
secure_get("https://127.0.0.1:#{
|
297
|
+
secure_get("https://127.0.0.1:#{@port}/example/hello")
|
291
298
|
end
|
292
299
|
end
|
293
300
|
end
|
@@ -306,11 +313,11 @@ class HttpHelperTest < Test::Unit::TestCase
|
|
306
313
|
end
|
307
314
|
|
308
315
|
on_driver_transport(opt) do |driver|
|
309
|
-
driver.http_server_create_https_server(:http_server_helper_test_tls, addr: '127.0.0.1', port:
|
316
|
+
driver.http_server_create_https_server(:http_server_helper_test_tls, addr: '127.0.0.1', port: @port, logger: NULL_LOGGER) do |s|
|
310
317
|
s.get('/example/hello') { [200, { 'Content-Type' => 'text/plain' }, 'hello get'] }
|
311
318
|
end
|
312
319
|
|
313
|
-
resp = secure_get("https://127.0.0.1:#{
|
320
|
+
resp = secure_get("https://127.0.0.1:#{@port}/example/hello", cert_path: cert_path)
|
314
321
|
assert_equal('200', resp.code)
|
315
322
|
assert_equal('hello get', resp.body)
|
316
323
|
end
|
@@ -333,11 +340,11 @@ class HttpHelperTest < Test::Unit::TestCase
|
|
333
340
|
end
|
334
341
|
|
335
342
|
on_driver_transport(opt) do |driver|
|
336
|
-
driver.http_server_create_https_server(:http_server_helper_test_tls, addr: '127.0.0.1', port:
|
343
|
+
driver.http_server_create_https_server(:http_server_helper_test_tls, addr: '127.0.0.1', port: @port, logger: NULL_LOGGER) do |s|
|
337
344
|
s.get('/example/hello') { [200, { 'Content-Type' => 'text/plain' }, 'hello get'] }
|
338
345
|
end
|
339
346
|
|
340
|
-
resp = secure_get("https://127.0.0.1:#{
|
347
|
+
resp = secure_get("https://127.0.0.1:#{@port}/example/hello", cert_path: ca_cert_path)
|
341
348
|
assert_equal('200', resp.code)
|
342
349
|
assert_equal('hello get', resp.body)
|
343
350
|
end
|
@@ -355,7 +362,7 @@ class HttpHelperTest < Test::Unit::TestCase
|
|
355
362
|
end
|
356
363
|
|
357
364
|
stub(Fluent::PluginHelper::HttpServer::Server).new(addr: anything, port: anything, logger: anything, default_app: anything) { server }
|
358
|
-
driver.http_server_create_http_server(:http_server_helper_test, addr: '127.0.0.1', port:
|
365
|
+
driver.http_server_create_http_server(:http_server_helper_test, addr: '127.0.0.1', port: @port, logger: NULL_LOGGER) do
|
359
366
|
# nothing
|
360
367
|
end
|
361
368
|
driver.stop
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/plugin_helper/metrics'
|
3
|
+
require 'fluent/plugin/base'
|
4
|
+
|
5
|
+
class MetricsTest < Test::Unit::TestCase
|
6
|
+
class Dummy < Fluent::Plugin::TestBase
|
7
|
+
helpers :metrics
|
8
|
+
def configure(conf)
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
setup do
|
14
|
+
@d = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
teardown do
|
18
|
+
if @d
|
19
|
+
@d.stop unless @d.stopped?
|
20
|
+
@d.shutdown unless @d.shutdown?
|
21
|
+
@d.close unless @d.closed?
|
22
|
+
@d.terminate unless @d.terminated?
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
test 'can be initialized without any metrics at first' do
|
27
|
+
d = Dummy.new
|
28
|
+
assert_equal 0, d._metrics.size
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'can be configured' do
|
32
|
+
d1 = Dummy.new
|
33
|
+
assert_nothing_raised do
|
34
|
+
d1.configure(config_element())
|
35
|
+
end
|
36
|
+
assert d1.plugin_id
|
37
|
+
assert d1.log
|
38
|
+
end
|
39
|
+
|
40
|
+
test 'creates metrics instances' do
|
41
|
+
d = Dummy.new
|
42
|
+
i = d.metrics_create(namespace: "fluentd_test", subsystem: "unit-test", name: "metrics1", help_text: "metrics testing")
|
43
|
+
d.configure(config_element())
|
44
|
+
assert do
|
45
|
+
d.instance_variable_get(:@plugin_type_or_id).include?("dummy.object")
|
46
|
+
end
|
47
|
+
assert{ i.is_a?(Fluent::Plugin::LocalMetrics) }
|
48
|
+
assert_true i.has_methods_for_counter
|
49
|
+
assert_false i.has_methods_for_gauge
|
50
|
+
|
51
|
+
d = Dummy.new
|
52
|
+
i = d.metrics_create(namespace: "fluentd_test", subsystem: "unit-test", name: "metrics2", help_text: "metrics testing", prefer_gauge: true)
|
53
|
+
d.configure(config_element())
|
54
|
+
assert do
|
55
|
+
d.instance_variable_get(:@plugin_type_or_id).include?("dummy.object")
|
56
|
+
end
|
57
|
+
assert{ i.is_a?(Fluent::Plugin::LocalMetrics) }
|
58
|
+
assert_false i.has_methods_for_counter
|
59
|
+
assert_true i.has_methods_for_gauge
|
60
|
+
end
|
61
|
+
|
62
|
+
test 'calls lifecycle methods for all plugin instances via owner plugin' do
|
63
|
+
@d = d = Dummy.new
|
64
|
+
i1 = d.metrics_create(namespace: "fluentd_test", subsystem: "unit-test", name: "metrics1", help_text: "metrics testing")
|
65
|
+
i2 = d.metrics_create(namespace: "fluentd_test", subsystem: "unit-test", name: "metrics2", help_text: "metrics testing", prefer_gauge: true)
|
66
|
+
i3 = d.metrics_create(namespace: "fluentd_test", subsystem: "unit-test", name: "metrics3", help_text: "metrics testing")
|
67
|
+
d.configure(config_element())
|
68
|
+
assert do
|
69
|
+
d.instance_variable_get(:@plugin_type_or_id).include?("dummy.object")
|
70
|
+
end
|
71
|
+
d.start
|
72
|
+
|
73
|
+
assert i1.started?
|
74
|
+
assert i2.started?
|
75
|
+
assert i3.started?
|
76
|
+
|
77
|
+
assert !i1.stopped?
|
78
|
+
assert !i2.stopped?
|
79
|
+
assert !i3.stopped?
|
80
|
+
|
81
|
+
d.stop
|
82
|
+
|
83
|
+
assert i1.stopped?
|
84
|
+
assert i2.stopped?
|
85
|
+
assert i3.stopped?
|
86
|
+
|
87
|
+
assert !i1.before_shutdown?
|
88
|
+
assert !i2.before_shutdown?
|
89
|
+
assert !i3.before_shutdown?
|
90
|
+
|
91
|
+
d.before_shutdown
|
92
|
+
|
93
|
+
assert i1.before_shutdown?
|
94
|
+
assert i2.before_shutdown?
|
95
|
+
assert i3.before_shutdown?
|
96
|
+
|
97
|
+
assert !i1.shutdown?
|
98
|
+
assert !i2.shutdown?
|
99
|
+
assert !i3.shutdown?
|
100
|
+
|
101
|
+
d.shutdown
|
102
|
+
|
103
|
+
assert i1.shutdown?
|
104
|
+
assert i2.shutdown?
|
105
|
+
assert i3.shutdown?
|
106
|
+
|
107
|
+
assert !i1.after_shutdown?
|
108
|
+
assert !i2.after_shutdown?
|
109
|
+
assert !i3.after_shutdown?
|
110
|
+
|
111
|
+
d.after_shutdown
|
112
|
+
|
113
|
+
assert i1.after_shutdown?
|
114
|
+
assert i2.after_shutdown?
|
115
|
+
assert i3.after_shutdown?
|
116
|
+
|
117
|
+
assert !i1.closed?
|
118
|
+
assert !i2.closed?
|
119
|
+
assert !i3.closed?
|
120
|
+
|
121
|
+
d.close
|
122
|
+
|
123
|
+
assert i1.closed?
|
124
|
+
assert i2.closed?
|
125
|
+
assert i3.closed?
|
126
|
+
|
127
|
+
assert !i1.terminated?
|
128
|
+
assert !i2.terminated?
|
129
|
+
assert !i3.terminated?
|
130
|
+
|
131
|
+
d.terminate
|
132
|
+
|
133
|
+
assert i1.terminated?
|
134
|
+
assert i2.terminated?
|
135
|
+
assert i3.terminated?
|
136
|
+
end
|
137
|
+
end
|