require_relative 'helper'
require 'fluent/event_router'
require 'fluent/system_config'
require 'timecop'
require_relative 'test_plugin_classes'
class RootAgentTest < ::Test::Unit::TestCase
include Fluent
include FluentTest
def test_initialize
ra = RootAgent.new(log: $log)
assert_equal 0, ra.instance_variable_get(:@suppress_emit_error_log_interval)
assert_nil ra.instance_variable_get(:@next_emit_error_log_time)
end
data(
'suppress interval' => [{'emit_error_log_interval' => 30}, {:@suppress_emit_error_log_interval => 30}],
'without source' => [{'without_source' => true}, {:@without_source => true}]
)
def test_initialize_with_opt(data)
opt, expected = data
ra = RootAgent.new(log: $log, system_config: SystemConfig.new(opt))
expected.each { |k, v|
assert_equal v, ra.instance_variable_get(k)
}
end
sub_test_case 'configure' do
setup do
@ra = RootAgent.new(log: $log)
stub(Engine).root_agent { @ra }
end
def configure_ra(conf_str)
conf = Config.parse(conf_str, "(test)", "(test_dir)", true)
@ra.configure(conf)
@ra
end
test 'empty' do
ra = configure_ra('')
assert_empty ra.inputs
assert_empty ra.labels
assert_empty ra.outputs
assert_empty ra.filters
assert_nil ra.context
assert_nil ra.error_collector
end
test 'raises configuration error for missing type of source' do
conf = <<-EOC
EOC
errmsg = "Missing '@type' parameter on