Sha256: 73c4b39cf825f6ab222dc5efd664a9c689bcfb435d7ee26c476ea17b4c30f5cf

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

require 'logstash-logger'

describe LogStashLogger::Device::Firehose do
  include_context 'device'

  let(:client) { double("Aws::Firehose::Client") }

  before(:each) do
    allow(Aws::Firehose::Client).to receive(:new) { client }
  end

  it "writes to a Firehose stream" do
    response = ::Aws::Firehose::Types::PutRecordBatchOutput.new
    response.failed_put_count = 0
    response.request_responses = []
    expect(client).to receive(:put_record_batch) { response }
    firehose_device.write "foo"

    expect(firehose_device).to be_connected
    firehose_device.close!
    expect(firehose_device).not_to be_connected
  end

  it "it puts records with recoverable errors back in the buffer" do
    failed_record = ::Aws::Firehose::Types::PutRecordBatchResponseEntry.new
    failed_record.error_code = "InternalFailure"
    failed_record.error_message = "InternalFailure"
    response = ::Aws::Firehose::Types::PutRecordBatchOutput.new
    response.failed_put_count = 1
    response.request_responses = [failed_record]

    expect(client).to receive(:put_record_batch) { response }
    expect(firehose_device).to receive(:write).with("foo")

    firehose_device.write_one "foo"
  end

  it "defaults the Firehose stream to logstash" do
    expect(firehose_device.stream).to eq('logstash')
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
logstash-logger-p-0.26.1 spec/device/firehose_spec.rb
logstash-logger-yajl-0.27.0 spec/device/firehose_spec.rb
logstash-logger-0.26.1 spec/device/firehose_spec.rb
logstash-logger-0.26.0 spec/device/firehose_spec.rb