Skip to content

Commit

Permalink
Add a test to assert rotate size
Browse files Browse the repository at this point in the history
  • Loading branch information
ganmacs committed Sep 23, 2016
1 parent 2a91c51 commit 282d19d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/test_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,36 @@ def test_log_with_logdevio(expected)
end
end

def test_log_rotates_specifed_size_with_logdevio
with_timezone('utc') do
rotate_age = 2
rotate_size = 100
path = "#{TMP_DIR}/log-dev-io-#{rotate_size}-#{rotate_age}"

logdev = Fluent::LogDeviceIO.new(path, shift_age: rotate_age, shift_size: rotate_size)
logger = ServerEngine::DaemonLogger.new(logdev)
log = Fluent::Log.new(logger)

msg = 'a' * 101
log.info msg
assert_match msg, File.read(path)

# create log.0
msg2 = 'b' * 101
log.info msg2
c = File.read(path)
c0 = File.read(path + '.0')
assert_match msg2, c
assert_match msg, c0

# rotate
msg3 = 'c' * 101
log.info msg3
c = File.read(path)
c0 = File.read(path + '.0')
assert_match msg3, c
assert_match msg2, c0
end
end
end

Expand Down

0 comments on commit 282d19d

Please sign in to comment.