Skip to content

Commit 4e34f8c

Browse files
committed
test_supervisor: add test case when loaded all files with @include
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
1 parent d12af91 commit 4e34f8c

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

test/test_supervisor.rb

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,68 @@ def test_stop_parallel_old_supervisor_after_delay
12671267
$log.out.reset if $log&.out&.respond_to?(:reset)
12681268
end
12691269

1270+
test "do not load additional configuration when loaded all files with @include" do
1271+
write_config("#{@config_include_dir}/forward.conf", <<~EOF)
1272+
<match test>
1273+
@type forward
1274+
<server>
1275+
host 127.0.0.1
1276+
port 24224
1277+
</server>
1278+
</match>
1279+
EOF
1280+
write_config("#{@config_include_dir}/obsolete_plugins.conf", <<~EOF)
1281+
<source>
1282+
@type obsolete_plugins
1283+
</source>
1284+
EOF
1285+
1286+
write_config("#{@tmp_dir}/fluent.conf", <<~EOF)
1287+
<system>
1288+
config_include_dir #{@config_include_dir}
1289+
</system>
1290+
1291+
<match sample.*>
1292+
@type file
1293+
</match>
1294+
1295+
@include #{@config_include_dir}/*.conf
1296+
EOF
1297+
1298+
supervisor = Fluent::Supervisor.new({ config_path: "#{@tmp_dir}/fluent.conf" })
1299+
stub(supervisor).setup_global_logger { create_debug_dummy_logger }
1300+
1301+
supervisor.configure(supervisor: true)
1302+
elements = supervisor.instance_variable_get(:@conf).elements
1303+
assert_equal(4, elements.size)
1304+
1305+
assert_equal('system', elements[0].name)
1306+
assert_equal(@config_include_dir, elements[0]['config_include_dir'])
1307+
1308+
assert_equal('match', elements[1].name)
1309+
assert_equal('file', elements[1]['@type'])
1310+
1311+
assert_equal('match', elements[2].name)
1312+
assert_equal('forward', elements[2]['@type'])
1313+
1314+
assert_equal('source', elements[3].name)
1315+
assert_equal('obsolete_plugins', elements[3]['@type'])
1316+
1317+
# no additional load, all files were skipped
1318+
skipped_files = %W[
1319+
#{@config_include_dir}/forward.conf
1320+
#{@config_include_dir}/obsolete_plugins.conf
1321+
]
1322+
1323+
logs_line = $log.out.logs.join
1324+
skipped_files.each do |path|
1325+
assert { logs_line.include?("skip auto loading, it was already loaded path=\"#{path}\"") }
1326+
end
1327+
assert_not_match(/loading additional configuration file/, logs_line)
1328+
ensure
1329+
$log.out.reset if $log&.out&.respond_to?(:reset)
1330+
end
1331+
12701332
test "can load partial config loaded config_include_dir feature by even if already loaded" do
12711333
write_config("#{@config_include_dir}/system.conf", <<~EOF)
12721334
<system>

0 commit comments

Comments
 (0)