Skip to content

Commit

Permalink
Add coverage for large mpub payload behavior described in #25
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisroberts committed Mar 20, 2015
1 parent f839885 commit 190b154
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions test/specs/application/large_mpub_producer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
require 'securerandom'
require_relative '../../helpers/spec_helper'

describe Krakow do

before do
@nsqd = Krakow::Nsqd.new
@nsqd.run!
end

after do
@nsqd.halt!
end

describe 'Large mpub from producer with sufficient wait response' do

before do
@topic = TOPIC_NAME.shuffle.join
@producer = @nsqd.nsqd_tcp_addresses.map do |addr|
host, port = addr.split(':')
Krakow::Producer.new(
:host => host,
:port => port,
:topic => @topic,
:connection_options => {
:options => {
:response_wait => 10
}
}
)
end.first
wait_for{ @producer.connected? }
end

after do
@producer.terminate
end

it 'should deliver large mpub payload and receive result' do
msgs = 100000.times.map{ SecureRandom.hex }
msgs.each_slice(50000) do |slice|
result = @producer.write(*slice)
result.must_be :is_a?, Krakow::FrameType
end
end

end

describe 'Large mpub from producer without sufficient wait response' do

before do
@topic = TOPIC_NAME.shuffle.join
@producer = @nsqd.nsqd_tcp_addresses.map do |addr|
host, port = addr.split(':')
Krakow::Producer.new(
:host => host,
:port => port,
:topic => @topic,
:connection_options => {
:options => {
:response_wait => 0.01
}
}
)
end.first
wait_for{ @producer.connected? }
end

after do
@producer.terminate
end

it 'should deliver large mpub payload and receive result' do
msgs = 100000.times.map{ SecureRandom.hex }
lambda do
msgs.each_slice(50000) do |slice|
result = @producer.write(*slice)
end
end.must_raise Krakow::Error::BadResponse::NoResponse
end

end

end

0 comments on commit 190b154

Please sign in to comment.