bunny 1.7.1 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CONTRIBUTING.md +14 -0
- data/ChangeLog.md +21 -6
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/README.md +22 -23
- data/bunny.gemspec +1 -1
- data/lib/bunny/channel.rb +12 -0
- data/lib/bunny/concurrent/continuation_queue.rb +30 -13
- data/lib/bunny/exchange.rb +0 -5
- data/lib/bunny/jruby/socket.rb +1 -2
- data/lib/bunny/queue.rb +9 -0
- data/lib/bunny/session.rb +7 -6
- data/lib/bunny/version.rb +1 -1
- data/spec/higher_level_api/integration/basic_ack_spec.rb +9 -9
- data/spec/higher_level_api/integration/basic_cancel_spec.rb +4 -4
- data/spec/higher_level_api/integration/basic_consume_spec.rb +22 -22
- data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +1 -1
- data/spec/higher_level_api/integration/basic_get_spec.rb +2 -2
- data/spec/higher_level_api/integration/basic_nack_spec.rb +6 -6
- data/spec/higher_level_api/integration/basic_publish_spec.rb +14 -14
- data/spec/higher_level_api/integration/basic_qos_spec.rb +11 -2
- data/spec/higher_level_api/integration/basic_recover_spec.rb +2 -2
- data/spec/higher_level_api/integration/basic_reject_spec.rb +6 -6
- data/spec/higher_level_api/integration/basic_return_spec.rb +1 -1
- data/spec/higher_level_api/integration/channel_close_spec.rb +2 -2
- data/spec/higher_level_api/integration/channel_open_spec.rb +11 -11
- data/spec/higher_level_api/integration/connection_recovery_spec.rb +52 -52
- data/spec/higher_level_api/integration/connection_spec.rb +83 -83
- data/spec/higher_level_api/integration/connection_stop_spec.rb +11 -11
- data/spec/higher_level_api/integration/consistent_hash_exchange_spec.rb +2 -2
- data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +3 -3
- data/spec/higher_level_api/integration/dead_lettering_spec.rb +6 -6
- data/spec/higher_level_api/integration/exchange_bind_spec.rb +1 -1
- data/spec/higher_level_api/integration/exchange_declare_spec.rb +20 -20
- data/spec/higher_level_api/integration/exchange_delete_spec.rb +11 -11
- data/spec/higher_level_api/integration/exchange_unbind_spec.rb +2 -2
- data/spec/higher_level_api/integration/merry_go_round_spec.rb +2 -2
- data/spec/higher_level_api/integration/message_properties_access_spec.rb +27 -27
- data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +1 -1
- data/spec/higher_level_api/integration/publisher_confirms_spec.rb +19 -19
- data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +9 -9
- data/spec/higher_level_api/integration/queue_bind_spec.rb +13 -13
- data/spec/higher_level_api/integration/queue_declare_spec.rb +23 -23
- data/spec/higher_level_api/integration/queue_delete_spec.rb +1 -1
- data/spec/higher_level_api/integration/queue_purge_spec.rb +2 -2
- data/spec/higher_level_api/integration/queue_unbind_spec.rb +2 -2
- data/spec/higher_level_api/integration/read_only_consumer_spec.rb +3 -3
- data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +4 -4
- data/spec/higher_level_api/integration/tls_connection_spec.rb +5 -5
- data/spec/higher_level_api/integration/with_channel_spec.rb +1 -1
- data/spec/issues/issue100_spec.rb +9 -10
- data/spec/issues/issue141_spec.rb +11 -12
- data/spec/issues/issue224_spec.rb +2 -2
- data/spec/issues/issue78_spec.rb +14 -18
- data/spec/issues/issue83_spec.rb +5 -6
- data/spec/issues/issue97_spec.rb +25 -26
- data/spec/lower_level_api/integration/basic_cancel_spec.rb +15 -16
- data/spec/lower_level_api/integration/basic_consume_spec.rb +19 -20
- data/spec/stress/channel_open_stress_spec.rb +1 -1
- data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +6 -7
- data/spec/stress/concurrent_consumers_stress_spec.rb +6 -7
- data/spec/stress/concurrent_publishers_stress_spec.rb +6 -7
- data/spec/stress/connection_open_close_spec.rb +6 -6
- data/spec/stress/long_running_consumer_spec.rb +6 -7
- data/spec/unit/bunny_spec.rb +5 -5
- data/spec/unit/concurrent/atomic_fixnum_spec.rb +6 -6
- data/spec/unit/concurrent/condition_spec.rb +3 -3
- data/spec/unit/concurrent/linked_continuation_queue_spec.rb +2 -2
- data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +16 -16
- data/spec/unit/system_timer_spec.rb +2 -2
- data/spec/unit/version_delivery_tag_spec.rb +3 -3
- metadata +8 -7
@@ -1,33 +1,32 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Bunny::Channel, "#basic_consume" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
c
|
4
|
+
before(:all) do
|
5
|
+
@connection = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
+
@connection.start
|
8
7
|
end
|
9
8
|
|
10
9
|
after :all do
|
11
|
-
connection.close if connection.open?
|
10
|
+
@connection.close if @connection.open?
|
12
11
|
end
|
13
12
|
|
14
13
|
it "returns basic.consume-ok when it is received" do
|
15
|
-
ch = connection.create_channel
|
14
|
+
ch = @connection.create_channel
|
16
15
|
q = ch.queue("", :exclusive => true)
|
17
16
|
|
18
17
|
consume_ok = ch.basic_consume(q)
|
19
|
-
consume_ok.
|
20
|
-
consume_ok.consumer_tag.
|
18
|
+
expect(consume_ok).to be_instance_of AMQ::Protocol::Basic::ConsumeOk
|
19
|
+
expect(consume_ok.consumer_tag).not_to be_nil
|
21
20
|
|
22
21
|
ch.close
|
23
22
|
end
|
24
23
|
|
25
24
|
it "carries server-generated consumer tag with basic.consume-ok" do
|
26
|
-
ch = connection.create_channel
|
25
|
+
ch = @connection.create_channel
|
27
26
|
q = ch.queue("", :exclusive => true)
|
28
27
|
|
29
28
|
consume_ok = ch.basic_consume(q, "")
|
30
|
-
consume_ok.consumer_tag.
|
29
|
+
expect(consume_ok.consumer_tag).to match /amq\.ctag.*/
|
31
30
|
|
32
31
|
ch.close
|
33
32
|
end
|
@@ -40,7 +39,7 @@ describe Bunny::Channel, "#basic_consume" do
|
|
40
39
|
delivered_data = []
|
41
40
|
|
42
41
|
t = Thread.new do
|
43
|
-
ch = connection.create_channel
|
42
|
+
ch = @connection.create_channel
|
44
43
|
q = ch.queue(queue_name, :auto_delete => true, :durable => false)
|
45
44
|
ch.basic_consume(q, "", true, false) do |delivery_info, properties, payload|
|
46
45
|
delivered_keys << delivery_info.routing_key
|
@@ -50,15 +49,15 @@ describe Bunny::Channel, "#basic_consume" do
|
|
50
49
|
t.abort_on_exception = true
|
51
50
|
sleep 0.5
|
52
51
|
|
53
|
-
ch = connection.create_channel
|
52
|
+
ch = @connection.create_channel
|
54
53
|
x = ch.default_exchange
|
55
54
|
x.publish("hello", :routing_key => queue_name)
|
56
55
|
|
57
56
|
sleep 0.7
|
58
|
-
delivered_keys.
|
59
|
-
delivered_data.
|
57
|
+
expect(delivered_keys).to include queue_name
|
58
|
+
expect(delivered_data).to include "hello"
|
60
59
|
|
61
|
-
ch.queue(queue_name, :auto_delete => true, :durable => false).message_count.
|
60
|
+
expect(ch.queue(queue_name, :auto_delete => true, :durable => false).message_count).to eq 0
|
62
61
|
|
63
62
|
ch.close
|
64
63
|
end
|
@@ -72,7 +71,7 @@ describe Bunny::Channel, "#basic_consume" do
|
|
72
71
|
delivered_data = []
|
73
72
|
|
74
73
|
t = Thread.new do
|
75
|
-
ch = connection.create_channel
|
74
|
+
ch = @connection.create_channel
|
76
75
|
q = ch.queue(queue_name, :auto_delete => true, :durable => false)
|
77
76
|
ch.basic_consume(q, "", false, false) do |delivery_info, properties, payload|
|
78
77
|
delivered_keys << delivery_info.routing_key
|
@@ -84,15 +83,15 @@ describe Bunny::Channel, "#basic_consume" do
|
|
84
83
|
t.abort_on_exception = true
|
85
84
|
sleep 0.5
|
86
85
|
|
87
|
-
ch = connection.create_channel
|
86
|
+
ch = @connection.create_channel
|
88
87
|
x = ch.default_exchange
|
89
88
|
x.publish("hello", :routing_key => queue_name)
|
90
89
|
|
91
90
|
sleep 0.7
|
92
|
-
delivered_keys.
|
93
|
-
delivered_data.
|
91
|
+
expect(delivered_keys).to include queue_name
|
92
|
+
expect(delivered_data).to include "hello"
|
94
93
|
|
95
|
-
ch.queue(queue_name, :auto_delete => true, :durable => false).message_count.
|
94
|
+
expect(ch.queue(queue_name, :auto_delete => true, :durable => false).message_count).to eq 0
|
96
95
|
|
97
96
|
ch.close
|
98
97
|
end
|
@@ -2,23 +2,22 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
unless ENV["CI"]
|
4
4
|
describe "Rapidly opening and closing lots of channels on a non-threaded connection" do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
c
|
5
|
+
before :all do
|
6
|
+
@connection = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed", :automatic_recovery => false, :threaded => false)
|
7
|
+
@connection.start
|
9
8
|
end
|
10
9
|
|
11
10
|
after :all do
|
12
|
-
connection.close
|
11
|
+
@connection.close
|
13
12
|
end
|
14
13
|
|
15
14
|
context "in a single-threaded scenario" do
|
16
15
|
let(:n) { 500 }
|
17
16
|
|
18
17
|
it "works correctly" do
|
19
|
-
xs = Array.new(n) { connection.create_channel }
|
18
|
+
xs = Array.new(n) { @connection.create_channel }
|
20
19
|
|
21
|
-
xs.size.
|
20
|
+
expect(xs.size).to eq n
|
22
21
|
xs.each do |ch|
|
23
22
|
ch.close
|
24
23
|
end
|
@@ -3,15 +3,14 @@ require "spec_helper"
|
|
3
3
|
|
4
4
|
unless ENV["CI"]
|
5
5
|
describe "Concurrent consumers sharing a connection" do
|
6
|
-
|
7
|
-
|
6
|
+
before :all do
|
7
|
+
@connection = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed",
|
8
8
|
:automatic_recovery => false, :continuation_timeout => 6000)
|
9
|
-
|
10
|
-
c
|
9
|
+
@connection.start
|
11
10
|
end
|
12
11
|
|
13
12
|
after :all do
|
14
|
-
connection.close
|
13
|
+
@connection.close
|
15
14
|
end
|
16
15
|
|
17
16
|
def any_not_drained?(qs)
|
@@ -25,13 +24,13 @@ unless ENV["CI"]
|
|
25
24
|
let(:m) { 1000 }
|
26
25
|
|
27
26
|
it "successfully drain all queues" do
|
28
|
-
ch = connection.create_channel
|
27
|
+
ch = @connection.create_channel
|
29
28
|
body = "абвг"
|
30
29
|
x = ch.topic("bunny.stress.concurrent.consumers.topic", :durable => true)
|
31
30
|
|
32
31
|
chs = {}
|
33
32
|
n.times do |i|
|
34
|
-
chs[i] = connection.create_channel
|
33
|
+
chs[i] = @connection.create_channel
|
35
34
|
end
|
36
35
|
qs = []
|
37
36
|
|
@@ -3,21 +3,20 @@ require "spec_helper"
|
|
3
3
|
|
4
4
|
unless ENV["CI"]
|
5
5
|
describe "Concurrent publishers sharing a connection" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
c
|
6
|
+
before :all do
|
7
|
+
@connection = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed", :automatically_recover => false, :continuation_timeout => 20.0)
|
8
|
+
@connection.start
|
10
9
|
end
|
11
10
|
|
12
11
|
after :all do
|
13
|
-
connection.close
|
12
|
+
@connection.close
|
14
13
|
end
|
15
14
|
|
16
15
|
let(:concurrency) { 24 }
|
17
16
|
let(:rate) { 5_000 }
|
18
17
|
|
19
18
|
it "successfully finish publishing" do
|
20
|
-
ch = connection.create_channel
|
19
|
+
ch = @connection.create_channel
|
21
20
|
|
22
21
|
q = ch.queue("", :exclusive => true)
|
23
22
|
body = "сообщение"
|
@@ -27,7 +26,7 @@ unless ENV["CI"]
|
|
27
26
|
|
28
27
|
chs = {}
|
29
28
|
concurrency.times do |i|
|
30
|
-
chs[i] = connection.create_channel
|
29
|
+
chs[i] = @connection.create_channel
|
31
30
|
end
|
32
31
|
|
33
32
|
ts = []
|
@@ -17,9 +17,9 @@ unless defined?(JRUBY_VERSION) && !ENV["FORCE_JRUBY_RUN"]
|
|
17
17
|
c.start
|
18
18
|
ch = c.create_channel
|
19
19
|
|
20
|
-
c.
|
20
|
+
expect(c).to be_connected
|
21
21
|
c.stop
|
22
|
-
c.
|
22
|
+
expect(c).to be_closed
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -29,9 +29,9 @@ unless defined?(JRUBY_VERSION) && !ENV["FORCE_JRUBY_RUN"]
|
|
29
29
|
c.start
|
30
30
|
ch = c.create_channel
|
31
31
|
|
32
|
-
c.
|
32
|
+
expect(c).to be_connected
|
33
33
|
c.stop
|
34
|
-
c.
|
34
|
+
expect(c).to be_closed
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -42,9 +42,9 @@ unless defined?(JRUBY_VERSION) && !ENV["FORCE_JRUBY_RUN"]
|
|
42
42
|
c.start
|
43
43
|
ch = c.create_channel
|
44
44
|
|
45
|
-
c.
|
45
|
+
expect(c).to be_connected
|
46
46
|
c.stop
|
47
|
-
c.
|
47
|
+
expect(c).to be_closed
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -6,14 +6,13 @@ unless ENV["CI"]
|
|
6
6
|
require "bunny/test_kit"
|
7
7
|
|
8
8
|
describe "Long running [relatively to heartbeat interval] consumer that never publishes" do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
c
|
9
|
+
before :all do
|
10
|
+
@connection = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed", :automatic_recovery => false, :heartbeat_interval => 6)
|
11
|
+
@connection.start
|
13
12
|
end
|
14
13
|
|
15
14
|
after :all do
|
16
|
-
connection.close
|
15
|
+
@connection.close
|
17
16
|
end
|
18
17
|
|
19
18
|
let(:target) { 512 * 1024 * 1024 }
|
@@ -29,7 +28,7 @@ unless ENV["CI"]
|
|
29
28
|
|
30
29
|
ct = Thread.new do
|
31
30
|
t = 0
|
32
|
-
ch = connection.create_channel(nil, 6)
|
31
|
+
ch = @connection.create_channel(nil, 6)
|
33
32
|
begin
|
34
33
|
q = ch.queue(queue, :exclusive => true)
|
35
34
|
|
@@ -53,7 +52,7 @@ unless ENV["CI"]
|
|
53
52
|
|
54
53
|
pt = Thread.new do
|
55
54
|
t = 0
|
56
|
-
ch = connection.create_channel
|
55
|
+
ch = @connection.create_channel
|
57
56
|
begin
|
58
57
|
x = ch.fanout("amq.fanout")
|
59
58
|
|
data/spec/unit/bunny_spec.rb
CHANGED
@@ -2,14 +2,14 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Bunny do
|
4
4
|
it "has library version" do
|
5
|
-
Bunny::VERSION.
|
6
|
-
Bunny.version.
|
5
|
+
expect(Bunny::VERSION).not_to be_nil
|
6
|
+
expect(Bunny.version).not_to be_nil
|
7
7
|
end
|
8
8
|
|
9
9
|
|
10
10
|
it "has AMQP protocol version" do
|
11
|
-
Bunny::PROTOCOL_VERSION.
|
12
|
-
AMQ::Protocol::PROTOCOL_VERSION.
|
13
|
-
Bunny.protocol_version.
|
11
|
+
expect(Bunny::PROTOCOL_VERSION).to eq "0.9.1"
|
12
|
+
expect(AMQ::Protocol::PROTOCOL_VERSION).to eq "0.9.1"
|
13
|
+
expect(Bunny.protocol_version).to eq "0.9.1"
|
14
14
|
end
|
15
15
|
end
|
@@ -5,31 +5,31 @@ describe Bunny::Concurrent::AtomicFixnum do
|
|
5
5
|
it "allows retrieving the current value" do
|
6
6
|
af = described_class.new(0)
|
7
7
|
|
8
|
-
af.get.
|
9
|
-
af.
|
8
|
+
expect(af.get).to eq 0
|
9
|
+
expect(af).to eq 0
|
10
10
|
end
|
11
11
|
|
12
12
|
it "can be updated" do
|
13
13
|
af = described_class.new(0)
|
14
14
|
|
15
|
-
af.get.
|
15
|
+
expect(af.get).to eq 0
|
16
16
|
Thread.new do
|
17
17
|
af.set(10)
|
18
18
|
end
|
19
19
|
sleep 0.6
|
20
|
-
af.get.
|
20
|
+
expect(af.get).to eq 10
|
21
21
|
end
|
22
22
|
|
23
23
|
it "can be incremented" do
|
24
24
|
af = described_class.new(0)
|
25
25
|
|
26
|
-
af.get.
|
26
|
+
expect(af.get).to eq 0
|
27
27
|
10.times do
|
28
28
|
Thread.new do
|
29
29
|
af.increment
|
30
30
|
end
|
31
31
|
end
|
32
32
|
sleep 0.6
|
33
|
-
af.get.
|
33
|
+
expect(af.get).to eq 10
|
34
34
|
end
|
35
35
|
end
|
@@ -18,7 +18,7 @@ describe Bunny::Concurrent::Condition do
|
|
18
18
|
t.abort_on_exception = true
|
19
19
|
|
20
20
|
condition.wait
|
21
|
-
xs.
|
21
|
+
expect(xs).to eq [:notified]
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -45,7 +45,7 @@ describe Bunny::Concurrent::Condition do
|
|
45
45
|
sleep 0.25
|
46
46
|
condition.notify
|
47
47
|
sleep 0.5
|
48
|
-
xs.
|
48
|
+
expect(xs).to satisfy { |ys| ys.size == 1 && (ys.include?(:notified1) || ys.include?(:notified2)) }
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -74,7 +74,7 @@ describe Bunny::Concurrent::Condition do
|
|
74
74
|
n.times do |i|
|
75
75
|
item = "notified#{i + 1}".to_sym
|
76
76
|
|
77
|
-
@xs.
|
77
|
+
expect(@xs).to include item
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -14,7 +14,7 @@ if defined?(JRUBY_VERSION)
|
|
14
14
|
t.abort_on_exception = true
|
15
15
|
|
16
16
|
v = subject.poll(500)
|
17
|
-
v.
|
17
|
+
expect(v).to eq 10
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -28,7 +28,7 @@ if defined?(JRUBY_VERSION)
|
|
28
28
|
end
|
29
29
|
t.abort_on_exception = true
|
30
30
|
|
31
|
-
|
31
|
+
expect { subject.poll(500) }.to raise_error(::Timeout::Error)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -6,42 +6,42 @@ unless ENV["CI"]
|
|
6
6
|
50.times do |i|
|
7
7
|
it "provides the same API as SortedSet for key operations (take #{i})" do
|
8
8
|
s = described_class.new
|
9
|
-
s.length.
|
9
|
+
expect(s.length).to eq 0
|
10
10
|
|
11
11
|
s << 1
|
12
|
-
s.length.
|
12
|
+
expect(s.length).to eq 1
|
13
13
|
s << 1
|
14
|
-
s.length.
|
14
|
+
expect(s.length).to eq 1
|
15
15
|
s << 2
|
16
|
-
s.length.
|
16
|
+
expect(s.length).to eq 2
|
17
17
|
s << 3
|
18
|
-
s.length.
|
18
|
+
expect(s.length).to eq 3
|
19
19
|
s << 4
|
20
|
-
s.length.
|
20
|
+
expect(s.length).to eq 4
|
21
21
|
s << 4
|
22
22
|
s << 4
|
23
23
|
s << 4
|
24
|
-
s.length.
|
24
|
+
expect(s.length).to eq 4
|
25
25
|
s << 5
|
26
|
-
s.length.
|
26
|
+
expect(s.length).to eq 5
|
27
27
|
s << 5
|
28
28
|
s << 5
|
29
29
|
s << 5
|
30
|
-
s.length.
|
30
|
+
expect(s.length).to eq 5
|
31
31
|
s << 6
|
32
|
-
s.length.
|
32
|
+
expect(s.length).to eq 6
|
33
33
|
s << 7
|
34
|
-
s.length.
|
34
|
+
expect(s.length).to eq 7
|
35
35
|
s << 8
|
36
|
-
s.length.
|
36
|
+
expect(s.length).to eq 8
|
37
37
|
s.delete 8
|
38
|
-
s.length.
|
38
|
+
expect(s.length).to eq 7
|
39
39
|
s.delete_if { |i| i == 1 }
|
40
|
-
s.length.
|
40
|
+
expect(s.length).to eq 6
|
41
41
|
end
|
42
42
|
it "synchronizes common operations needed by Bunny (take #{i})" do
|
43
43
|
s = described_class.new
|
44
|
-
s.length.
|
44
|
+
expect(s.length).to eq 0
|
45
45
|
|
46
46
|
10.times do
|
47
47
|
Thread.new do
|
@@ -66,7 +66,7 @@ unless ENV["CI"]
|
|
66
66
|
end
|
67
67
|
sleep 0.5
|
68
68
|
|
69
|
-
s.length.
|
69
|
+
expect(s.length).to eq 6
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|