Sha256: a36caa58e40af179c9aca50b10b04d64e6bfdf414e46c790a8caa79c1672e22c

Contents?: true

Size: 1.59 KB

Versions: 5

Compression:

Stored size: 1.59 KB

Contents

require 'helper'
require 'fluent/configurable'
require 'fluent/config/element'
require 'fluent/config/section'
require 'fluent/supervisor'

module Fluent::Config
  class TestSystemConfig < ::Test::Unit::TestCase
    def parse_text(text)
      basepath = File.expand_path(File.dirname(__FILE__) + '/../../')
      Fluent::Config.parse(text, '(test)', basepath, true).elements.find { |e| e.name == 'system' }
    end

    test 'should not override default configurations when no parameters' do
      conf = parse_text(<<EOS)
<system>
</system>
EOS
      sc = Fluent::Supervisor::SystemConfig.new(conf)
      assert_nil(sc.log_level)
      assert_nil(sc.suppress_repeated_stacktrace)
      assert_nil(sc.emit_error_log_interval)
      assert_nil(sc.suppress_config_dump)
      assert_nil(sc.without_source)
      assert_empty(sc.to_opt)
    end

    {'log_level' => 'error', 'suppress_repeated_stacktrace' => true, 'emit_error_log_interval' => 60, 'suppress_config_dump' => true, 'without_source' => true}.each { |k, v|
      test "accepts #{k} parameter" do
        conf = parse_text(<<EOS)
<system>
  #{k} #{v}
</system>
EOS
        sc = Fluent::Supervisor::SystemConfig.new(conf)
        assert_not_nil(sc.instance_variable_get("@#{k}"))
        key = (k == 'emit_error_log_interval' ? :suppress_interval : k.to_sym)
        assert_include(sc.to_opt, key)
      end
    }

    {'foo' => 'bar', 'hoge' => 'fuga'}.each { |k, v|
      test "should not affect settable parameters with unknown #{k} parameter" do
        sc = Fluent::Supervisor::SystemConfig.new({k => v})
        assert_empty(sc.to_opt)
      end
    }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fluentd-0.10.57 test/config/test_system_config.rb
fluentd-0.12.0.pre.2 test/config/test_system_config.rb
fluentd-0.10.56 test/config/test_system_config.rb
fluentd-0.10.55 test/config/test_system_config.rb
fluentd-0.10.54 test/config/test_system_config.rb