Skip to content
Merged
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
20 changes: 16 additions & 4 deletions qa/integration/specs/fatal_error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,19 @@
@logstash = @fixture.get_service("logstash")
end

after(:each) { @logstash.teardown }
after(:each) do
@logstash.teardown
FileUtils.rm_rf(temp_dir)
end

let(:timeout) { 90 } # seconds
let(:temp_dir) { Stud::Temporary.directory("logstash-error-test") }
let(:logs_dir) { File.join(temp_dir, "logs") }

# ensure PQ data is isolated.
# We crash before ACK-ing events, so we need to make sure we don't
# leave those un-ACK'd events in the queue to poison a subsequent test.
let(:data_dir) { File.join(temp_dir, "data") }

it "halts LS on fatal error" do
config = "input { generator { count => 1 message => 'a fatal error' } } "
Expand All @@ -42,7 +51,7 @@

expect(@logstash.exit_code).to be 120

log_file = "#{temp_dir}/logstash-plain.log"
log_file = "#{logs_dir}/logstash-plain.log"
expect( File.exists?(log_file) ).to be true
expect( File.read(log_file) ).to match /\[FATAL\]\[org.logstash.Logstash.*?java.lang.AssertionError: a fatal error/m
end
Expand All @@ -55,13 +64,16 @@

expect(@logstash.exit_code).to be 0 # normal exit

log_file = "#{temp_dir}/logstash-plain.log"
log_file = "#{logs_dir}/logstash-plain.log"
expect( File.exists?(log_file) ).to be true
expect( File.read(log_file) ).to match /\[ERROR\]\[org.logstash.Logstash.*?uncaught exception \(in thread .*?java.io.EOFException: unexpected/m
end

def spawn_logstash_and_wait_for_exit!(config, timeout)
@logstash.spawn_logstash('-w', '1', '--path.logs', temp_dir, '-e', config)
@logstash.spawn_logstash('--pipeline.workers=1',
'--path.logs', logs_dir,
'--path.data', data_dir,
'--config.string', config)

time = Time.now
while (Time.now - time) < timeout
Expand Down