From 1bc27ce2354ffc171511072d349cb6acee6f5166 Mon Sep 17 00:00:00 2001 From: Craig Read Date: Wed, 27 Jan 2016 13:43:22 +1100 Subject: [PATCH] flush data on close --- lib/logstash/outputs/s3.rb | 1 + spec/integration/s3_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/lib/logstash/outputs/s3.rb b/lib/logstash/outputs/s3.rb index 20d4b395..af782054 100644 --- a/lib/logstash/outputs/s3.rb +++ b/lib/logstash/outputs/s3.rb @@ -340,6 +340,7 @@ def close @file_rotation_lock.synchronize do @tempfile.close unless @tempfile.nil? && @tempfile.closed? + move_file_to_bucket(@tempfile.path) unless @tempfile.nil? end end diff --git a/spec/integration/s3_spec.rb b/spec/integration/s3_spec.rb index cb2f574e..070cf7ee 100644 --- a/spec/integration/s3_spec.rb +++ b/spec/integration/s3_spec.rb @@ -28,6 +28,15 @@ delete_matching_keys_on_bucket('my-prefix') end + describe '#close' do + it 'flushes to s3' do + s3 = LogStash::Outputs::S3.new(minimal_settings) + s3.register + expect(s3).to receive(:move_file_to_bucket) + s3.close + end + end + describe "#register" do it "write a file on the bucket to check permissions" do s3 = LogStash::Outputs::S3.new(minimal_settings)