Skip to content

Commit

Permalink
Merge pull request #890 from okkez/suppress-warnings-step2
Browse files Browse the repository at this point in the history
Suppress warnings step 2
  • Loading branch information
tagomoris committed Apr 19, 2016
2 parents 20e6b44 + 7ba6f41 commit 9f651fa
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 38 deletions.
1 change: 0 additions & 1 deletion lib/fluent/config/configure_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ def config_section(name, *args, &block)
end
name = name.to_sym

opts = {}
unless args.empty? || args.size == 1 && args.first.is_a?(Hash)
raise ArgumentError, "#{self.name}: unknown config_section arguments: #{args.inspect}"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def initialize
super
@paths = []
@tails = {}
@pf_file = nil
@pf = nil
end

desc 'The paths to read. Multiple paths can be specified, separated by comma.'
Expand Down Expand Up @@ -695,8 +697,6 @@ def self.parse(file)
m = /^([^\t]+)\t([0-9a-fA-F]+)\t([0-9a-fA-F]+)/.match(line)
next unless m
path = m[1]
pos = m[2].to_i(16)
ino = m[3].to_i(16)
seek = file.pos - line.bytesize + path.bytesize + 1
map[path] = FilePositionEntry.new(file, seek)
}
Expand Down
6 changes: 3 additions & 3 deletions lib/fluent/plugin/out_exec_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ def configure(conf)

super

if localtime = conf['localtime']
if conf['localtime']
@localtime = true
elsif utc = conf['utc']
elsif conf['utc']
@localtime = false
end

Expand Down Expand Up @@ -353,7 +353,7 @@ def run
@log.error "exec_filter thread unexpectedly failed with an error.", command: @command, error: $!.to_s
@log.warn_backtrace $!.backtrace
ensure
pid, stat = Process.waitpid2(@pid)
_pid, stat = Process.waitpid2(@pid)
unless @finished
@log.error "exec_filter process unexpectedly exited.", command: @command, ecode: stat.to_i
unless @respawns == 0
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin_helper/timer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def timer_execute(title, interval, repeat: true, &block)
end

def timer_running?
@_timer_running
defined?(@_timer_running) && @_timer_running
end

def initialize
Expand Down
32 changes: 16 additions & 16 deletions test/plugin/test_buf_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_init
chunk = filebufferchunk('key2', 'init2', symlink: symlink_path)
assert_equal 'key2', chunk.key
assert_equal 'init2', chunk.unique_id
assert File.exists?(symlink_path) && File.symlink?(symlink_path)
assert File.exist?(symlink_path) && File.symlink?(symlink_path)

chunk.close # unlink

Expand Down Expand Up @@ -129,7 +129,7 @@ def test_append_close_purge
assert_equal 38, chunk.size
chunk.close

assert File.exists?(bufpath('append1'))
assert File.exist?(bufpath('append1'))

chunk = filebufferchunk('a1', 'append1', mode: 'r')
test_data = test_data1.force_encoding('ASCII-8BIT') + test_data2.force_encoding('ASCII-8BIT')
Expand All @@ -142,7 +142,7 @@ def test_append_close_purge

chunk.purge

assert !(File.exists?(bufpath('append1')))
assert !(File.exist?(bufpath('append1')))
end

def test_empty_chunk_key # for BufferedOutput#emit
Expand Down Expand Up @@ -251,13 +251,13 @@ def test_mv

assert_equal bufpath('move1'), chunk.path

assert File.exists?( bufpath( 'move1' ) )
assert !(File.exists?( bufpath( 'move2' ) ))
assert File.exist?( bufpath( 'move1' ) )
assert !(File.exist?( bufpath( 'move2' ) ))

chunk.mv(bufpath('move2'))

assert !(File.exists?( bufpath( 'move1' ) ))
assert File.exists?( bufpath( 'move2' ) )
assert !(File.exist?( bufpath( 'move1' ) ))
assert File.exist?( bufpath( 'move2' ) )

assert_equal bufpath('move2'), chunk.path

Expand Down Expand Up @@ -373,9 +373,9 @@ def test_start_makes_parent_directories
buf = Fluent::FileBuffer.new
buf.configure({'buffer_path' => bufpath('start/base.*.log')})
parent_dirname = File.dirname(buf.instance_eval{ @buffer_path_prefix })
assert !(Dir.exists?(parent_dirname))
assert !(Dir.exist?(parent_dirname))
buf.start
assert Dir.exists?(parent_dirname)
assert Dir.exist?(parent_dirname)
end

def test_new_chunk
Expand All @@ -386,7 +386,7 @@ def test_new_chunk

chunk = buf.new_chunk('key1')
assert chunk
assert File.exists?(chunk.path)
assert File.exist?(chunk.path)
assert chunk.path =~ /\A#{prefix}[-_.a-zA-Z0-9\%]+\.b[0-9a-f]+#{suffix}\Z/, "path from new_chunk must be a 'b' buffer chunk"
chunk.close
end
Expand Down Expand Up @@ -420,14 +420,14 @@ def test_enqueue_moves_chunk_from_b_to_q

assert chunk
old_path = chunk.path.dup
assert File.exists?(chunk.path)
assert File.exist?(chunk.path)
assert chunk.path =~ /\A#{prefix}[-_.a-zA-Z0-9\%]+\.b[0-9a-f]+#{suffix}\Z/, "path from new_chunk must be a 'b' buffer chunk"

buf.enqueue(chunk)

assert chunk
assert File.exists?(chunk.path)
assert !(File.exists?(old_path))
assert File.exist?(chunk.path)
assert !(File.exist?(old_path))
assert chunk.path =~ /\A#{prefix}[-_.a-zA-Z0-9\%]+\.q[0-9a-f]+#{suffix}\Z/, "enqueued chunk's path must be a 'q' buffer chunk"

data = chunk.read
Expand All @@ -448,15 +448,15 @@ def test_enqueue_chunk_with_empty_key

assert chunk
old_path = chunk.path.dup
assert File.exists?(chunk.path)
assert File.exist?(chunk.path)
# chunk key is empty
assert chunk.path =~ /\A#{prefix}\.b[0-9a-f]+#{suffix}\Z/, "path from new_chunk must be a 'b' buffer chunk"

buf.enqueue(chunk)

assert chunk
assert File.exists?(chunk.path)
assert !(File.exists?(old_path))
assert File.exist?(chunk.path)
assert !(File.exist?(old_path))
# chunk key is empty
assert chunk.path =~ /\A#{prefix}\.q[0-9a-f]+#{suffix}\Z/, "enqueued chunk's path must be a 'q' buffer chunk"

Expand Down
4 changes: 2 additions & 2 deletions test/plugin/test_out_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,12 @@ def test_write_with_symlink
es = Fluent::OneEventStream.new(time, {"a"=>1})
d.instance.emit('tag', es, Fluent::NullOutputChain.instance)

assert File.exists?(symlink_path)
assert File.exist?(symlink_path)
assert File.symlink?(symlink_path)

d.instance.enqueue_buffer

assert !File.exists?(symlink_path)
assert !File.exist?(symlink_path)
assert File.symlink?(symlink_path)
ensure
d.instance.shutdown
Expand Down
16 changes: 3 additions & 13 deletions test/plugin_helper/test_child_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def configure(conf)

test 'can execute external command at just once, which can handle both of read and write' do
m = Mutex.new
t1 = Time.now
ary = []
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
ran = false
Expand Down Expand Up @@ -125,7 +124,6 @@ def configure(conf)

test 'can execute external command at just once, which can handle all of read, write and stderr' do
m = Mutex.new
t1 = Time.now
ary1 = []
ary2 = []
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
Expand Down Expand Up @@ -162,7 +160,6 @@ def configure(conf)

test 'can execute external command at just once, which can handle both of write and read (with stderr)' do
m = Mutex.new
t1 = Time.now
ary = []
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
ran = false
Expand Down Expand Up @@ -197,7 +194,6 @@ def configure(conf)

test 'can execute external command at just once, which runs forever' do
m = Mutex.new
t1 = Time.now
ary = []
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
ran = false
Expand Down Expand Up @@ -233,7 +229,6 @@ def configure(conf)
# In windows environment, child_process try KILL at first (because there's no SIGTERM)
test 'can execute external command just once, and can terminate it forcedly when shutdown/terminate even if it ignore SIGTERM' do
m = Mutex.new
t1 = Time.now
ary = []
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
ran = false
Expand Down Expand Up @@ -348,7 +343,6 @@ def configure(conf)

test 'execute external processes only for writing' do
m = Mutex.new
ary = []
unreadable = false
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
ran = false
Expand Down Expand Up @@ -376,7 +370,6 @@ def configure(conf)

test 'execute external processes only for reading' do
m = Mutex.new
ary = []
unwritable = false
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
ran = false
Expand All @@ -388,7 +381,7 @@ def configure(conf)
rescue IOError
unwritable = true
end
data = io.readline
_data = io.readline
m.unlock
end
sleep TEST_WAIT_INTERVAL_FOR_BLOCK_RUNNING until m.locked? || ran
Expand Down Expand Up @@ -442,7 +435,6 @@ def configure(conf)

test 'can convert encodings from ascii-8bit to utf-8' do
m = Mutex.new
encodings = []
str = nil
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
ran = false
Expand All @@ -464,7 +456,6 @@ def configure(conf)

test 'can scrub characters without exceptions' do
m = Mutex.new
encodings = []
str = nil
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
ran = false
Expand All @@ -486,7 +477,6 @@ def configure(conf)

test 'can scrub characters without exceptions and replace specified chars' do
m = Mutex.new
encodings = []
str = nil
Timeout.timeout(TEST_DEADLOCK_TIMEOUT) do
ran = false
Expand All @@ -509,7 +499,7 @@ def configure(conf)
unless Fluent.windows?
test 'can specify subprocess name' do
io = IO.popen([["cat", "caaaaaaaaaaat"], '-'])
process_naming_enabled = (open("|ps"){|io| io.readlines }.select{|line| line.include?("caaaaaaaaaaat") }.size > 0)
process_naming_enabled = (open("|ps"){|_io| _io.readlines }.select{|line| line.include?("caaaaaaaaaaat") }.size > 0)
Process.kill(:TERM, io.pid) rescue nil
io.close rescue nil

Expand All @@ -526,7 +516,7 @@ def configure(conf)
m.lock
ran = true
pids << @d.child_process_id
proc_lines += open("|ps"){|io| io.readlines }
proc_lines += open("|ps"){|_io| _io.readlines }
m.unlock
readio.read
end
Expand Down

0 comments on commit 9f651fa

Please sign in to comment.