Skip to content

Commit

Permalink
Use consistent name with other plugins
Browse files Browse the repository at this point in the history
Signed-off-by: Yuta Iwama <[email protected]>
  • Loading branch information
ganmacs committed Aug 7, 2019
1 parent d1294ee commit 57d0ef0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/fluent/plugin/sd_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

module Fluent
module Plugin
class SdFile < ServiceDiscovery
class FileServiceDiscovery < ServiceDiscovery
Plugin.register_sd('file', self)

DEFAULT_FILE_TYPE = :yaml
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/sd_static.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

module Fluent
module Plugin
class SdStatic < ServiceDiscovery
class StaticServiceDiscovery < ServiceDiscovery
Plugin.register_sd('static', self)

LISTEN_PORT = 24224
Expand Down
18 changes: 9 additions & 9 deletions test/plugin/test_sd_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'fileutils'
require 'json'

class SdFileTest < ::Test::Unit::TestCase
class FileServiceDiscoveryTest < ::Test::Unit::TestCase
setup do
@dir = File.expand_path('data/sd_file', __dir__)
FileUtils.mkdir_p(File.join(@dir, 'tmp'))
Expand All @@ -15,43 +15,43 @@ class SdFileTest < ::Test::Unit::TestCase

sub_test_case 'configure' do
test 'load yml' do
sdf = Fluent::Plugin::SdFile.new
sdf = Fluent::Plugin::FileServiceDiscovery.new
sdf.configure(config_element('service_discovery', '', { 'path' => File.join(@dir, 'config.yml') }))
assert_equal Fluent::Plugin::ServiceDiscovery::Service.new(:file, '127.0.0.1', 24224, 'test1', 1, false, 'user1', 'pass1', 'key1'), sdf.services[0]
assert_equal Fluent::Plugin::ServiceDiscovery::Service.new(:file, '127.0.0.1', 24225, nil, 1), sdf.services[1]
end

test 'load yaml' do
sdf = Fluent::Plugin::SdFile.new
sdf = Fluent::Plugin::FileServiceDiscovery.new
sdf.configure(config_element('service_discovery', '', { 'path' => File.join(@dir, 'config.yaml') }))
assert_equal Fluent::Plugin::ServiceDiscovery::Service.new(:file, '127.0.0.1', 24224, 'test1', 1, false, 'user1', 'pass1', 'key1'), sdf.services[0]
assert_equal Fluent::Plugin::ServiceDiscovery::Service.new(:file, '127.0.0.1', 24225, nil, 1), sdf.services[1]
end

test 'load json' do
sdf = Fluent::Plugin::SdFile.new
sdf = Fluent::Plugin::FileServiceDiscovery.new
sdf.configure(config_element('service_discovery', '', { 'path' => File.join(@dir, 'config.json') }))
assert_equal Fluent::Plugin::ServiceDiscovery::Service.new(:file, '127.0.0.1', 24224, 'test1', 1, false, 'user1', 'pass1', 'key1'), sdf.services[0]
assert_equal Fluent::Plugin::ServiceDiscovery::Service.new(:file, '127.0.0.1', 24225, nil, 1), sdf.services[1]
end

test 'regard as yaml if ext is not givened' do
sdf = Fluent::Plugin::SdFile.new
sdf = Fluent::Plugin::FileServiceDiscovery.new
sdf.configure(config_element('service_discovery', '', { 'path' => File.join(@dir, 'config') }))
assert_equal Fluent::Plugin::ServiceDiscovery::Service.new(:file, '127.0.0.1', 24224, 'test1', 1, false, 'user1', 'pass1', 'key1'), sdf.services[0]
assert_equal Fluent::Plugin::ServiceDiscovery::Service.new(:file, '127.0.0.1', 24225, nil, 1), sdf.services[1]
end

test 'raise an error if config has error' do
sdf = Fluent::Plugin::SdFile.new
sdf = Fluent::Plugin::FileServiceDiscovery.new
e = assert_raise Fluent::ConfigError do
sdf.configure(config_element('service_discovery', '', { 'path' => File.join(@dir, 'invalid_config.yaml') }))
end
assert_match(/path=/, e.message)
end

test 'raise an error if config file does not exist' do
sdf = Fluent::Plugin::SdFile.new
sdf = Fluent::Plugin::FileServiceDiscovery.new
e = assert_raise Fluent::ConfigError do
sdf.configure(config_element('service_discovery', '', { 'path' => File.join(@dir, 'invalid_not_found.json') }))
end
Expand All @@ -63,7 +63,7 @@ class SdFileTest < ::Test::Unit::TestCase
module TestStatEventHelperWrapper
# easy to control statsevent
def event_loop_attach(watcher)
unless watcher.is_a?(Fluent::Plugin::SdFile::StatWatcher)
unless watcher.is_a?(Fluent::Plugin::FileServiceDiscovery::StatWatcher)
super
return
end
Expand Down Expand Up @@ -103,7 +103,7 @@ def create_tmp_config(path, body)
end

setup do
sdf = Fluent::Plugin::SdFile.new
sdf = Fluent::Plugin::FileServiceDiscovery.new
@sd_file = sdf
end

Expand Down

0 comments on commit 57d0ef0

Please sign in to comment.