mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
parent
54ab10dfb0
commit
3b55273262
3 changed files with 24 additions and 3 deletions
|
@ -56,6 +56,7 @@ module LogStash; class Pipeline
|
|||
begin
|
||||
# There should be a better way to test this
|
||||
self.new(config_str, settings)
|
||||
true
|
||||
rescue => e
|
||||
e.message
|
||||
end
|
||||
|
|
|
@ -166,9 +166,9 @@ class LogStash::Runner < Clamp::Command
|
|||
end
|
||||
|
||||
if config_test?
|
||||
config_loader = LogStash::Config::Loader.new(@logger, config_test?)
|
||||
config_loader = LogStash::Config::Loader.new(@logger)
|
||||
config_str = config_loader.format_config(config_path, config_string)
|
||||
config_error = LogStash::Pipeline.config_valid?(config_str)
|
||||
config_error = LogStash::Pipeline.validate_config(config_str)
|
||||
if config_error == true
|
||||
@logger.terminal "Configuration OK"
|
||||
return 0
|
||||
|
@ -213,7 +213,7 @@ class LogStash::Runner < Clamp::Command
|
|||
show_short_help
|
||||
return 1
|
||||
rescue => e
|
||||
@logger.fatal I18n.t("oops", :error => e, :backtrace => e.backtrace)
|
||||
@logger.fatal(I18n.t("oops"), :error => e, :backtrace => e.backtrace)
|
||||
return 1
|
||||
ensure
|
||||
Stud::untrap("INT", sigint_id) unless sigint_id.nil?
|
||||
|
|
|
@ -95,6 +95,26 @@ describe LogStash::Runner do
|
|||
end
|
||||
end
|
||||
|
||||
context "--config-test" do
|
||||
subject { LogStash::Runner.new("") }
|
||||
let(:args) { ["-t", "-e", pipeline_string] }
|
||||
|
||||
context "with a good configuration" do
|
||||
let(:pipeline_string) { "input { } filter { } output { }" }
|
||||
it "should exit successfuly" do
|
||||
expect(channel).to receive(:terminal)
|
||||
expect(subject.run(args)).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context "with a bad configuration" do
|
||||
let(:pipeline_string) { "rlwekjhrewlqrkjh" }
|
||||
it "should fail by returning a bad exit code" do
|
||||
expect(channel).to receive(:fatal)
|
||||
expect(subject.run(args)).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe "pipeline settings" do
|
||||
let(:pipeline_string) { "input { stdin {} } output { stdout {} }" }
|
||||
let(:main_pipeline_settings) { { :pipeline_id => "main" } }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue