Skip to content

Commit

Permalink
test_in_tail: Move group config tests to separated sub_test_case
Browse files Browse the repository at this point in the history
Signed-off-by: Takuro Ashie <[email protected]>
  • Loading branch information
ashie committed May 15, 2022
1 parent dc680be commit 07ef562
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions test/plugin/test_in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,50 +177,6 @@ def create_driver(conf = SINGLE_LINE_CONFIG, use_common_conf = true)
end

sub_test_case "configure" do
test "<rule> required" do
conf = create_group_directive('.', '1m') + SINGLE_LINE_CONFIG
assert_raise(Fluent::ConfigError) do
create_driver(conf)
end
end

test "valid configuration" do
rule1 = create_rule_directive({
"namespace"=> "/namespace-a/",
"podname"=> "/podname-[b|c]/"
}, 100)
rule2 = create_rule_directive({
"namespace"=> "/namespace-[d|e]/",
"podname"=> "/podname-f/",
}, 50)
rule3 = create_rule_directive({
"podname"=> "/podname-g/",
}, -1)
rule4 = create_rule_directive({
"namespace"=> "/namespace-h/",
}, 0)

conf = create_group_directive(TAILING_GROUP_PATTERN, '1m', rule1, rule2, rule3, rule4) + SINGLE_LINE_CONFIG
assert_nothing_raised do
create_driver(conf)
end
end

test "limit should be greater than DEFAULT_LIMIT (-1)" do
rule1 = create_rule_directive({
"namespace"=> "/namespace-a/",
"podname"=> "/podname-[b|c]/",
}, -100)
rule2 = create_rule_directive({
"namespace"=> "/namespace-[d|e]/",
"podname"=> "/podname-f/",
}, 50)
conf = create_group_directive(TAILING_GROUP_PATTERN, '1m', rule1, rule2) + SINGLE_LINE_CONFIG
assert_raise(RuntimeError) do
create_driver(conf)
end
end

test "plain single line" do
d = create_driver
assert_equal ["#{TMP_DIR}/tail.txt"], d.instance.paths
Expand Down Expand Up @@ -334,8 +290,53 @@ def create_driver(conf = SINGLE_LINE_CONFIG, use_common_conf = true)
end
end

sub_test_case "group rules line limit resolution" do
sub_test_case "configure group" do
test "<rule> required" do
conf = create_group_directive('.', '1m') + SINGLE_LINE_CONFIG
assert_raise(Fluent::ConfigError) do
create_driver(conf)
end
end

test "valid configuration" do
rule1 = create_rule_directive({
"namespace"=> "/namespace-a/",
"podname"=> "/podname-[b|c]/"
}, 100)
rule2 = create_rule_directive({
"namespace"=> "/namespace-[d|e]/",
"podname"=> "/podname-f/",
}, 50)
rule3 = create_rule_directive({
"podname"=> "/podname-g/",
}, -1)
rule4 = create_rule_directive({
"namespace"=> "/namespace-h/",
}, 0)

conf = create_group_directive(TAILING_GROUP_PATTERN, '1m', rule1, rule2, rule3, rule4) + SINGLE_LINE_CONFIG
assert_nothing_raised do
create_driver(conf)
end
end

test "limit should be greater than DEFAULT_LIMIT (-1)" do
rule1 = create_rule_directive({
"namespace"=> "/namespace-a/",
"podname"=> "/podname-[b|c]/",
}, -100)
rule2 = create_rule_directive({
"namespace"=> "/namespace-[d|e]/",
"podname"=> "/podname-f/",
}, 50)
conf = create_group_directive(TAILING_GROUP_PATTERN, '1m', rule1, rule2) + SINGLE_LINE_CONFIG
assert_raise(RuntimeError) do
create_driver(conf)
end
end
end

sub_test_case "group rules line limit resolution" do
test "valid" do
rule1 = create_rule_directive({
"namespace"=> "/namespace-a/",
Expand Down Expand Up @@ -385,7 +386,6 @@ def create_driver(conf = SINGLE_LINE_CONFIG, use_common_conf = true)
assert_equal(-1, instance.find_group({}).limit)
end
end

end

sub_test_case "files should be placed in groups" do
Expand Down

0 comments on commit 07ef562

Please sign in to comment.