Skip to content

Commit

Permalink
test: add rotation system config test case
Browse files Browse the repository at this point in the history
Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
  • Loading branch information
kenhys committed May 6, 2021
1 parent 536893f commit 83bbc8c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/config/test_system_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,23 @@ def parse_text(text)
sc.overwrite_variables(**s.for_system_config)
assert_equal(level, sc.log_level)
end

sub_test_case "log rotation" do
test "rotate without age" do
conf = parse_text(<<-EOS)
<system>
<log>
rotate_age 3
rotate_size 300
</log>
</system>
EOS
s = FakeSupervisor.new
sc = Fluent::SystemConfig.new(conf)
sc.overwrite_variables(**s.for_system_config)
assert_equal("3", sc.log.rotate_age)
assert_equal(300, sc.log.rotate_size)
end
end
end
end
29 changes: 29 additions & 0 deletions test/test_supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,35 @@ def test_logger_with_rotate_age_and_rotate_size(rotate_age)
assert_equal 10, $log.out.instance_variable_get(:@shift_size)
end

sub_test_case "system log rotation" do
def test_default_log_rotate_age
require "tempfile"
Tempfile.open do |file|
config =<<-EOS
<system>
<log>
rotate_age: 3
rotate_size: 300
</log>
</system>
EOS
file.puts(config)
file.flush
opts = Fluent::Supervisor.default_options.merge(
log_path: "#{TMP_DIR}/test.log", config_path: file.path
)
sv = Fluent::Supervisor.new(opts)

log = sv.instance_variable_get(:@log)
log.init(:standalone, 0)
logger = $log.instance_variable_get(:@logger)

assert_equal(3, logger.instance_variable_get(:@rotate_age))
assert_equal(300, logger.instance_variable_get(:@rotate_size))
end
end
end

def test_inline_config
omit 'this feature is deprecated. see https://github.com/fluent/fluentd/issues/2711'

Expand Down

0 comments on commit 83bbc8c

Please sign in to comment.