Skip to content

Commit b41742e

Browse files
committed
tests: add processor_invalid.sh test for validating invalid processor handling
This test verifies Fluent Bit's behavior when configured with a non-existent processor. It checks that Fluent Bit properly fails to start and reports a relevant error message. Part of #10305
1 parent 31a8163 commit b41742e

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

tests/runtime_shell/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ set(UNIT_TESTS_SH
1414
in_syslog_uds_dgram_plaintext_expect.sh
1515
in_syslog_uds_stream_plaintext_expect.sh
1616
processor_conditional.sh
17+
processor_invalid.sh
1718
)
1819

1920
# Prepare list of unit tests
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/sh
2+
3+
# Setup environment if not already set
4+
if [ -z "$FLB_BIN" ]; then
5+
FLB_ROOT=${FLB_ROOT:-$(cd $(dirname $0)/../.. && pwd)}
6+
FLB_BIN=${FLB_BIN:-$FLB_ROOT/build/bin/fluent-bit}
7+
fi
8+
9+
echo "Using Fluent Bit at: $FLB_BIN"
10+
11+
# Create a temporary YAML config file
12+
cat > /tmp/processor_invalid.yaml << EOL
13+
service:
14+
log_level: debug
15+
flush: 1
16+
pipeline:
17+
inputs:
18+
- name: dummy
19+
dummy: '{"message": "test message"}'
20+
tag: test
21+
processors:
22+
logs:
23+
- name: non_existent_processor
24+
action: invalid
25+
26+
outputs:
27+
- name: stdout
28+
match: '*'
29+
EOL
30+
31+
echo "Running Fluent Bit with invalid processor YAML config..."
32+
echo "YAML Config:"
33+
cat /tmp/processor_invalid.yaml
34+
35+
# Redirect stdout and stderr to a file for analysis
36+
OUTPUT_FILE="/tmp/processor_invalid_output.txt"
37+
$FLB_BIN -c /tmp/processor_invalid.yaml -o stdout > $OUTPUT_FILE 2>&1
38+
39+
# Check exit code - we expect it to fail
40+
EXIT_CODE=$?
41+
echo "Fluent Bit exited with code: $EXIT_CODE"
42+
43+
# Show the output
44+
echo "Output file content:"
45+
cat $OUTPUT_FILE
46+
47+
# Check if the output contains an error related to invalid processor
48+
INVALID_PROCESSOR=$(grep -c "error creating processor 'non_existent_processor': plugin doesn't exist or failed to initialize" $OUTPUT_FILE || true)
49+
FAILED_INIT=$(grep -c "error initializing processor" $OUTPUT_FILE || true)
50+
51+
# Clean up
52+
echo "Cleaning up..."
53+
rm -f /tmp/processor_invalid.yaml
54+
rm -f $OUTPUT_FILE
55+
56+
# Check results - we expect Fluent Bit to fail (non-zero exit code)
57+
# and have an error message about the invalid processor
58+
if [ "$EXIT_CODE" -ne 0 ] && ([ "$INVALID_PROCESSOR" -gt 0 ] || [ "$FAILED_INIT" -gt 0 ]); then
59+
echo "Test passed: Fluent Bit failed with error about invalid processor"
60+
exit 0
61+
else
62+
echo "Test failed: Fluent Bit should fail when an invalid processor is configured"
63+
echo "Exit code: $EXIT_CODE (expected non-zero)"
64+
echo "Invalid processor message count: $INVALID_PROCESSOR (expected > 0)"
65+
echo "Failed init message count: $FAILED_INIT (expected > 0)"
66+
exit 1
67+
fi

0 commit comments

Comments
 (0)