Sha256: 7ed5ce24d0e34bf3b0761dce4577543a76384a6a07ba0868f8575d59d505e7a2

Contents?: true

Size: 1.45 KB

Versions: 12

Compression:

Stored size: 1.45 KB

Contents

# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
require "logstash/codecs/gzip_lines"
require "logstash/errors"
require "stringio"

def compress_with_gzip(io)
  compressed = StringIO.new('', 'r+b')

  gzip = Zlib::GzipWriter.new(compressed)
  gzip.write(io.read)
  gzip.finish

  compressed.rewind

  compressed
end

describe LogStash::Codecs::GzipLines do
  let!(:uncompressed_log) do
    # Using format from
    # http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html
    str = StringIO.new

    str << "2010-03-12   23:51:20   SEA4   192.0.2.147   connect   2014   OK   bfd8a98bee0840d9b871b7f6ade9908f   rtmp://shqshne4jdp4b6.cloudfront.net/cfx/st​  key=value   http://player.longtailvideo.com/player.swf   http://www.longtailvideo.com/support/jw-player-setup-wizard?example=204   LNX%2010,0,32,18   -   -   -   -\n"
    str << "2010-03-12   23:51:21   SEA4   192.0.2.222   play   3914   OK   bfd8a98bee0840d9b871b7f6ade9908f   rtmp://shqshne4jdp4b6.cloudfront.net/cfx/st​  key=value   http://player.longtailvideo.com/player.swf   http://www.longtailvideo.com/support/jw-player-setup-wizard?example=204   LNX%2010,0,32,18   myvideo   p=2&q=4   flv   1\n"

    str.rewind
    str
  end

  describe "#decode" do
    it "should create events from a gzip file" do
      events = []

      subject.decode(compress_with_gzip(uncompressed_log)) do |event|
        events << event
      end

      expect(events.size).to eq(2)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
logstash-codec-gzip_lines-3.0.3 spec/codecs/gzip_lines_spec.rb
logstash-codec-gzip_lines-3.0.2 spec/codecs/gzip_lines_spec.rb
logstash-codec-gzip_lines-3.0.1 spec/codecs/gzip_lines_spec.rb
logstash-codec-gzip_lines-3.0.0 spec/codecs/gzip_lines_spec.rb
logstash-codec-gzip_lines-2.0.4 spec/codecs/gzip_lines_spec.rb
logstash-codec-gzip_lines-2.0.2 spec/codecs/gzip_lines_spec.rb
logstash-codec-gzip_lines-2.0.1 spec/codecs/gzip_lines_spec.rb
logstash-codec-gzip_lines-0.1.5 spec/codecs/gzip_lines_spec.rb
logstash-codec-gzip_lines-0.1.4 spec/codecs/gzip_lines_spec.rb
logstash-codec-gzip_lines-0.1.3 spec/codecs/gzip_lines_spec.rb
logstash-codec-gzip_lines-0.1.2 spec/codecs/gzip_lines_spec.rb
logstash-codec-gzip_lines-0.1.1 spec/codecs/gzip_lines_spec.rb