bunny 1.0.7 → 2.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +92 -87
- data/lib/amq/protocol/extensions.rb +2 -0
- data/lib/bunny/authentication/credentials_encoder.rb +2 -0
- data/lib/bunny/authentication/external_mechanism_encoder.rb +2 -0
- data/lib/bunny/authentication/plain_mechanism_encoder.rb +2 -0
- data/lib/bunny/channel.rb +485 -186
- data/lib/bunny/channel_id_allocator.rb +8 -4
- data/lib/bunny/concurrent/atomic_fixnum.rb +2 -0
- data/lib/bunny/concurrent/condition.rb +2 -0
- data/lib/bunny/concurrent/continuation_queue.rb +37 -13
- data/lib/bunny/concurrent/synchronized_sorted_set.rb +2 -0
- data/lib/bunny/consumer.rb +20 -13
- data/lib/bunny/consumer_tag_generator.rb +6 -2
- data/lib/bunny/consumer_work_pool.rb +37 -7
- data/lib/bunny/cruby/socket.rb +51 -22
- data/lib/bunny/cruby/ssl_socket.rb +68 -5
- data/lib/bunny/delivery_info.rb +3 -1
- data/lib/bunny/exceptions.rb +27 -4
- data/lib/bunny/exchange.rb +35 -29
- data/lib/bunny/framing.rb +2 -0
- data/lib/bunny/get_response.rb +85 -0
- data/lib/bunny/heartbeat_sender.rb +9 -6
- data/lib/bunny/message_properties.rb +2 -0
- data/lib/bunny/queue.rb +89 -41
- data/lib/bunny/reader_loop.rb +72 -28
- data/lib/bunny/return_info.rb +2 -0
- data/lib/bunny/session.rb +621 -225
- data/lib/bunny/socket.rb +7 -12
- data/lib/bunny/ssl_socket.rb +7 -12
- data/lib/bunny/test_kit.rb +15 -0
- data/lib/bunny/timeout.rb +3 -12
- data/lib/bunny/timestamp.rb +24 -0
- data/lib/bunny/transport.rb +223 -98
- data/lib/bunny/version.rb +2 -1
- data/lib/bunny/versioned_delivery_tag.rb +2 -0
- data/lib/bunny.rb +54 -8
- metadata +38 -224
- data/.gitignore +0 -22
- data/.rspec +0 -3
- data/.ruby-version +0 -1
- data/.travis.yml +0 -23
- data/.yardopts +0 -8
- data/ChangeLog.md +0 -1092
- data/Gemfile +0 -54
- data/LICENSE +0 -21
- data/benchmarks/basic_publish/with_128K_messages.rb +0 -35
- data/benchmarks/basic_publish/with_1k_messages.rb +0 -35
- data/benchmarks/basic_publish/with_4K_messages.rb +0 -35
- data/benchmarks/basic_publish/with_64K_messages.rb +0 -35
- data/benchmarks/channel_open.rb +0 -28
- data/benchmarks/mutex_and_monitor.rb +0 -42
- data/benchmarks/queue_declare.rb +0 -29
- data/benchmarks/queue_declare_and_bind.rb +0 -29
- data/benchmarks/queue_declare_bind_and_delete.rb +0 -29
- data/benchmarks/synchronized_sorted_set.rb +0 -53
- data/benchmarks/write_vs_write_nonblock.rb +0 -49
- data/bin/ci/before_build.sh +0 -31
- data/bunny.gemspec +0 -40
- data/examples/connection/authentication_failure.rb +0 -16
- data/examples/connection/automatic_recovery_with_basic_get.rb +0 -40
- data/examples/connection/automatic_recovery_with_client_named_queues.rb +0 -36
- data/examples/connection/automatic_recovery_with_multiple_consumers.rb +0 -46
- data/examples/connection/automatic_recovery_with_server_named_queues.rb +0 -35
- data/examples/connection/channel_level_exception.rb +0 -35
- data/examples/connection/disabled_automatic_recovery.rb +0 -34
- data/examples/connection/heartbeat.rb +0 -17
- data/examples/connection/manually_reconnecting_consumer.rb +0 -23
- data/examples/connection/manually_reconnecting_publisher.rb +0 -28
- data/examples/connection/unknown_host.rb +0 -16
- data/examples/guides/exchanges/direct_exchange_routing.rb +0 -36
- data/examples/guides/exchanges/fanout_exchange_routing.rb +0 -28
- data/examples/guides/exchanges/headers_exchange_routing.rb +0 -31
- data/examples/guides/exchanges/mandatory_messages.rb +0 -30
- data/examples/guides/extensions/alternate_exchange.rb +0 -28
- data/examples/guides/extensions/basic_nack.rb +0 -33
- data/examples/guides/extensions/connection_blocked.rb +0 -35
- data/examples/guides/extensions/consumer_cancellation_notification.rb +0 -39
- data/examples/guides/extensions/dead_letter_exchange.rb +0 -32
- data/examples/guides/extensions/exchange_to_exchange_bindings.rb +0 -29
- data/examples/guides/extensions/per_message_ttl.rb +0 -36
- data/examples/guides/extensions/per_queue_message_ttl.rb +0 -36
- data/examples/guides/extensions/publisher_confirms.rb +0 -28
- data/examples/guides/extensions/queue_lease.rb +0 -26
- data/examples/guides/extensions/sender_selected_distribution.rb +0 -32
- data/examples/guides/getting_started/blabbr.rb +0 -27
- data/examples/guides/getting_started/hello_world.rb +0 -20
- data/examples/guides/getting_started/weathr.rb +0 -47
- data/examples/guides/queues/one_off_consumer.rb +0 -23
- data/examples/guides/queues/redeliveries.rb +0 -79
- data/lib/bunny/compatibility.rb +0 -24
- data/lib/bunny/concurrent/linked_continuation_queue.rb +0 -61
- data/lib/bunny/jruby/socket.rb +0 -40
- data/lib/bunny/jruby/ssl_socket.rb +0 -53
- data/lib/bunny/system_timer.rb +0 -20
- data/profiling/basic_publish/with_4K_messages.rb +0 -33
- data/repl +0 -3
- data/spec/compatibility/queue_declare_spec.rb +0 -44
- data/spec/compatibility/queue_declare_with_default_channel_spec.rb +0 -33
- data/spec/higher_level_api/integration/basic_ack_spec.rb +0 -71
- data/spec/higher_level_api/integration/basic_cancel_spec.rb +0 -76
- data/spec/higher_level_api/integration/basic_consume_spec.rb +0 -225
- data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +0 -54
- data/spec/higher_level_api/integration/basic_get_spec.rb +0 -48
- data/spec/higher_level_api/integration/basic_nack_spec.rb +0 -79
- data/spec/higher_level_api/integration/basic_publish_spec.rb +0 -89
- data/spec/higher_level_api/integration/basic_qos_spec.rb +0 -29
- data/spec/higher_level_api/integration/basic_recover_spec.rb +0 -18
- data/spec/higher_level_api/integration/basic_reject_spec.rb +0 -74
- data/spec/higher_level_api/integration/basic_return_spec.rb +0 -33
- data/spec/higher_level_api/integration/channel_close_spec.rb +0 -25
- data/spec/higher_level_api/integration/channel_flow_spec.rb +0 -21
- data/spec/higher_level_api/integration/channel_open_spec.rb +0 -57
- data/spec/higher_level_api/integration/confirm_select_spec.rb +0 -19
- data/spec/higher_level_api/integration/connection_spec.rb +0 -400
- data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -26
- data/spec/higher_level_api/integration/consistent_hash_exchange_spec.rb +0 -50
- data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +0 -128
- data/spec/higher_level_api/integration/dead_lettering_spec.rb +0 -52
- data/spec/higher_level_api/integration/exchange_bind_spec.rb +0 -31
- data/spec/higher_level_api/integration/exchange_declare_spec.rb +0 -204
- data/spec/higher_level_api/integration/exchange_delete_spec.rb +0 -105
- data/spec/higher_level_api/integration/exchange_unbind_spec.rb +0 -40
- data/spec/higher_level_api/integration/exclusive_queue_spec.rb +0 -28
- data/spec/higher_level_api/integration/heartbeat_spec.rb +0 -31
- data/spec/higher_level_api/integration/merry_go_round_spec.rb +0 -85
- data/spec/higher_level_api/integration/message_properties_access_spec.rb +0 -95
- data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +0 -24
- data/spec/higher_level_api/integration/publisher_confirms_spec.rb +0 -77
- data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +0 -65
- data/spec/higher_level_api/integration/queue_bind_spec.rb +0 -109
- data/spec/higher_level_api/integration/queue_declare_spec.rb +0 -190
- data/spec/higher_level_api/integration/queue_delete_spec.rb +0 -41
- data/spec/higher_level_api/integration/queue_purge_spec.rb +0 -30
- data/spec/higher_level_api/integration/queue_unbind_spec.rb +0 -54
- data/spec/higher_level_api/integration/read_only_consumer_spec.rb +0 -60
- data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +0 -36
- data/spec/higher_level_api/integration/tls_connection_spec.rb +0 -127
- data/spec/higher_level_api/integration/tx_commit_spec.rb +0 -21
- data/spec/higher_level_api/integration/tx_rollback_spec.rb +0 -21
- data/spec/higher_level_api/integration/with_channel_spec.rb +0 -25
- data/spec/issues/issue100_spec.rb +0 -42
- data/spec/issues/issue141_spec.rb +0 -44
- data/spec/issues/issue78_spec.rb +0 -75
- data/spec/issues/issue83_spec.rb +0 -31
- data/spec/issues/issue97_attachment.json +0 -1
- data/spec/issues/issue97_spec.rb +0 -176
- data/spec/lower_level_api/integration/basic_cancel_spec.rb +0 -69
- data/spec/lower_level_api/integration/basic_consume_spec.rb +0 -100
- data/spec/spec_helper.rb +0 -64
- data/spec/stress/channel_open_stress_spec.rb +0 -51
- data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +0 -28
- data/spec/stress/concurrent_consumers_stress_spec.rb +0 -69
- data/spec/stress/concurrent_publishers_stress_spec.rb +0 -57
- data/spec/stress/connection_open_close_spec.rb +0 -40
- data/spec/stress/long_running_consumer_spec.rb +0 -83
- data/spec/tls/cacert.pem +0 -18
- data/spec/tls/client_cert.pem +0 -18
- data/spec/tls/client_key.pem +0 -27
- data/spec/tls/server_cert.pem +0 -18
- data/spec/tls/server_key.pem +0 -27
- data/spec/unit/bunny_spec.rb +0 -15
- data/spec/unit/concurrent/atomic_fixnum_spec.rb +0 -35
- data/spec/unit/concurrent/condition_spec.rb +0 -82
- data/spec/unit/concurrent/linked_continuation_queue_spec.rb +0 -35
- data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +0 -73
- data/spec/unit/system_timer_spec.rb +0 -10
- data/spec/unit/version_delivery_tag_spec.rb +0 -28
@@ -1,33 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Exchange, "#publish" do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
connection.close if connection.open?
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
context "with :mandatory => true and a bad [no routes] routing key" do
|
16
|
-
it "causes a message to be returned" do
|
17
|
-
ch = connection.create_channel
|
18
|
-
x = ch.default_exchange
|
19
|
-
|
20
|
-
returned = []
|
21
|
-
x.on_return do |basic_deliver, properties, content|
|
22
|
-
returned << content
|
23
|
-
end
|
24
|
-
|
25
|
-
x.publish("xyzzy", :routing_key => rand.to_s, :mandatory => true)
|
26
|
-
sleep 0.5
|
27
|
-
|
28
|
-
returned.should include("xyzzy")
|
29
|
-
|
30
|
-
ch.close
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Channel, "when closed" do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
connection.close
|
12
|
-
end
|
13
|
-
|
14
|
-
it "releases the id" do
|
15
|
-
ch = connection.create_channel
|
16
|
-
n = ch.number
|
17
|
-
|
18
|
-
ch.should be_open
|
19
|
-
ch.close
|
20
|
-
ch.should be_closed
|
21
|
-
|
22
|
-
# a new channel with the same id can be created
|
23
|
-
connection.create_channel(n)
|
24
|
-
end
|
25
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Channel, "#flow" do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
connection.close
|
12
|
-
end
|
13
|
-
|
14
|
-
it "is supported" do
|
15
|
-
ch = connection.create_channel
|
16
|
-
|
17
|
-
ch.flow(true).should be_instance_of(AMQ::Protocol::Channel::FlowOk)
|
18
|
-
ch.flow(false).should be_instance_of(AMQ::Protocol::Channel::FlowOk)
|
19
|
-
ch.flow(true).should be_instance_of(AMQ::Protocol::Channel::FlowOk)
|
20
|
-
end
|
21
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Channel, "when opened" do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
connection.close
|
12
|
-
end
|
13
|
-
|
14
|
-
context "without explicitly provided id" do
|
15
|
-
it "gets an allocated id and is successfully opened" do
|
16
|
-
connection.should be_connected
|
17
|
-
ch = connection.create_channel
|
18
|
-
ch.should be_open
|
19
|
-
|
20
|
-
ch.id.should be > 0
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "with an explicitly provided id = 0" do
|
25
|
-
it "raises ArgumentError" do
|
26
|
-
connection.should be_connected
|
27
|
-
expect {
|
28
|
-
connection.create_channel(0)
|
29
|
-
}.to raise_error(ArgumentError)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
context "with explicitly provided id" do
|
35
|
-
it "uses that id and is successfully opened" do
|
36
|
-
ch = connection.create_channel(767)
|
37
|
-
connection.should be_connected
|
38
|
-
ch.should be_open
|
39
|
-
|
40
|
-
ch.id.should == 767
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
context "with explicitly provided id that is already taken" do
|
47
|
-
it "reuses the channel that is already opened" do
|
48
|
-
ch = connection.create_channel(767)
|
49
|
-
connection.should be_connected
|
50
|
-
ch.should be_open
|
51
|
-
|
52
|
-
ch.id.should == 767
|
53
|
-
|
54
|
-
connection.create_channel(767).should == ch
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Channel, "#confirm_select" do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
6
|
-
c.start
|
7
|
-
c
|
8
|
-
end
|
9
|
-
|
10
|
-
after :each do
|
11
|
-
connection.close if connection.open?
|
12
|
-
end
|
13
|
-
|
14
|
-
it "is supported" do
|
15
|
-
connection.with_channel do |ch|
|
16
|
-
ch.confirm_select
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,400 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Session do
|
4
|
-
let(:port) { AMQ::Protocol::DEFAULT_PORT }
|
5
|
-
let(:username) { "guest" }
|
6
|
-
|
7
|
-
let(:tls_port) { AMQ::Protocol::TLS_PORT }
|
8
|
-
|
9
|
-
context "initialized via connection URI" do
|
10
|
-
after :each do
|
11
|
-
subject.close if subject.open?
|
12
|
-
end
|
13
|
-
|
14
|
-
context "when schema is not one of [amqp, amqps]" do
|
15
|
-
it "raises ArgumentError" do
|
16
|
-
expect {
|
17
|
-
described_class.new("http://127.0.0.1")
|
18
|
-
}.to raise_error(ArgumentError, /amqp or amqps schema/)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
it "handles amqp:// URIs w/o path part" do
|
24
|
-
session = described_class.new("amqp://127.0.0.1")
|
25
|
-
session.start
|
26
|
-
|
27
|
-
session.vhost.should == "/"
|
28
|
-
session.host.should == "127.0.0.1"
|
29
|
-
session.port.should == 5672
|
30
|
-
session.ssl?.should be_false
|
31
|
-
|
32
|
-
session.close
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
context "when URI ends in a slash" do
|
37
|
-
it "parses vhost as an empty string" do
|
38
|
-
session = described_class.new("amqp://127.0.0.1/")
|
39
|
-
|
40
|
-
session.hostname.should == "127.0.0.1"
|
41
|
-
session.port.should == 5672
|
42
|
-
session.vhost.should == ""
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context "when URI is amqp://dev.rabbitmq.com/a/path/with/slashes" do
|
47
|
-
it "raises an ArgumentError" do
|
48
|
-
lambda { described_class.new("amqp://dev.rabbitmq.com/a/path/with/slashes") }.should raise_error(ArgumentError)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
context "initialized with all defaults" do
|
57
|
-
it "provides a way to fine tune socket options" do
|
58
|
-
conn = Bunny.new
|
59
|
-
conn.start
|
60
|
-
conn.transport.socket.should respond_to(:setsockopt)
|
61
|
-
|
62
|
-
conn.close
|
63
|
-
end
|
64
|
-
|
65
|
-
it "successfully negotiates the connection" do
|
66
|
-
conn = Bunny.new
|
67
|
-
conn.start
|
68
|
-
conn.should be_connected
|
69
|
-
|
70
|
-
conn.server_properties.should_not be_nil
|
71
|
-
conn.server_capabilities.should_not be_nil
|
72
|
-
|
73
|
-
props = conn.server_properties
|
74
|
-
|
75
|
-
props["product"].should_not be_nil
|
76
|
-
props["platform"].should_not be_nil
|
77
|
-
props["version"].should_not be_nil
|
78
|
-
|
79
|
-
conn.close
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
unless ENV["CI"]
|
84
|
-
context "initialized with TCP connection timeout = 5" do
|
85
|
-
it "successfully connects" do
|
86
|
-
conn = described_class.new(:connection_timeout => 5)
|
87
|
-
conn.start
|
88
|
-
conn.should be_connected
|
89
|
-
|
90
|
-
conn.server_properties.should_not be_nil
|
91
|
-
conn.server_capabilities.should_not be_nil
|
92
|
-
|
93
|
-
props = conn.server_properties
|
94
|
-
|
95
|
-
props["product"].should_not be_nil
|
96
|
-
props["platform"].should_not be_nil
|
97
|
-
props["version"].should_not be_nil
|
98
|
-
|
99
|
-
conn.close
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
context "initialized with :host => 127.0.0.1" do
|
104
|
-
after :each do
|
105
|
-
subject.close if subject.open?
|
106
|
-
end
|
107
|
-
|
108
|
-
let(:host) { "127.0.0.1" }
|
109
|
-
subject do
|
110
|
-
described_class.new(:host => host)
|
111
|
-
end
|
112
|
-
|
113
|
-
it "uses hostname = 127.0.0.1" do
|
114
|
-
subject.host.should == host
|
115
|
-
subject.hostname.should == host
|
116
|
-
end
|
117
|
-
|
118
|
-
it "uses port 5672" do
|
119
|
-
subject.port.should == port
|
120
|
-
end
|
121
|
-
|
122
|
-
it "uses username = guest" do
|
123
|
-
subject.username.should == username
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
context "initialized with :hostname => localhost" do
|
128
|
-
after :each do
|
129
|
-
subject.close if subject.open?
|
130
|
-
end
|
131
|
-
|
132
|
-
let(:host) { "localhost" }
|
133
|
-
let(:subject) { described_class.new(:hostname => host) }
|
134
|
-
|
135
|
-
it "uses hostname = localhost" do
|
136
|
-
subject.host.should == host
|
137
|
-
subject.hostname.should == host
|
138
|
-
end
|
139
|
-
|
140
|
-
it "uses port 5672" do
|
141
|
-
subject.port.should == port
|
142
|
-
end
|
143
|
-
|
144
|
-
it "uses username = guest" do
|
145
|
-
subject.username.should == username
|
146
|
-
subject.user.should == username
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context "initialized with :channel_max => 4096" do
|
151
|
-
after :each do
|
152
|
-
subject.close if subject.open?
|
153
|
-
end
|
154
|
-
|
155
|
-
let(:channel_max) { 1024 }
|
156
|
-
let(:subject) { described_class.new(:channel_max => channel_max) }
|
157
|
-
|
158
|
-
# this assumes RabbitMQ has no lower value configured. In 3.2
|
159
|
-
# it is 0 (no limit) by default and 1024 is still a fairly low value
|
160
|
-
# for future releases. MK.
|
161
|
-
it "negotiates channel max to be 1024" do
|
162
|
-
subject.start
|
163
|
-
subject.channel_max.should == channel_max
|
164
|
-
|
165
|
-
subject.close
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
context "initialized with :ssl => true" do
|
170
|
-
let(:subject) do
|
171
|
-
described_class.new(:user => "bunny_gem",
|
172
|
-
:password => "bunny_password",
|
173
|
-
:vhost => "bunny_testbed",
|
174
|
-
:ssl => true,
|
175
|
-
:ssl_cert => "spec/tls/client_cert.pem",
|
176
|
-
:ssl_key => "spec/tls/client_key.pem",
|
177
|
-
:ssl_ca_certificates => ["./spec/tls/cacert.pem"])
|
178
|
-
end
|
179
|
-
|
180
|
-
it "uses TLS port" do
|
181
|
-
subject.port.should == tls_port
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
context "initialized with :tls => true" do
|
186
|
-
let(:subject) do
|
187
|
-
described_class.new(:user => "bunny_gem",
|
188
|
-
:password => "bunny_password",
|
189
|
-
:vhost => "bunny_testbed",
|
190
|
-
:tls => true,
|
191
|
-
:tls_cert => "spec/tls/client_cert.pem",
|
192
|
-
:tls_key => "spec/tls/client_key.pem",
|
193
|
-
:tls_ca_certificates => ["./spec/tls/cacert.pem"])
|
194
|
-
end
|
195
|
-
|
196
|
-
it "uses TLS port" do
|
197
|
-
subject.port.should == tls_port
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
|
203
|
-
context "initialized with :host => 127.0.0.1 and non-default credentials" do
|
204
|
-
after :each do
|
205
|
-
subject.close if subject.open?
|
206
|
-
end
|
207
|
-
|
208
|
-
let(:host) { "127.0.0.1" }
|
209
|
-
# see ./bin/ci/before_build.sh
|
210
|
-
let(:username) { "bunny_gem" }
|
211
|
-
let(:password) { "bunny_password" }
|
212
|
-
let(:vhost) { "bunny_testbed" }
|
213
|
-
|
214
|
-
subject do
|
215
|
-
described_class.new(:hostname => host, :username => username, :password => password, :virtual_host => vhost)
|
216
|
-
end
|
217
|
-
|
218
|
-
it "successfully connects" do
|
219
|
-
5.times { subject.start }
|
220
|
-
subject.should be_connected
|
221
|
-
|
222
|
-
subject.server_properties.should_not be_nil
|
223
|
-
subject.server_capabilities.should_not be_nil
|
224
|
-
|
225
|
-
props = subject.server_properties
|
226
|
-
|
227
|
-
props["product"].should_not be_nil
|
228
|
-
props["platform"].should_not be_nil
|
229
|
-
props["version"].should_not be_nil
|
230
|
-
end
|
231
|
-
|
232
|
-
it "uses hostname = 127.0.0.1" do
|
233
|
-
subject.host.should == host
|
234
|
-
subject.hostname.should == host
|
235
|
-
end
|
236
|
-
|
237
|
-
it "uses port 5672" do
|
238
|
-
subject.port.should == port
|
239
|
-
end
|
240
|
-
|
241
|
-
it "uses provided vhost" do
|
242
|
-
subject.vhost.should == vhost
|
243
|
-
subject.virtual_host.should == vhost
|
244
|
-
end
|
245
|
-
|
246
|
-
it "uses provided username" do
|
247
|
-
subject.username.should == username
|
248
|
-
end
|
249
|
-
|
250
|
-
it "uses provided password" do
|
251
|
-
subject.password.should == password
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
|
256
|
-
context "initialized with :host => 127.0.0.1 and non-default credentials (take 2)" do
|
257
|
-
after :each do
|
258
|
-
subject.close if subject.open?
|
259
|
-
end
|
260
|
-
|
261
|
-
let(:host) { "127.0.0.1" }
|
262
|
-
# see ./bin/ci/before_build.sh
|
263
|
-
let(:username) { "bunny_gem" }
|
264
|
-
let(:password) { "bunny_password" }
|
265
|
-
let(:vhost) { "bunny_testbed" }
|
266
|
-
|
267
|
-
subject do
|
268
|
-
described_class.new(:hostname => host, :user => username, :pass => password, :vhost => vhost)
|
269
|
-
end
|
270
|
-
|
271
|
-
it "successfully connects" do
|
272
|
-
subject.start
|
273
|
-
subject.should be_connected
|
274
|
-
|
275
|
-
subject.server_properties.should_not be_nil
|
276
|
-
subject.server_capabilities.should_not be_nil
|
277
|
-
|
278
|
-
props = subject.server_properties
|
279
|
-
|
280
|
-
props["product"].should_not be_nil
|
281
|
-
props["platform"].should_not be_nil
|
282
|
-
props["version"].should_not be_nil
|
283
|
-
end
|
284
|
-
|
285
|
-
it "uses hostname = 127.0.0.1" do
|
286
|
-
subject.host.should == host
|
287
|
-
subject.hostname.should == host
|
288
|
-
end
|
289
|
-
|
290
|
-
it "uses port 5672" do
|
291
|
-
subject.port.should == port
|
292
|
-
end
|
293
|
-
|
294
|
-
it "uses provided username" do
|
295
|
-
subject.username.should == username
|
296
|
-
end
|
297
|
-
|
298
|
-
it "uses provided password" do
|
299
|
-
subject.password.should == password
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
context "initialized with :host => 127.0.0.1 and non-default credentials (take 2)" do
|
306
|
-
after :each do
|
307
|
-
subject.close if subject.open?
|
308
|
-
end
|
309
|
-
|
310
|
-
let(:host) { "127.0.0.1" }
|
311
|
-
# see ./bin/ci/before_build.sh
|
312
|
-
let(:username) { "bunny_gem" }
|
313
|
-
let(:password) { "bunny_password" }
|
314
|
-
let(:vhost) { "bunny_testbed" }
|
315
|
-
let(:interval) { 1 }
|
316
|
-
|
317
|
-
subject do
|
318
|
-
described_class.new(:hostname => host, :user => username, :pass => password, :vhost => vhost, :heartbeat_interval => interval)
|
319
|
-
end
|
320
|
-
|
321
|
-
it "successfully connects" do
|
322
|
-
subject.start
|
323
|
-
subject.should be_connected
|
324
|
-
|
325
|
-
subject.server_properties.should_not be_nil
|
326
|
-
subject.server_capabilities.should_not be_nil
|
327
|
-
|
328
|
-
props = subject.server_properties
|
329
|
-
|
330
|
-
props["product"].should_not be_nil
|
331
|
-
props["platform"].should_not be_nil
|
332
|
-
props["version"].should_not be_nil
|
333
|
-
props["capabilities"].should_not be_nil
|
334
|
-
|
335
|
-
# this is negotiated with RabbitMQ, so we need to
|
336
|
-
# establish the connection first
|
337
|
-
subject.heartbeat.should == interval
|
338
|
-
end
|
339
|
-
end
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
context "initialized with :host => 127.0.0.1 and INVALID credentials" do
|
344
|
-
let(:host) { "127.0.0.1" }
|
345
|
-
# see ./bin/ci/before_build.sh
|
346
|
-
let(:username) { "bunny_gem#{Time.now.to_i}" }
|
347
|
-
let(:password) { "sdjkfhsdf8ysd8fy8" }
|
348
|
-
let(:vhost) { "___sd89aysd98789" }
|
349
|
-
|
350
|
-
subject do
|
351
|
-
described_class.new(:hostname => host, :user => username, :pass => password, :vhost => vhost)
|
352
|
-
end
|
353
|
-
|
354
|
-
it "fails to connect" do
|
355
|
-
lambda do
|
356
|
-
subject.start
|
357
|
-
end.should raise_error(Bunny::PossibleAuthenticationFailureError)
|
358
|
-
end
|
359
|
-
|
360
|
-
it "uses provided username" do
|
361
|
-
subject.username.should == username
|
362
|
-
end
|
363
|
-
|
364
|
-
it "uses provided password" do
|
365
|
-
subject.password.should == password
|
366
|
-
end
|
367
|
-
end
|
368
|
-
|
369
|
-
|
370
|
-
context "initialized with a disconnected host" do
|
371
|
-
it "fails to connect" do
|
372
|
-
lambda do
|
373
|
-
c = described_class.new(:port => 38000)
|
374
|
-
c.start
|
375
|
-
end.should raise_error(Bunny::TCPConnectionFailed)
|
376
|
-
end
|
377
|
-
|
378
|
-
it "is not connected" do
|
379
|
-
begin
|
380
|
-
c = described_class.new(:port => 38000)
|
381
|
-
c.start
|
382
|
-
rescue Bunny::TCPConnectionFailed => e
|
383
|
-
true
|
384
|
-
end
|
385
|
-
|
386
|
-
subject.status.should == :not_connected
|
387
|
-
end
|
388
|
-
|
389
|
-
it "is not open" do
|
390
|
-
begin
|
391
|
-
c = described_class.new(:port => 38000)
|
392
|
-
c.start
|
393
|
-
rescue Bunny::TCPConnectionFailed => e
|
394
|
-
true
|
395
|
-
end
|
396
|
-
|
397
|
-
subject.should_not be_open
|
398
|
-
end
|
399
|
-
end
|
400
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Session do
|
4
|
-
it "can be closed" do
|
5
|
-
c = Bunny.new(:automatically_recover => false)
|
6
|
-
c.start
|
7
|
-
ch = c.create_channel
|
8
|
-
|
9
|
-
c.should be_connected
|
10
|
-
c.stop
|
11
|
-
c.should be_closed
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
describe Bunny::Session, "in a single threaded mode" do
|
17
|
-
it "can be closed" do
|
18
|
-
c = Bunny.new(:automatically_recover => false, :threaded => false)
|
19
|
-
c.start
|
20
|
-
ch = c.create_channel
|
21
|
-
|
22
|
-
c.should be_connected
|
23
|
-
c.stop
|
24
|
-
c.should be_closed
|
25
|
-
end
|
26
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
unless ENV["CI"]
|
5
|
-
describe "x-consistent-hash exchange" do
|
6
|
-
let(:connection) do
|
7
|
-
c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
|
8
|
-
c.start
|
9
|
-
c
|
10
|
-
end
|
11
|
-
|
12
|
-
after :each do
|
13
|
-
connection.close
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:list) { Range.new(0, 6).to_a.map(&:to_s) }
|
17
|
-
|
18
|
-
let(:m) { 1500 }
|
19
|
-
|
20
|
-
it "distributes messages between queues bound with the same routing key" do
|
21
|
-
ch = connection.create_channel
|
22
|
-
body = "сообщение"
|
23
|
-
# requires the consistent hash exchange plugin,
|
24
|
-
# enable it with
|
25
|
-
#
|
26
|
-
# $ [sudo] rabbitmq-plugins enable rabbitmq_consistent_hash_exchange
|
27
|
-
x = ch.exchange("bunny.stress.concurrent.consumers", :type => "x-consistent-hash", :durable => true)
|
28
|
-
|
29
|
-
qs = []
|
30
|
-
|
31
|
-
q1 = ch.queue("", :exclusive => true).bind(x, :routing_key => "5")
|
32
|
-
q2 = ch.queue("", :exclusive => true).bind(x, :routing_key => "5")
|
33
|
-
|
34
|
-
sleep 1.0
|
35
|
-
|
36
|
-
5.times do |i|
|
37
|
-
m.times do
|
38
|
-
x.publish(body, :routing_key => list.sample)
|
39
|
-
end
|
40
|
-
puts "Published #{(i + 1) * m} tiny messages..."
|
41
|
-
end
|
42
|
-
|
43
|
-
sleep 2.0
|
44
|
-
q1.message_count.should be > 100
|
45
|
-
q2.message_count.should be > 100
|
46
|
-
|
47
|
-
ch.close
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|