|
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 |
|
|
186 | 185 | end
|
187 | 186 |
|
188 | 187 | context "having periodic rotations" do
|
189 |
| - |
190 | 188 | let(:s3) { LogStash::Outputs::S3.new(minimal_settings.merge({ "size_file" => 1024, "time_file" => 6e-10 })) }
|
191 | 189 | let(:tmp) { Tempfile.new('s3_rotation_temp_file') }
|
192 | 190 |
|
|
196 | 194 | end
|
197 | 195 |
|
198 | 196 | after(:each) do
|
199 |
| - tmp.close |
| 197 | + s3.teardown |
| 198 | + tmp.close |
200 | 199 | tmp.unlink
|
201 | 200 | end
|
202 | 201 |
|
203 | 202 | it "raises no error when periodic rotation happen" do
|
204 | 203 | 1000.times do
|
205 |
| - expect{ s3.rotate_events_log?}.not_to raise_error |
| 204 | + expect { s3.rotate_events_log? }.not_to raise_error |
206 | 205 | end
|
207 | 206 | end
|
208 |
| - |
209 | 207 | end
|
210 | 208 | end
|
211 | 209 |
|
212 | 210 | describe "#move_file_to_bucket" do
|
213 |
| - let!(:s3) { LogStash::Outputs::S3.new(minimal_settings) } |
214 |
| - |
215 |
| - before do |
216 |
| - # Assume the AWS test credentials pass. |
217 |
| - allow(s3).to receive(:test_s3_write) |
218 |
| - s3.register |
219 |
| - end |
| 211 | + subject { LogStash::Outputs::S3.new(minimal_settings) } |
220 | 212 |
|
221 | 213 | it "should always delete the source file" do
|
222 | 214 | tmp = Stud::Temporary.file
|
223 | 215 |
|
224 | 216 | allow(File).to receive(:zero?).and_return(true)
|
225 | 217 | expect(File).to receive(:delete).with(tmp)
|
226 | 218 |
|
227 |
| - s3.move_file_to_bucket(tmp) |
| 219 | + subject.move_file_to_bucket(tmp) |
228 | 220 | end
|
229 | 221 |
|
230 | 222 | it 'should not upload the file if the size of the file is zero' do
|
231 | 223 | temp_file = Stud::Temporary.file
|
232 | 224 | allow(temp_file).to receive(:zero?).and_return(true)
|
233 | 225 |
|
234 |
| - expect(s3).not_to receive(:write_on_bucket) |
235 |
| - s3.move_file_to_bucket(temp_file) |
| 226 | + expect(subject).not_to receive(:write_on_bucket) |
| 227 | + subject.move_file_to_bucket(temp_file) |
236 | 228 | end
|
237 | 229 |
|
238 | 230 | it "should upload the file if the size > 0" do
|
239 | 231 | tmp = Stud::Temporary.file
|
240 | 232 |
|
241 | 233 | allow(File).to receive(:zero?).and_return(false)
|
242 |
| - expect(s3).to receive(:write_on_bucket) |
| 234 | + expect(subject).to receive(:write_on_bucket) |
243 | 235 |
|
244 |
| - s3.move_file_to_bucket(tmp) |
| 236 | + subject.move_file_to_bucket(tmp) |
245 | 237 | end
|
246 | 238 | end
|
247 | 239 |
|
|
0 commit comments