logstash-output-s3 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -1
- data/README.md +4 -4
- data/lib/logstash/outputs/s3.rb +6 -2
- data/logstash-output-s3.gemspec +1 -1
- data/spec/outputs/s3_spec.rb +48 -26
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aabc38c7152aedb21ddb970e238362806d6ca08d
|
4
|
+
data.tar.gz: 26246183663a604686e5e0eaa5aa20f69f4c6509
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5492262d10345835ece18e519a837387af9c00311a439bf70aee0fffc7dbc7f202aed8559002b03cc00dbd554f392230edfd69c2e1aefa264d877db68e407ce5
|
7
|
+
data.tar.gz: 5af7cb1457d125e4c65876a385bf61ba980fcda7a28feb2fa5762c362e0200b9e4e13f5061408e09751f4a256d8c666ad985027e93ca285ad8e19febee6e5d64
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
gemspec
|
2
|
+
gemspec
|
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
This is a plugin for [Logstash](https://github.com/
|
3
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
4
4
|
|
5
5
|
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
|
6
6
|
|
7
7
|
## Documentation
|
8
8
|
|
9
|
-
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.
|
9
|
+
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
|
10
10
|
|
11
11
|
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
12
|
-
- For more asciidoc formatting tips, see the excellent reference here https://github.com/
|
12
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
13
13
|
|
14
14
|
## Need Help?
|
15
15
|
|
@@ -83,4 +83,4 @@ Programming is not a required skill. Whatever you've seen about open source and
|
|
83
83
|
|
84
84
|
It is more important to the community that you are able to contribute.
|
85
85
|
|
86
|
-
For more information about contributing, see the [CONTRIBUTING](https://github.com/
|
86
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
data/lib/logstash/outputs/s3.rb
CHANGED
@@ -284,7 +284,9 @@ class LogStash::Outputs::S3 < LogStash::Outputs::Base
|
|
284
284
|
|
285
285
|
public
|
286
286
|
def rotate_events_log?
|
287
|
-
@
|
287
|
+
@file_rotation_lock.synchronize do
|
288
|
+
@tempfile.size > @size_file
|
289
|
+
end
|
288
290
|
end
|
289
291
|
|
290
292
|
public
|
@@ -311,7 +313,9 @@ class LogStash::Outputs::S3 < LogStash::Outputs::Base
|
|
311
313
|
shutdown_upload_workers
|
312
314
|
@periodic_rotation_thread.stop! if @periodic_rotation_thread
|
313
315
|
|
314
|
-
@
|
316
|
+
@file_rotation_lock.synchronize do
|
317
|
+
@tempfile.close unless @tempfile.nil? && @tempfile.closed?
|
318
|
+
end
|
315
319
|
finished
|
316
320
|
end
|
317
321
|
|
data/logstash-output-s3.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-s3'
|
4
|
-
s.version = '1.0.
|
4
|
+
s.version = '1.0.1'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This plugin was created for store the logstash's events into Amazon Simple Storage Service (Amazon S3)"
|
7
7
|
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
data/spec/outputs/s3_spec.rb
CHANGED
@@ -12,7 +12,6 @@ describe LogStash::Outputs::S3 do
|
|
12
12
|
# We stub all the calls from S3, for more information see:
|
13
13
|
# http://ruby.awsblog.com/post/Tx2SU6TYJWQQLC3/Stubbing-AWS-Responses
|
14
14
|
AWS.stub!
|
15
|
-
|
16
15
|
Thread.abort_on_exception = true
|
17
16
|
end
|
18
17
|
|
@@ -70,8 +69,8 @@ describe LogStash::Outputs::S3 do
|
|
70
69
|
|
71
70
|
describe "#generate_temporary_filename" do
|
72
71
|
before do
|
73
|
-
Socket.
|
74
|
-
Time.
|
72
|
+
allow(Socket).to receive(:gethostname) { "logstash.local" }
|
73
|
+
allow(Time).to receive(:now) { Time.new('2015-10-09-09:00') }
|
75
74
|
end
|
76
75
|
|
77
76
|
it "should add tags to the filename if present" do
|
@@ -97,7 +96,7 @@ describe LogStash::Outputs::S3 do
|
|
97
96
|
|
98
97
|
let(:fake_bucket) do
|
99
98
|
s3 = double('S3Object')
|
100
|
-
s3.
|
99
|
+
allow(s3).to receive(:write)
|
101
100
|
s3
|
102
101
|
end
|
103
102
|
|
@@ -158,35 +157,58 @@ describe LogStash::Outputs::S3 do
|
|
158
157
|
end
|
159
158
|
|
160
159
|
describe "#rotate_events_log" do
|
161
|
-
let(:s3) { LogStash::Outputs::S3.new(minimal_settings.merge({ "size_file" => 1024 })) }
|
162
160
|
|
163
|
-
|
164
|
-
|
165
|
-
tmp.stub(:size) { 2024001 }
|
161
|
+
context "having a single worker" do
|
162
|
+
let(:s3) { LogStash::Outputs::S3.new(minimal_settings.merge({ "size_file" => 1024 })) }
|
166
163
|
|
167
|
-
|
168
|
-
|
164
|
+
before(:each) do
|
165
|
+
s3.register
|
166
|
+
end
|
167
|
+
|
168
|
+
it "returns true if the tempfile is over the file_size limit" do
|
169
|
+
Stud::Temporary.file do |tmp|
|
170
|
+
allow(tmp).to receive(:size) { 2024001 }
|
171
|
+
|
172
|
+
s3.tempfile = tmp
|
173
|
+
expect(s3.rotate_events_log?).to be(true)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
it "returns false if the tempfile is under the file_size limit" do
|
178
|
+
Stud::Temporary.file do |tmp|
|
179
|
+
allow(tmp).to receive(:size) { 100 }
|
180
|
+
|
181
|
+
s3.tempfile = tmp
|
182
|
+
expect(s3.rotate_events_log?).to eq(false)
|
183
|
+
end
|
169
184
|
end
|
170
185
|
end
|
171
186
|
|
172
|
-
|
173
|
-
|
174
|
-
|
187
|
+
context "having periodic rotations" do
|
188
|
+
let(:s3) { LogStash::Outputs::S3.new(minimal_settings.merge({ "size_file" => 1024, "time_file" => 6e-10 })) }
|
189
|
+
let(:tmp) { Tempfile.new('s3_rotation_temp_file') }
|
175
190
|
|
191
|
+
before(:each) do
|
176
192
|
s3.tempfile = tmp
|
177
|
-
|
193
|
+
s3.register
|
194
|
+
end
|
195
|
+
|
196
|
+
after(:each) do
|
197
|
+
s3.teardown
|
198
|
+
tmp.close
|
199
|
+
tmp.unlink
|
200
|
+
end
|
201
|
+
|
202
|
+
it "raises no error when periodic rotation happen" do
|
203
|
+
1000.times do
|
204
|
+
expect { s3.rotate_events_log? }.not_to raise_error
|
205
|
+
end
|
178
206
|
end
|
179
207
|
end
|
180
208
|
end
|
181
209
|
|
182
210
|
describe "#move_file_to_bucket" do
|
183
|
-
|
184
|
-
|
185
|
-
before do
|
186
|
-
# Assume the AWS test credentials pass.
|
187
|
-
allow(s3).to receive(:test_s3_write)
|
188
|
-
s3.register
|
189
|
-
end
|
211
|
+
subject { LogStash::Outputs::S3.new(minimal_settings) }
|
190
212
|
|
191
213
|
it "should always delete the source file" do
|
192
214
|
tmp = Stud::Temporary.file
|
@@ -194,24 +216,24 @@ describe LogStash::Outputs::S3 do
|
|
194
216
|
allow(File).to receive(:zero?).and_return(true)
|
195
217
|
expect(File).to receive(:delete).with(tmp)
|
196
218
|
|
197
|
-
|
219
|
+
subject.move_file_to_bucket(tmp)
|
198
220
|
end
|
199
221
|
|
200
222
|
it 'should not upload the file if the size of the file is zero' do
|
201
223
|
temp_file = Stud::Temporary.file
|
202
224
|
allow(temp_file).to receive(:zero?).and_return(true)
|
203
225
|
|
204
|
-
expect(
|
205
|
-
|
226
|
+
expect(subject).not_to receive(:write_on_bucket)
|
227
|
+
subject.move_file_to_bucket(temp_file)
|
206
228
|
end
|
207
229
|
|
208
230
|
it "should upload the file if the size > 0" do
|
209
231
|
tmp = Stud::Temporary.file
|
210
232
|
|
211
233
|
allow(File).to receive(:zero?).and_return(false)
|
212
|
-
expect(
|
234
|
+
expect(subject).to receive(:write_on_bucket)
|
213
235
|
|
214
|
-
|
236
|
+
subject.move_file_to_bucket(tmp)
|
215
237
|
end
|
216
238
|
end
|
217
239
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
156
|
version: '0'
|
157
157
|
requirements: []
|
158
158
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
159
|
+
rubygems_version: 2.4.5
|
160
160
|
signing_key:
|
161
161
|
specification_version: 4
|
162
162
|
summary: This plugin was created for store the logstash's events into Amazon Simple Storage Service (Amazon S3)
|