Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in_tcp: in_udp: Add <parse> section checking. Fix #2266 #2267

Merged
merged 1 commit into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/fluent/plugin/in_tcp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ class TcpInput < Input

def configure(conf)
compat_parameters_convert(conf, :parser)
parser_config = conf.elements('parse').first
unless parser_config
raise Fluent::ConfigError, "<parse> section is required."
end
super
@_event_loop_blocking_timeout = @blocking_timeout
@source_hostname_key ||= @source_host_key if @source_host_key

@parser = parser_create
@parser = parser_create(conf: parser_config)
end

def multi_workers_ready?
Expand Down
6 changes: 5 additions & 1 deletion lib/fluent/plugin/in_udp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ class UdpInput < Input

def configure(conf)
compat_parameters_convert(conf, :parser)
parser_config = conf.elements('parse').first
unless parser_config
raise Fluent::ConfigError, "<parse> section is required."
end
super
@_event_loop_blocking_timeout = @blocking_timeout
@source_hostname_key ||= @source_host_key if @source_host_key
@message_length_limit = @body_size_limit if @body_size_limit

@parser = parser_create
@parser = parser_create(conf: parser_config)
end

def multi_workers_ready?
Expand Down
6 changes: 6 additions & 0 deletions test/plugin/test_in_tcp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ def create_tcp_socket(host, port, &block)
assert_equal "\n", d.instance.delimiter
end

test ' configure w/o parse section' do
assert_raise(Fluent::ConfigError.new("<parse> section is required.")) {
create_driver(BASE_CONFIG)
}
end

test_case_data = {
'none' => {
'format' => 'none',
Expand Down
6 changes: 6 additions & 0 deletions test/plugin/test_in_udp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ def create_udp_socket(host, port)
assert_equal nil, d.instance.receive_buffer_size
end

test ' configure w/o parse section' do
assert_raise(Fluent::ConfigError.new("<parse> section is required.")) {
create_driver(BASE_CONFIG)
}
end

data(
'ipv4' => [CONFIG, '127.0.0.1', :ipv4],
'ipv6' => [IPv6_CONFIG, '::1', :ipv6],
Expand Down