Sha256: 8060a6df1e23613d99c6604fdf4fd19e7a5246a69391bc1e462eed2ead04bb8e

Contents?: true

Size: 1.23 KB

Versions: 14

Compression:

Stored size: 1.23 KB

Contents

# encoding: utf-8
require_relative "../spec_helper"
require "logstash/outputs/s3"
require "logstash/codecs/line"
require "stud/temporary"

describe "Restore from crash", :integration => true do
  include_context "setup plugin"

  let(:options) { main_options.merge({ "restore" => true, "canned_acl" => "public-read-write" }) }

  let(:number_of_files) { 5 }
  let(:dummy_content) { "foobar\n" * 100 }

  before do
    clean_remote_files(prefix)
    # Use the S3 factory to create mutliples files with dummy content
    factory = LogStash::Outputs::S3::TemporaryFileFactory.new(prefix, tags, "none", temporary_directory)

    # Creating a factory always create a file
    factory.current.write(dummy_content)
    factory.current.fsync

    (number_of_files - 1).times do
      factory.rotate!
      factory.current.write(dummy_content)
      factory.current.fsync
    end
  end

  it "uploads the file to the bucket" do
    subject.register
    try(20) do
      expect(bucket_resource.objects(:prefix => prefix).count).to eq(number_of_files)
      expect(Dir.glob(File.join(temporary_directory, "*")).size).to eq(0)
      expect(bucket_resource.objects(:prefix => prefix).first.acl.grants.collect(&:permission)).to include("READ", "WRITE")
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
logstash-output-s3-4.1.6 spec/integration/restore_from_crash_spec.rb
logstash-output-s3-4.1.5 spec/integration/restore_from_crash_spec.rb
logstash-output-s3-4.1.4 spec/integration/restore_from_crash_spec.rb
logstash-output-s3-4.1.3 spec/integration/restore_from_crash_spec.rb
logstash-output-s3-4.1.2 spec/integration/restore_from_crash_spec.rb
logstash-output-s3-4.1.1 spec/integration/restore_from_crash_spec.rb
logstash-output-s3-4.1.0 spec/integration/restore_from_crash_spec.rb
logstash-output-s3-4.0.13 spec/integration/restore_from_crash_spec.rb
logstash-output-s3-4.0.12 spec/integration/restore_from_crash_spec.rb
logstash-output-s3-4.0.11 spec/integration/restore_from_crash_spec.rb
logstash-output-s3-4.0.10 spec/integration/restore_from_crash_spec.rb
logstash-output-s3-4.0.9 spec/integration/restore_from_crash_spec.rb
logstash-output-s3-4.0.8 spec/integration/restore_from_crash_spec.rb
logstash-output-s3-4.0.7 spec/integration/restore_from_crash_spec.rb