Sha256: cd48cbba273abe47352757a11ae40adac70fcd2d0ee519d5b504e67302c53c7a

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

require "logstash/devutils/rspec/spec_helper"
require "logstash/outputs/redis"
require "logstash/json"
require "redis"
require "flores/random"

describe LogStash::Outputs::Redis do

  context "Redis#receive in batch mode" do
    # this is a regression test harness to verify fix for https://github.com/logstash-plugins/logstash-output-redis/issues/26
    # TODO: refactor specs above and probably rely on a Redis mock to correctly test the code expected behaviour, the actual
    # tests agains Redis should be moved into integration tests.
    let(:key) { "thekey" }
    let(:payload) { "somepayload"}
    let(:event) { LogStash::Event.new({"message" => "test"}) }
    let(:config) {
      {
        "key" => key,
        "data_type" => "list",
        "batch" => true,
        "batch_events" => 50,
       }
    }
    let(:redis) { described_class.new(config) }

    it "should call buffer_receive" do
      redis.register
      expect(redis).to receive(:buffer_receive).exactly(10000).times.and_call_original
      expect(redis).to receive(:flush).exactly(200).times

      # I was able to reproduce the LocalJumpError: unexpected next exception at around 50
      # consicutive invocations. setting to 10000 should reproduce it for any environment
      # I have no clue at this point why this problem does not happen at every invocation
      1.upto(10000) do
        expect{redis.receive(event)}.to_not raise_error
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
logstash-output-redis-3.0.3 spec/unit/outputs/redis_spec.rb
logstash-output-redis-3.0.2 spec/unit/outputs/redis_spec.rb
logstash-output-redis-3.0.1 spec/unit/outputs/redis_spec.rb
logstash-output-redis-3.0.0 spec/unit/outputs/redis_spec.rb