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