logstash-input-s3 3.3.3 → 3.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c3b88def1290e33f7d948bc9d48a62e43ac098be76f98b9b5fdd3745ab9e92e
4
- data.tar.gz: f1901fe7e0c0edab44370b28f58c3145dc393a97a0098e7e4020d13534e08f36
3
+ metadata.gz: c14073f2906b9c1958697f2fac9d9c94f63451194494cb6c2b7152d7884fbf5e
4
+ data.tar.gz: fd650fb97f1624cb0586c47be4c12d5cfd6742135499474854d2f3f05526ee84
5
5
  SHA512:
6
- metadata.gz: e5a17bf1aafc53530789724d2fcb9073c8b3b3f99f944044da7806e44a10023f278b3d54d44587238834d74b42b6cb9287561479f368a23c2c8afe552c000ad7
7
- data.tar.gz: 8f9c6ba566077a036bd8a6737299bb83f480a35bfe8471fc847d6ef6378000f160b268e2068567e05497cd38ca22a90788bb7e7047b0b0e7cd9ab7ba46b5ac95
6
+ metadata.gz: 2dbb14ca04cebda808918a9cd2fec7a1fda0c5d41cb39ba30d86e83e3c62e9eb9ed77dd6e24ff77c5e8cdb2338061bf503ea1bad9dddeaffc65694258548d0eb
7
+ data.tar.gz: b0f938a69ba7968a7dacfba808eb8d4e983c6c2f01990a324e170579574789b3504db2cc670cfe2c290f3417eea3abbc03331bf5b071f697c1efdf3c4db86eb7
@@ -1,3 +1,6 @@
1
+ ## 3.3.4
2
+ - Log entry when bucket is empty #150
3
+
1
4
  ## 3.3.3
2
5
  - Symbolize hash keys for additional_settings hash #148
3
6
 
@@ -109,18 +109,22 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
109
109
  public
110
110
  def list_new_files
111
111
  objects = {}
112
-
112
+ found = false
113
113
  begin
114
114
  @s3bucket.objects(:prefix => @prefix).each do |log|
115
+ found = true
115
116
  @logger.debug("S3 input: Found key", :key => log.key)
116
- unless ignore_filename?(log.key)
117
+ if !ignore_filename?(log.key)
117
118
  if sincedb.newer?(log.last_modified) && log.content_length > 0
118
119
  objects[log.key] = log.last_modified
119
120
  @logger.debug("S3 input: Adding to objects[]", :key => log.key)
120
121
  @logger.debug("objects[] length is: ", :length => objects.length)
121
122
  end
123
+ else
124
+ @logger.debug('S3 input: Ignoring', :key => log.key)
122
125
  end
123
126
  end
127
+ @logger.info('S3 input: No files found in bucket', :prefix => prefix) unless found
124
128
  rescue Aws::Errors::ServiceError => e
125
129
  @logger.error("S3 input: Unable to list objects in bucket", :prefix => prefix, :message => e.message)
126
130
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-s3'
4
- s.version = '3.3.3'
4
+ s.version = '3.3.4'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Streams events from files in a S3 bucket"
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/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -135,6 +135,36 @@ describe LogStash::Inputs::S3 do
135
135
  expect(plugin.list_new_files).to eq(objects_list.map(&:key))
136
136
  end
137
137
 
138
+ context 'when all files are excluded from a bucket' do
139
+ let(:objects_list) {
140
+ [
141
+ double(:key => 'exclude-this-file-1', :last_modified => Time.now - 2 * day, :content_length => 100),
142
+ double(:key => 'exclude/logstash', :last_modified => Time.now - 2 * day, :content_length => 50),
143
+ ]
144
+ }
145
+
146
+ it 'should not log that no files were found in the bucket' do
147
+ plugin = LogStash::Inputs::S3.new(config.merge({ "exclude_pattern" => "^exclude" }))
148
+ plugin.register
149
+ allow(plugin.logger).to receive(:debug).with(anything, anything)
150
+
151
+ expect(plugin.logger).not_to receive(:info).with(/No files found/, anything)
152
+ expect(plugin.logger).to receive(:debug).with(/Ignoring/, anything)
153
+ expect(plugin.list_new_files).to be_empty
154
+ end
155
+ end
156
+
157
+ context 'with an empty bucket' do
158
+ let(:objects_list) { [] }
159
+
160
+ it 'should log that no files were found in the bucket' do
161
+ plugin = LogStash::Inputs::S3.new(config)
162
+ plugin.register
163
+ expect(plugin.logger).to receive(:info).with(/No files found/, anything)
164
+ expect(plugin.list_new_files).to be_empty
165
+ end
166
+ end
167
+
138
168
  context "If the bucket is the same as the backup bucket" do
139
169
  it 'should ignore files from the bucket if they match the backup prefix' do
140
170
  objects_list = [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.3
4
+ version: 3.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-01 00:00:00.000000000 Z
11
+ date: 2018-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement