fluentd 1.13.0-x64-mingw32 → 1.14.0-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/.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
@@ -15,8 +15,8 @@
|
|
15
15
|
#
|
16
16
|
|
17
17
|
require 'fluent/plugin/parser'
|
18
|
-
require 'fluent/env'
|
19
18
|
require 'fluent/time'
|
19
|
+
require 'fluent/oj_options'
|
20
20
|
|
21
21
|
require 'yajl'
|
22
22
|
require 'json'
|
@@ -50,8 +50,7 @@ module Fluent
|
|
50
50
|
def configure_json_parser(name)
|
51
51
|
case name
|
52
52
|
when :oj
|
53
|
-
|
54
|
-
Oj.default_options = Fluent::DEFAULT_OJ_OPTIONS
|
53
|
+
raise LoadError unless Fluent::OjOptions.available?
|
55
54
|
[Oj.method(:load), Oj::ParseError]
|
56
55
|
when :json then [JSON.method(:load), JSON::ParserError]
|
57
56
|
when :yajl then [Yajl.method(:load), Yajl::ParseError]
|
@@ -13,21 +13,6 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
|
-
#
|
17
|
-
# Fluentd
|
18
|
-
#
|
19
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
20
|
-
# you may not use this file except in compliance with the License.
|
21
|
-
# You may obtain a copy of the License at
|
22
|
-
#
|
23
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
24
|
-
#
|
25
|
-
# Unless required by applicable law or agreed to in writing, software
|
26
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
27
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
28
|
-
# See the License for the specific language governing permissions and
|
29
|
-
# limitations under the License.
|
30
|
-
#
|
31
16
|
|
32
17
|
require 'fluent/plugin/base'
|
33
18
|
|
data/lib/fluent/plugin.rb
CHANGED
@@ -36,8 +36,9 @@ module Fluent
|
|
36
36
|
FORMATTER_REGISTRY = Registry.new(:formatter, 'fluent/plugin/formatter_', dir_search_prefix: 'formatter_')
|
37
37
|
STORAGE_REGISTRY = Registry.new(:storage, 'fluent/plugin/storage_', dir_search_prefix: 'storage_')
|
38
38
|
SD_REGISTRY = Registry.new(:sd, 'fluent/plugin/sd_', dir_search_prefix: 'sd_')
|
39
|
+
METRICS_REGISTRY = Registry.new(:metrics, 'fluent/plugin/metrics_', dir_search_prefix: 'metrics_')
|
39
40
|
|
40
|
-
REGISTRIES = [INPUT_REGISTRY, OUTPUT_REGISTRY, FILTER_REGISTRY, BUFFER_REGISTRY, PARSER_REGISTRY, FORMATTER_REGISTRY, STORAGE_REGISTRY, SD_REGISTRY]
|
41
|
+
REGISTRIES = [INPUT_REGISTRY, OUTPUT_REGISTRY, FILTER_REGISTRY, BUFFER_REGISTRY, PARSER_REGISTRY, FORMATTER_REGISTRY, STORAGE_REGISTRY, SD_REGISTRY, METRICS_REGISTRY]
|
41
42
|
|
42
43
|
def self.register_input(type, klass)
|
43
44
|
register_impl('input', INPUT_REGISTRY, type, klass)
|
@@ -59,6 +60,10 @@ module Fluent
|
|
59
60
|
register_impl('sd', SD_REGISTRY, type, klass)
|
60
61
|
end
|
61
62
|
|
63
|
+
def self.register_metrics(type, klass)
|
64
|
+
register_impl('metrics', METRICS_REGISTRY, type, klass)
|
65
|
+
end
|
66
|
+
|
62
67
|
def self.register_parser(type, klass_or_proc)
|
63
68
|
if klass_or_proc.is_a?(Regexp)
|
64
69
|
# This usage is not recommended for new API
|
@@ -121,6 +126,10 @@ module Fluent
|
|
121
126
|
new_impl('sd', SD_REGISTRY, type, parent)
|
122
127
|
end
|
123
128
|
|
129
|
+
def self.new_metrics(type, parent: nil)
|
130
|
+
new_impl('metrics', METRICS_REGISTRY, type, parent)
|
131
|
+
end
|
132
|
+
|
124
133
|
class << self
|
125
134
|
# This should be defined for fluent-plugin-config-formatter type arguments.
|
126
135
|
alias_method :new_service_discovery, :new_sd
|
@@ -29,6 +29,9 @@ module Fluent
|
|
29
29
|
if @_event_emitter_lazy_init
|
30
30
|
@router = @primary_instance.router
|
31
31
|
end
|
32
|
+
if @router.respond_to?(:caller_plugin_id=)
|
33
|
+
@router.caller_plugin_id = self.plugin_id
|
34
|
+
end
|
32
35
|
@router
|
33
36
|
end
|
34
37
|
|
@@ -47,7 +50,11 @@ module Fluent
|
|
47
50
|
|
48
51
|
def event_emitter_router(label_name)
|
49
52
|
if label_name
|
50
|
-
|
53
|
+
if label_name == "@ROOT"
|
54
|
+
Engine.root_agent.event_router
|
55
|
+
else
|
56
|
+
Engine.root_agent.find_label(label_name).event_router
|
57
|
+
end
|
51
58
|
elsif self.respond_to?(:as_secondary) && self.as_secondary
|
52
59
|
if @primary_instance.has_router?
|
53
60
|
@_event_emitter_lazy_init = true
|
@@ -0,0 +1,129 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'forwardable'
|
18
|
+
|
19
|
+
require 'fluent/plugin'
|
20
|
+
require 'fluent/plugin/metrics'
|
21
|
+
require 'fluent/plugin_helper/timer'
|
22
|
+
require 'fluent/config/element'
|
23
|
+
require 'fluent/configurable'
|
24
|
+
require 'fluent/system_config'
|
25
|
+
|
26
|
+
module Fluent
|
27
|
+
module PluginHelper
|
28
|
+
module Metrics
|
29
|
+
include Fluent::SystemConfig::Mixin
|
30
|
+
|
31
|
+
attr_reader :_metrics # For tests.
|
32
|
+
|
33
|
+
def initialize
|
34
|
+
super
|
35
|
+
@_metrics_started = false
|
36
|
+
@_metrics = {} # usage => metrics_state
|
37
|
+
end
|
38
|
+
|
39
|
+
def configure(conf)
|
40
|
+
super
|
41
|
+
|
42
|
+
@plugin_type_or_id = if self.plugin_id_configured?
|
43
|
+
self.plugin_id
|
44
|
+
else
|
45
|
+
if type = (conf["@type"] || conf["type"])
|
46
|
+
"#{type}.#{self.plugin_id}"
|
47
|
+
else
|
48
|
+
"#{self.class.to_s.split("::").last.downcase}.#{self.plugin_id}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def metrics_create(namespace: "fluentd", subsystem: "metrics", name:, help_text:, labels: {}, prefer_gauge: false)
|
54
|
+
metrics = if system_config.metrics
|
55
|
+
Fluent::Plugin.new_metrics(system_config.metrics[:@type], parent: self)
|
56
|
+
else
|
57
|
+
Fluent::Plugin.new_metrics(Fluent::Plugin::Metrics::DEFAULT_TYPE, parent: self)
|
58
|
+
end
|
59
|
+
config = if system_config.metrics
|
60
|
+
system_config.metrics.corresponding_config_element
|
61
|
+
else
|
62
|
+
Fluent::Config::Element.new('metrics', '', {'@type' => Fluent::Plugin::Metrics::DEFAULT_TYPE}, [])
|
63
|
+
end
|
64
|
+
metrics.use_gauge_metric = prefer_gauge
|
65
|
+
metrics.configure(config)
|
66
|
+
# For multi workers environment, cmetrics should be distinguish with static labels.
|
67
|
+
if Fluent::Engine.system_config.workers > 1
|
68
|
+
labels.merge!(worker_id: fluentd_worker_id.to_s)
|
69
|
+
end
|
70
|
+
labels.merge!(plugin: @plugin_type_or_id)
|
71
|
+
metrics.create(namespace: namespace, subsystem: subsystem, name: name, help_text: help_text, labels: labels)
|
72
|
+
|
73
|
+
@_metrics["#{@plugin_type_or_id}_#{namespace}_#{subsystem}_#{name}"] = metrics
|
74
|
+
|
75
|
+
metrics
|
76
|
+
end
|
77
|
+
|
78
|
+
def metrics_operate(method_name, &block)
|
79
|
+
@_metrics.each_pair do |key, m|
|
80
|
+
begin
|
81
|
+
block.call(s) if block_given?
|
82
|
+
m.__send__(method_name)
|
83
|
+
rescue => e
|
84
|
+
log.error "unexpected error while #{method_name}", key: key, metrics: m, error: e
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def start
|
90
|
+
super
|
91
|
+
|
92
|
+
metrics_operate(:start)
|
93
|
+
@_metrics_started = true
|
94
|
+
end
|
95
|
+
|
96
|
+
def stop
|
97
|
+
super
|
98
|
+
# timer stops automatically in super
|
99
|
+
metrics_operate(:stop)
|
100
|
+
end
|
101
|
+
|
102
|
+
def before_shutdown
|
103
|
+
metrics_operate(:before_shutdown)
|
104
|
+
super
|
105
|
+
end
|
106
|
+
|
107
|
+
def shutdown
|
108
|
+
metrics_operate(:shutdown)
|
109
|
+
super
|
110
|
+
end
|
111
|
+
|
112
|
+
def after_shutdown
|
113
|
+
metrics_operate(:after_shutdown)
|
114
|
+
super
|
115
|
+
end
|
116
|
+
|
117
|
+
def close
|
118
|
+
metrics_operate(:close)
|
119
|
+
super
|
120
|
+
end
|
121
|
+
|
122
|
+
def terminate
|
123
|
+
metrics_operate(:terminate)
|
124
|
+
@_metrics = {}
|
125
|
+
super
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -709,13 +709,15 @@ module Fluent
|
|
709
709
|
return true
|
710
710
|
end
|
711
711
|
rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH => e
|
712
|
+
peeraddr = (@_handler_socket.peeraddr rescue PEERADDR_FAILED)
|
712
713
|
@log.trace "unexpected error before accepting TLS connection",
|
713
|
-
|
714
|
+
addr: peeraddr[3], host: peeraddr[2], port: peeraddr[1], error: e
|
714
715
|
close rescue nil
|
715
716
|
rescue OpenSSL::SSL::SSLError => e
|
717
|
+
peeraddr = (@_handler_socket.peeraddr rescue PEERADDR_FAILED)
|
716
718
|
# Use same log level as on_readable
|
717
719
|
@log.warn "unexpected error before accepting TLS connection by OpenSSL",
|
718
|
-
|
720
|
+
addr: peeraddr[3], host: peeraddr[2], port: peeraddr[1], error: e
|
719
721
|
close rescue nil
|
720
722
|
end
|
721
723
|
|
data/lib/fluent/plugin_helper.rb
CHANGED
@@ -32,6 +32,7 @@ require 'fluent/plugin_helper/retry_state'
|
|
32
32
|
require 'fluent/plugin_helper/record_accessor'
|
33
33
|
require 'fluent/plugin_helper/compat_parameters'
|
34
34
|
require 'fluent/plugin_helper/service_discovery'
|
35
|
+
require 'fluent/plugin_helper/metrics'
|
35
36
|
|
36
37
|
module Fluent
|
37
38
|
module PluginHelper
|
data/lib/fluent/root_agent.rb
CHANGED
@@ -55,9 +55,11 @@ module Fluent
|
|
55
55
|
@suppress_emit_error_log_interval = 0
|
56
56
|
@next_emit_error_log_time = nil
|
57
57
|
@without_source = false
|
58
|
+
@enable_input_metrics = false
|
58
59
|
|
59
60
|
suppress_interval(system_config.emit_error_log_interval) unless system_config.emit_error_log_interval.nil?
|
60
61
|
@without_source = system_config.without_source unless system_config.without_source.nil?
|
62
|
+
@enable_input_metrics = !!system_config.enable_input_metrics
|
61
63
|
end
|
62
64
|
|
63
65
|
attr_reader :inputs
|
@@ -131,6 +133,7 @@ module Fluent
|
|
131
133
|
end
|
132
134
|
name = e.arg
|
133
135
|
raise ConfigError, "Missing symbol argument on <label> directive" if name.empty?
|
136
|
+
raise ConfigError, "@ROOT for <label> is not permitted, reserved for getting root router" if name == '@ROOT'
|
134
137
|
|
135
138
|
if name == ERROR_LABEL
|
136
139
|
error_label_config = e
|
@@ -315,6 +318,9 @@ module Fluent
|
|
315
318
|
# See also 'fluentd/plugin/input.rb'
|
316
319
|
input.context_router = @event_router
|
317
320
|
input.configure(conf)
|
321
|
+
if @enable_input_metrics
|
322
|
+
@event_router.add_metric_callbacks(input.plugin_id, Proc.new {|es| input.metric_callback(es) })
|
323
|
+
end
|
318
324
|
@inputs << input
|
319
325
|
|
320
326
|
input
|
data/lib/fluent/supervisor.rb
CHANGED
@@ -570,6 +570,8 @@ module Fluent
|
|
570
570
|
suppress_repeated_stacktrace: true,
|
571
571
|
ignore_repeated_log_interval: nil,
|
572
572
|
without_source: nil,
|
573
|
+
enable_input_metrics: nil,
|
574
|
+
enable_size_metrics: nil,
|
573
575
|
use_v1_config: true,
|
574
576
|
strict_config_value: nil,
|
575
577
|
supervise: true,
|
data/lib/fluent/system_config.rb
CHANGED
@@ -27,7 +27,8 @@ module Fluent
|
|
27
27
|
:log_event_verbose, :ignore_repeated_log_interval, :ignore_same_log_interval,
|
28
28
|
:without_source, :rpc_endpoint, :enable_get_dump, :process_name,
|
29
29
|
:file_permission, :dir_permission, :counter_server, :counter_client,
|
30
|
-
:strict_config_value, :enable_msgpack_time_support, :disable_shared_socket
|
30
|
+
:strict_config_value, :enable_msgpack_time_support, :disable_shared_socket,
|
31
|
+
:metrics, :enable_input_metrics, :enable_size_metrics
|
31
32
|
]
|
32
33
|
|
33
34
|
config_param :workers, :integer, default: 1
|
@@ -46,6 +47,8 @@ module Fluent
|
|
46
47
|
config_param :strict_config_value, :bool, default: nil
|
47
48
|
config_param :enable_msgpack_time_support, :bool, default: nil
|
48
49
|
config_param :disable_shared_socket, :bool, default: nil
|
50
|
+
config_param :enable_input_metrics, :bool, default: nil
|
51
|
+
config_param :enable_size_metrics, :bool, default: nil
|
49
52
|
config_param :file_permission, default: nil do |v|
|
50
53
|
v.to_i(8)
|
51
54
|
end
|
@@ -93,6 +96,11 @@ module Fluent
|
|
93
96
|
config_param :timeout, :time, default: nil
|
94
97
|
end
|
95
98
|
|
99
|
+
config_section :metrics, multi: false do
|
100
|
+
config_param :@type, :string, default: "local"
|
101
|
+
config_param :labels, :hash, default: {}
|
102
|
+
end
|
103
|
+
|
96
104
|
def self.create(conf, strict_config_value=false)
|
97
105
|
systems = conf.elements(name: 'system')
|
98
106
|
return SystemConfig.new if systems.empty?
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/test/driver/base_owned'
|
18
|
+
|
19
|
+
module Fluent
|
20
|
+
module Test
|
21
|
+
module Driver
|
22
|
+
class Storage < BaseOwned
|
23
|
+
def initialize(klass, **kwargs, &block)
|
24
|
+
super
|
25
|
+
@section_name = "storage"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/fluent/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
<%= preamble %>
|
2
|
+
|
3
|
+
require "fluent/plugin/storage"
|
4
|
+
|
5
|
+
module Fluent
|
6
|
+
module Plugin
|
7
|
+
class <%= class_name %> < Fluent::Plugin::Storage
|
8
|
+
Fluent::Plugin.register_storage("<%= plugin_name %>", self)
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure(conf)
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def load
|
19
|
+
end
|
20
|
+
|
21
|
+
def save
|
22
|
+
end
|
23
|
+
|
24
|
+
def get(key)
|
25
|
+
end
|
26
|
+
|
27
|
+
def fetch(key, defval)
|
28
|
+
end
|
29
|
+
|
30
|
+
def put(key, value)
|
31
|
+
end
|
32
|
+
|
33
|
+
def delete(key)
|
34
|
+
end
|
35
|
+
|
36
|
+
def update(key, &block)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "helper"
|
2
|
+
require "fluent/plugin/<%= plugin_filename %>"
|
3
|
+
|
4
|
+
class <%= class_name %>Test < Test::Unit::TestCase
|
5
|
+
setup do
|
6
|
+
Fluent::Test.setup
|
7
|
+
end
|
8
|
+
|
9
|
+
test "failure" do
|
10
|
+
flunk
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def create_driver(conf)
|
16
|
+
Fluent::Test::Driver::Storage.new(Fluent::Plugin::<%= class_name %>).configure(conf)
|
17
|
+
end
|
18
|
+
end
|
data/test/command/test_cat.rb
CHANGED
@@ -18,20 +18,23 @@ class TestFluentCat < ::Test::Unit::TestCase
|
|
18
18
|
@primary = create_primary
|
19
19
|
metadata = @primary.buffer.new_metadata
|
20
20
|
@chunk = create_chunk(@primary, metadata, @es)
|
21
|
+
@port = unused_port
|
21
22
|
end
|
22
23
|
|
23
24
|
def teardown
|
24
25
|
FileUtils.rm_rf(TMP_DIR)
|
26
|
+
@port = nil
|
25
27
|
end
|
26
28
|
|
27
29
|
TMP_DIR = File.expand_path(File.dirname(__FILE__) + "/../tmp/command/fluent_cat#{ENV['TEST_ENV_NUMBER']}")
|
28
30
|
FLUENT_CAT_COMMAND = File.expand_path(File.dirname(__FILE__) + "/../../bin/fluent-cat")
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
def config
|
33
|
+
%[
|
34
|
+
port #{@port}
|
35
|
+
bind 127.0.0.1
|
36
|
+
]
|
37
|
+
end
|
35
38
|
|
36
39
|
SECONDARY_CONFIG = %[
|
37
40
|
directory #{TMP_DIR}
|
@@ -41,7 +44,7 @@ class TestFluentCat < ::Test::Unit::TestCase
|
|
41
44
|
def write(chunk); end
|
42
45
|
end
|
43
46
|
|
44
|
-
def create_driver(conf=
|
47
|
+
def create_driver(conf=config)
|
45
48
|
Fluent::Test::Driver::Input.new(Fluent::Plugin::ForwardInput).configure(conf)
|
46
49
|
end
|
47
50
|
|
@@ -66,7 +69,7 @@ class TestFluentCat < ::Test::Unit::TestCase
|
|
66
69
|
def test_cat_json
|
67
70
|
d = create_driver
|
68
71
|
d.run(expect_records: 1) do
|
69
|
-
Open3.pipeline_w("ruby #{FLUENT_CAT_COMMAND} --port #{
|
72
|
+
Open3.pipeline_w("ruby #{FLUENT_CAT_COMMAND} --port #{@port} json") do |stdin|
|
70
73
|
stdin.puts('{"key":"value"}')
|
71
74
|
stdin.close
|
72
75
|
end
|
@@ -83,7 +86,7 @@ class TestFluentCat < ::Test::Unit::TestCase
|
|
83
86
|
path = d.instance.write(@chunk)
|
84
87
|
d = create_driver
|
85
88
|
d.run(expect_records: 1) do
|
86
|
-
Open3.pipeline_w("ruby #{FLUENT_CAT_COMMAND} --port #{
|
89
|
+
Open3.pipeline_w("ruby #{FLUENT_CAT_COMMAND} --port #{@port} --format msgpack secondary") do |stdin|
|
87
90
|
stdin.write(File.read(path))
|
88
91
|
stdin.close
|
89
92
|
end
|