-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add coverage for large mpub payload behavior described in #25
- Loading branch information
1 parent
f839885
commit 190b154
Showing
1 changed file
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |