Skip to content

Commit

Permalink
Merge pull request #2881 from ganmacs/add-test-suit
Browse files Browse the repository at this point in the history
test: skip if error is occured
  • Loading branch information
ganmacs authored Mar 13, 2020
2 parents 0bfde48 + b6fb848 commit eb9c49e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/fluent/plugin/sd_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def refresh_file(queue)
fetch_server_info
rescue => e
@log.error("sd_file: #{e}")
return
end

if s.nil?
Expand Down
17 changes: 17 additions & 0 deletions test/plugin/test_sd_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,23 @@ def create_tmp_config(path, body)
assert_empty queue
end

test 'Skip if error is occured' do
@sd_file.extend(TestStatEventHelperWrapper)

create_tmp_config('config.json', JSON.generate([{ port: 1233, host: '127.0.0.1' }]))
@sd_file.configure(config_element('service_discovery', '', { 'path' => File.join(@dir, 'config.yml') }))
queue = []

FileUtils.rm_r(File.join(@dir, 'tmp', 'config.json'))
mock.proxy(@sd_file).refresh_file(queue).twice

@sd_file.start(queue)
assert_empty queue

@sd_file.resume
assert_empty queue
end

test 'if service is updated, service_in and service_out event happen' do
@sd_file.extend(TestStatEventHelperWrapper)

Expand Down

0 comments on commit eb9c49e

Please sign in to comment.