Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/fluent-bit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1436,10 +1436,17 @@ static int flb_main_run(int argc, char **argv)
#endif

if (config->dry_run == FLB_TRUE) {
fprintf(stderr, "configuration test is successful\n");
ret = flb_reload_property_check_all(config);

/* At this point config test is done, so clean up after ourselves */
flb_init_env();
flb_cf_destroy(cf_opts);
flb_destroy(ctx);

if (ret != 0) {
exit(EXIT_FAILURE);
}
fprintf(stderr, "configuration test is successful\n");
exit(EXIT_SUCCESS);
}

Expand Down
1 change: 1 addition & 0 deletions tests/runtime_shell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ configure_file(

set(UNIT_TESTS_SH
custom_calyptia.sh
dry_run_invalid_property.sh
in_dummy_expect.sh
in_tail_expect.sh
in_http_tls_expect.sh
Expand Down
64 changes: 64 additions & 0 deletions tests/runtime_shell/dry_run_invalid_property.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just confirm this actually runs in CI @ahayworth ?

Copy link
Author

@ahayworth ahayworth Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦 I did forget to add the test to the list to run, and added that here: 8180652

I'm not 100% sure which CI job would actually run those tests, though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approved to run CI tests. Waiting for the results.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - looks like CI has passed, but I am not sure which of the matrix jobs actually runs the test to double-check it.

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/sh

# Setup environment if not already set
if [ -z "$FLB_BIN" ]; then
FLB_ROOT=${FLB_ROOT:-$(cd $(dirname $0)/../.. && pwd)}
FLB_BIN=${FLB_BIN:-$FLB_ROOT/build/bin/fluent-bit}
fi

echo "Using Fluent Bit at: $FLB_BIN"

# Create a temporary YAML config file with an invalid property
cat > /tmp/dry_run_invalid_property.yaml << EOL
service:
log_level: debug
flush: 1
pipeline:
inputs:
- name: dummy
tag: test
invalid_property_that_does_not_exist: some_value
outputs:
- name: stdout
match: '*'
EOL

echo "Running Fluent Bit with --dry-run and invalid property config..."
echo "YAML Config:"
cat /tmp/dry_run_invalid_property.yaml

# Redirect stdout and stderr to a file for analysis
OUTPUT_FILE="/tmp/dry_run_invalid_property_output.txt"
$FLB_BIN --dry-run -c /tmp/dry_run_invalid_property.yaml > $OUTPUT_FILE 2>&1

# Check exit code - we expect it to fail
EXIT_CODE=$?
echo "Fluent Bit --dry-run exited with code: $EXIT_CODE"

# Show the output
echo "Output file content:"
cat $OUTPUT_FILE

# Check if the output contains an error about the unknown configuration property
UNKNOWN_PROPERTY=$(grep -c "unknown configuration property 'invalid_property_that_does_not_exist'" $OUTPUT_FILE || true)
RELOAD_ERROR=$(grep -c "check properties for input plugins is failed" $OUTPUT_FILE || true)

# Clean up
echo "Cleaning up..."
rm -f /tmp/dry_run_invalid_property.yaml
rm -f $OUTPUT_FILE

# Check results - we expect:
# 1. Fluent Bit to fail (non-zero exit code)
# 2. Error message about unknown configuration property
# 3. Error message from reload validation
if [ "$EXIT_CODE" -ne 0 ] && [ "$UNKNOWN_PROPERTY" -gt 0 ] && [ "$RELOAD_ERROR" -gt 0 ]; then
echo "Test passed: Fluent Bit --dry-run correctly detected invalid property and failed"
exit 0
else
echo "Test failed: Fluent Bit --dry-run should detect invalid properties and fail"
echo "Exit code: $EXIT_CODE (expected non-zero)"
echo "Unknown property message count: $UNKNOWN_PROPERTY (expected > 0)"
echo "Reload error message count: $RELOAD_ERROR (expected > 0)"
exit 1
fi
Loading