bunny 2.19.0 → 2.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -32
- data/lib/bunny/channel.rb +86 -10
- data/lib/bunny/consumer.rb +2 -2
- data/lib/bunny/delivery_info.rb +1 -1
- data/lib/bunny/queue.rb +33 -2
- data/lib/bunny/session.rb +1 -1
- data/lib/bunny/transport.rb +30 -1
- data/lib/bunny/version.rb +1 -1
- data/lib/bunny.rb +45 -4
- metadata +4 -144
- data/spec/config/enabled_plugins +0 -1
- data/spec/config/rabbitmq.conf +0 -13
- data/spec/higher_level_api/integration/basic_ack_spec.rb +0 -230
- data/spec/higher_level_api/integration/basic_cancel_spec.rb +0 -142
- data/spec/higher_level_api/integration/basic_consume_spec.rb +0 -357
- 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 -80
- data/spec/higher_level_api/integration/basic_nack_spec.rb +0 -82
- data/spec/higher_level_api/integration/basic_publish_spec.rb +0 -74
- data/spec/higher_level_api/integration/basic_qos_spec.rb +0 -57
- data/spec/higher_level_api/integration/basic_reject_spec.rb +0 -152
- data/spec/higher_level_api/integration/basic_return_spec.rb +0 -33
- data/spec/higher_level_api/integration/channel_close_spec.rb +0 -66
- data/spec/higher_level_api/integration/channel_open_spec.rb +0 -57
- data/spec/higher_level_api/integration/connection_recovery_spec.rb +0 -483
- data/spec/higher_level_api/integration/connection_spec.rb +0 -589
- data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -83
- data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +0 -128
- data/spec/higher_level_api/integration/dead_lettering_spec.rb +0 -75
- data/spec/higher_level_api/integration/exchange_bind_spec.rb +0 -31
- data/spec/higher_level_api/integration/exchange_declare_spec.rb +0 -237
- 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 -49
- 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 -191
- data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +0 -87
- data/spec/higher_level_api/integration/queue_bind_spec.rb +0 -109
- data/spec/higher_level_api/integration/queue_declare_spec.rb +0 -285
- 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 -255
- data/spec/higher_level_api/integration/toxiproxy_spec.rb +0 -76
- 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 -43
- data/spec/issues/issue202_spec.rb +0 -15
- data/spec/issues/issue224_spec.rb +0 -40
- data/spec/issues/issue465_spec.rb +0 -32
- data/spec/issues/issue549_spec.rb +0 -30
- data/spec/issues/issue609_spec.rb +0 -84
- data/spec/issues/issue78_spec.rb +0 -72
- data/spec/issues/issue83_spec.rb +0 -30
- data/spec/issues/issue97_attachment.json +0 -1
- data/spec/issues/issue97_spec.rb +0 -175
- data/spec/lower_level_api/integration/basic_cancel_spec.rb +0 -83
- data/spec/lower_level_api/integration/basic_consume_spec.rb +0 -99
- data/spec/spec_helper.rb +0 -47
- data/spec/stress/channel_close_stress_spec.rb +0 -64
- data/spec/stress/channel_open_stress_spec.rb +0 -84
- data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +0 -28
- data/spec/stress/concurrent_consumers_stress_spec.rb +0 -71
- data/spec/stress/concurrent_publishers_stress_spec.rb +0 -54
- data/spec/stress/connection_open_close_spec.rb +0 -52
- data/spec/stress/merry_go_round_spec.rb +0 -105
- data/spec/toxiproxy_helper.rb +0 -28
- 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/exchange_recovery_spec.rb +0 -39
- data/spec/unit/version_delivery_tag_spec.rb +0 -28
@@ -1,255 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
require "socket"
|
5
|
-
|
6
|
-
CERTIFICATE_DIR = ENV.fetch("BUNNY_CERTIFICATE_DIR", "./spec/tls")
|
7
|
-
puts "Will use certificates from #{CERTIFICATE_DIR}"
|
8
|
-
|
9
|
-
shared_examples_for "successful TLS connection" do
|
10
|
-
it "succeeds", skip: ENV["CI"] do
|
11
|
-
expect(subject).to be_tls
|
12
|
-
ch = subject.create_channel
|
13
|
-
ch.confirm_select
|
14
|
-
|
15
|
-
q = ch.queue("", exclusive: true)
|
16
|
-
x = ch.default_exchange
|
17
|
-
|
18
|
-
x.publish("xyzzy", routing_key: q.name).
|
19
|
-
publish("xyzzy", routing_key: q.name).
|
20
|
-
publish("xyzzy", routing_key: q.name).
|
21
|
-
publish("xyzzy", routing_key: q.name)
|
22
|
-
|
23
|
-
x.wait_for_confirms
|
24
|
-
expect(q.message_count).to eq 4
|
25
|
-
|
26
|
-
i = 0
|
27
|
-
q.subscribe do |delivery_info, _, payload|
|
28
|
-
i += 1
|
29
|
-
end
|
30
|
-
sleep 1.0
|
31
|
-
expect(i).to eq 4
|
32
|
-
expect(q.message_count).to eq 0
|
33
|
-
|
34
|
-
ch.close
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def local_hostname
|
39
|
-
ENV.fetch("BUNNY_RABBITMQ_HOSTNAME", "localhost")
|
40
|
-
end
|
41
|
-
|
42
|
-
context "initialized with tls: true", skip: ENV["CI"] do
|
43
|
-
let(:subject) do
|
44
|
-
Bunny.new(
|
45
|
-
hostname: local_hostname(),
|
46
|
-
user: "bunny_gem",
|
47
|
-
password: "bunny_password",
|
48
|
-
vhost: "bunny_testbed",
|
49
|
-
tls: true,
|
50
|
-
verify_peer: verify_peer,
|
51
|
-
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
52
|
-
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
53
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"])
|
54
|
-
end
|
55
|
-
|
56
|
-
context "peer verification is off" do
|
57
|
-
let(:verify_peer) { false }
|
58
|
-
|
59
|
-
it "uses TLS port" do
|
60
|
-
expect(subject.port).to eq AMQ::Protocol::TLS_PORT
|
61
|
-
end
|
62
|
-
|
63
|
-
it "sends the SNI details" do
|
64
|
-
# https://github.com/ruby-amqp/bunny/issues/440
|
65
|
-
subject.start
|
66
|
-
expect(subject.transport.socket.hostname).to_not be_empty
|
67
|
-
end
|
68
|
-
|
69
|
-
after :each do
|
70
|
-
subject.close
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context "peer verification is on" do
|
75
|
-
let(:verify_peer) { true }
|
76
|
-
|
77
|
-
it "uses TLS port" do
|
78
|
-
expect(subject.port).to eq AMQ::Protocol::TLS_PORT
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "TLS connection to RabbitMQ with client certificates", skip: ENV["CI"] do
|
84
|
-
let(:subject) do
|
85
|
-
c = Bunny.new(
|
86
|
-
hostname: local_hostname(),
|
87
|
-
username: "bunny_gem",
|
88
|
-
password: "bunny_password",
|
89
|
-
vhost: "bunny_testbed",
|
90
|
-
tls: true,
|
91
|
-
tls_protocol: :TLSv1_2,
|
92
|
-
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
93
|
-
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
94
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
95
|
-
verify_peer: false)
|
96
|
-
c.start
|
97
|
-
c
|
98
|
-
end
|
99
|
-
|
100
|
-
after :each do
|
101
|
-
subject.close
|
102
|
-
end
|
103
|
-
|
104
|
-
include_examples "successful TLS connection"
|
105
|
-
end
|
106
|
-
|
107
|
-
|
108
|
-
describe "TLS connection to RabbitMQ without client certificates", skip: ENV["CI"] do
|
109
|
-
let(:subject) do
|
110
|
-
c = Bunny.new(
|
111
|
-
hostname: local_hostname(),
|
112
|
-
username: "bunny_gem",
|
113
|
-
password: "bunny_password",
|
114
|
-
vhost: "bunny_testbed",
|
115
|
-
tls: true,
|
116
|
-
tls_protocol: :TLSv1_2,
|
117
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
118
|
-
verify_peer: false)
|
119
|
-
c.start
|
120
|
-
c
|
121
|
-
end
|
122
|
-
|
123
|
-
after :each do
|
124
|
-
subject.close
|
125
|
-
end
|
126
|
-
|
127
|
-
include_examples "successful TLS connection"
|
128
|
-
end
|
129
|
-
|
130
|
-
|
131
|
-
describe "TLS connection to RabbitMQ with a connection string", skip: ENV["CI"] do
|
132
|
-
let(:subject) do
|
133
|
-
c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
|
134
|
-
tls_protocol: :TLSv1_2,
|
135
|
-
tls_cert: "#{CERTIFICATE_DIR}/client_certificate.pem",
|
136
|
-
tls_key: "#{CERTIFICATE_DIR}/client_key.pem",
|
137
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
138
|
-
verify_peer: false)
|
139
|
-
c.start
|
140
|
-
c
|
141
|
-
end
|
142
|
-
|
143
|
-
after :each do
|
144
|
-
subject.close
|
145
|
-
end
|
146
|
-
|
147
|
-
include_examples "successful TLS connection"
|
148
|
-
|
149
|
-
context "when URI contains query parameters" do
|
150
|
-
subject(:session) do
|
151
|
-
Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed?heartbeat=10&connection_timeout=100&channel_max=1000&verify=false&cacertfile=#{CERTIFICATE_DIR}/ca_certificate.pem&certfile=#{CERTIFICATE_DIR}/client_certificate.pem&keyfile=#{CERTIFICATE_DIR}/client_key.pem")
|
152
|
-
end
|
153
|
-
|
154
|
-
it "parses extra connection parameters" do
|
155
|
-
session.start
|
156
|
-
|
157
|
-
expect(session.uses_tls?).to eq(true)
|
158
|
-
expect(session.transport.verify_peer).to eq(false)
|
159
|
-
expect(session.transport.tls_ca_certificates).to eq(["#{CERTIFICATE_DIR}/ca_certificate.pem"])
|
160
|
-
expect(session.transport.tls_certificate_path).to eq("#{CERTIFICATE_DIR}/client_certificate.pem")
|
161
|
-
expect(session.transport.tls_key_path).to eq("#{CERTIFICATE_DIR}/client_key.pem")
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
|
167
|
-
describe "TLS connection to RabbitMQ with a connection string and w/o client certificate and key", skip: ENV["CI"] do
|
168
|
-
let(:subject) do
|
169
|
-
c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
|
170
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
171
|
-
tls_protocol: :TLSv1_2,
|
172
|
-
verify_peer: verify_peer)
|
173
|
-
c.start
|
174
|
-
c
|
175
|
-
end
|
176
|
-
|
177
|
-
after :each do
|
178
|
-
subject.close
|
179
|
-
end
|
180
|
-
|
181
|
-
context "peer verification is off" do
|
182
|
-
let(:verify_peer) { false }
|
183
|
-
|
184
|
-
include_examples "successful TLS connection"
|
185
|
-
|
186
|
-
it "sends the SNI details" do
|
187
|
-
# https://github.com/ruby-amqp/bunny/issues/440
|
188
|
-
expect(subject.transport.socket.hostname).to_not be_empty
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
context "peer verification is on" do
|
193
|
-
let(:verify_peer) { true }
|
194
|
-
|
195
|
-
include_examples "successful TLS connection"
|
196
|
-
|
197
|
-
it "sends the SNI details" do
|
198
|
-
# https://github.com/ruby-amqp/bunny/issues/440
|
199
|
-
expect(subject.transport.socket.hostname).to_not be_empty
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
describe "TLS connection to RabbitMQ w/o client certificate", skip: ENV["CI"] do
|
205
|
-
let(:subject) do
|
206
|
-
c = Bunny.new("amqps://bunny_gem:bunny_password@#{local_hostname()}/bunny_testbed",
|
207
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
208
|
-
tls_protocol: :TLSv1_2,
|
209
|
-
verify_peer: false,
|
210
|
-
tls_silence_warnings: should_silence_warnings)
|
211
|
-
c.start
|
212
|
-
c
|
213
|
-
end
|
214
|
-
|
215
|
-
after :each do
|
216
|
-
subject.close
|
217
|
-
end
|
218
|
-
|
219
|
-
context "TLS-related warnings are enabled" do
|
220
|
-
let(:should_silence_warnings) { false }
|
221
|
-
|
222
|
-
include_examples "successful TLS connection"
|
223
|
-
end
|
224
|
-
|
225
|
-
context "TLS-related warnings are silenced" do
|
226
|
-
let(:should_silence_warnings) { true }
|
227
|
-
|
228
|
-
include_examples "successful TLS connection"
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
|
233
|
-
describe "TLS connection to RabbitMQ with client certificates provided inline", skip: ENV["CI"] do
|
234
|
-
let(:subject) do
|
235
|
-
c = Bunny.new(
|
236
|
-
hostname: local_hostname(),
|
237
|
-
username: "bunny_gem",
|
238
|
-
password: "bunny_password",
|
239
|
-
vhost: "bunny_testbed",
|
240
|
-
tls: true,
|
241
|
-
tls_cert: File.read("#{CERTIFICATE_DIR}/client_certificate.pem"),
|
242
|
-
tls_key: File.read("#{CERTIFICATE_DIR}/client_key.pem"),
|
243
|
-
tls_ca_certificates: ["#{CERTIFICATE_DIR}/ca_certificate.pem"],
|
244
|
-
tls_protocol: :TLSv1_2,
|
245
|
-
verify_peer: false)
|
246
|
-
c.start
|
247
|
-
c
|
248
|
-
end
|
249
|
-
|
250
|
-
after :each do
|
251
|
-
subject.close
|
252
|
-
end
|
253
|
-
|
254
|
-
include_examples "successful TLS connection"
|
255
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require_relative "../../toxiproxy_helper"
|
3
|
-
|
4
|
-
if ::Toxiproxy.running?
|
5
|
-
describe Bunny::Channel, "#basic_publish" do
|
6
|
-
include RabbitMQ::Toxiproxy
|
7
|
-
|
8
|
-
after :each do
|
9
|
-
@connection.close if @connection.open?
|
10
|
-
end
|
11
|
-
|
12
|
-
context "when the the connection detects missed heartbeats with automatic recovery" do
|
13
|
-
before(:each) do
|
14
|
-
setup_toxiproxy
|
15
|
-
@connection = Bunny.new(user: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed",
|
16
|
-
host: "localhost:11111", heartbeat_timeout: 1, automatically_recover: true)
|
17
|
-
@connection.start
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:queue_name) { "bunny.basic.publish.queue#{rand}" }
|
21
|
-
|
22
|
-
it "raises a ConnectionClosedError" do
|
23
|
-
ch = @connection.create_channel
|
24
|
-
begin
|
25
|
-
rabbitmq_toxiproxy.down do
|
26
|
-
sleep 2
|
27
|
-
expect { ch.default_exchange.publish("", :routing_key => queue_name) }.to raise_error(Bunny::ConnectionClosedError)
|
28
|
-
end
|
29
|
-
ensure
|
30
|
-
cleanup_toxiproxy
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "when the the connection detects missed heartbeats without automatic recovery" do
|
36
|
-
before(:each) do
|
37
|
-
setup_toxiproxy
|
38
|
-
@connection = Bunny.new(user: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed",
|
39
|
-
host: "localhost:11111", heartbeat_timeout: 1, automatically_recover: false, threaded: false)
|
40
|
-
@connection.start
|
41
|
-
end
|
42
|
-
|
43
|
-
it "does not raise an exception on session thread" do
|
44
|
-
rabbitmq_toxiproxy.down do
|
45
|
-
sleep 5
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "recovery attempt limit that's exceeded" do
|
51
|
-
before(:each) do
|
52
|
-
setup_toxiproxy
|
53
|
-
@connection = Bunny.new(user: "bunny_gem", password: "bunny_password", vhost: "bunny_testbed",
|
54
|
-
host: "localhost:11111", heartbeat_timeout: 1, automatically_recover: true, network_recovery_interval: 1,
|
55
|
-
recovery_attempts: 2, reset_recovery_attempts_after_reconnection: true,
|
56
|
-
disconnect_timeout: 1)
|
57
|
-
@connection.start
|
58
|
-
end
|
59
|
-
|
60
|
-
it "permanently closes connection" do
|
61
|
-
expect(@connection.open?).to be(true)
|
62
|
-
|
63
|
-
rabbitmq_toxiproxy.down do
|
64
|
-
sleep 5
|
65
|
-
end
|
66
|
-
# give the connection one last chance to recover
|
67
|
-
sleep 3
|
68
|
-
|
69
|
-
expect(@connection.open?).to be(false)
|
70
|
-
expect(@connection.closed?).to be(true)
|
71
|
-
end
|
72
|
-
end # context
|
73
|
-
end # describe
|
74
|
-
else
|
75
|
-
puts "Toxiproxy isn't running, some examples will be skipped"
|
76
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Channel, "#tx_commit" do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(username: "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
|
-
ch = connection.create_channel
|
16
|
-
ch.tx_select
|
17
|
-
ch.tx_commit
|
18
|
-
|
19
|
-
ch.close
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Channel, "#tx_rollback" do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(username: "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
|
-
ch = connection.create_channel
|
16
|
-
ch.tx_select
|
17
|
-
ch.tx_rollback
|
18
|
-
|
19
|
-
ch.close
|
20
|
-
end
|
21
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Channel, "#with_channel" do
|
4
|
-
let(:connection) do
|
5
|
-
c = Bunny.new(username: "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 "closes if the block throws an exception" do
|
15
|
-
ch = nil
|
16
|
-
begin
|
17
|
-
connection.with_channel do |wch|
|
18
|
-
ch = wch
|
19
|
-
raise Exception.new
|
20
|
-
end
|
21
|
-
rescue Exception
|
22
|
-
end
|
23
|
-
expect(ch).to be_closed
|
24
|
-
end
|
25
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
unless ENV["CI"]
|
4
|
-
describe Bunny::Channel, "#basic_publish" do
|
5
|
-
before :all do
|
6
|
-
@connection = Bunny.new(username: "bunny_gem",
|
7
|
-
password: "bunny_password",
|
8
|
-
vhost: "bunny_testbed",
|
9
|
-
write_timeout: 0,
|
10
|
-
read_timeout: 0)
|
11
|
-
@connection.start
|
12
|
-
end
|
13
|
-
|
14
|
-
after :all do
|
15
|
-
@connection.close if @connection.open?
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
context "when publishing thousands of messages" do
|
20
|
-
let(:n) { 2_000 }
|
21
|
-
let(:m) { 10 }
|
22
|
-
|
23
|
-
it "successfully publishers them all" do
|
24
|
-
ch = @connection.create_channel
|
25
|
-
|
26
|
-
q = ch.queue("", exclusive: true)
|
27
|
-
x = ch.default_exchange
|
28
|
-
|
29
|
-
body = "x" * 1024
|
30
|
-
m.times do |i|
|
31
|
-
n.times do
|
32
|
-
x.publish(body, routing_key: q.name)
|
33
|
-
end
|
34
|
-
puts "Published #{i * n} 1K messages..."
|
35
|
-
end
|
36
|
-
|
37
|
-
q.purge
|
38
|
-
ch.close
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "Registering 2nd exclusive consumer on queue" do
|
4
|
-
before :all do
|
5
|
-
@connection = Bunny.new(:user => "bunny_gem", password: "bunny_password", :vhost => "bunny_testbed")
|
6
|
-
@connection.start
|
7
|
-
end
|
8
|
-
|
9
|
-
after :each do
|
10
|
-
@connection.close if @connection.open?
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
it "raises a meaningful exception" do
|
15
|
-
xs = []
|
16
|
-
|
17
|
-
ch1 = @connection.create_channel
|
18
|
-
ch2 = @connection.create_channel
|
19
|
-
q1 = ch1.queue("", :auto_delete => true)
|
20
|
-
q2 = ch2.queue(q1.name, :auto_delete => true, :passive => true)
|
21
|
-
|
22
|
-
c1 = q1.subscribe(exclusive: true) do |_, _, payload|
|
23
|
-
xs << payload
|
24
|
-
end
|
25
|
-
sleep 0.1
|
26
|
-
|
27
|
-
expect do
|
28
|
-
q2.subscribe(exclusive: true) do |_, _, _|
|
29
|
-
end
|
30
|
-
end.to raise_error(Bunny::AccessRefused)
|
31
|
-
|
32
|
-
expect(ch1).to be_open
|
33
|
-
expect(ch2).to be_closed
|
34
|
-
|
35
|
-
q1.publish("abc")
|
36
|
-
sleep 0.1
|
37
|
-
|
38
|
-
# verify that the first consumer is fine
|
39
|
-
expect(xs).to eq ["abc"]
|
40
|
-
|
41
|
-
q1.delete
|
42
|
-
end
|
43
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Bunny::Session do
|
4
|
-
context "with unreachable host" do
|
5
|
-
it "raises Bunny::TCPConnectionFailed" do
|
6
|
-
begin
|
7
|
-
conn = Bunny.new(:hostname => "127.0.0.254", :port => 1433)
|
8
|
-
conn.start
|
9
|
-
|
10
|
-
fail "expected 192.192.192.192 to be unreachable"
|
11
|
-
rescue Bunny::TCPConnectionFailed => e
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
unless ENV["CI"]
|
5
|
-
describe "Message framing implementation" do
|
6
|
-
let(:connection) do
|
7
|
-
c = Bunny.new(:user => "bunny_gem",
|
8
|
-
password: "bunny_password",
|
9
|
-
:vhost => "bunny_testbed",
|
10
|
-
:port => ENV.fetch("RABBITMQ_PORT", 5672))
|
11
|
-
c.start
|
12
|
-
c
|
13
|
-
end
|
14
|
-
|
15
|
-
after :each do
|
16
|
-
connection.close if connection.open?
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
context "with payload 272179 bytes in size" do
|
21
|
-
it "successfully frames the message" do
|
22
|
-
ch = connection.create_channel
|
23
|
-
|
24
|
-
q = ch.queue("", exclusive: true)
|
25
|
-
x = ch.default_exchange
|
26
|
-
|
27
|
-
as = ("a" * 272179)
|
28
|
-
x.publish(as, routing_key: q.name, persistent: true)
|
29
|
-
|
30
|
-
sleep(1)
|
31
|
-
expect(q.message_count).to eq 1
|
32
|
-
|
33
|
-
_, _, payload = q.pop
|
34
|
-
expect(payload.bytesize).to eq as.bytesize
|
35
|
-
|
36
|
-
ch.close
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Bunny::Session do
|
5
|
-
let(:connection) do
|
6
|
-
c = Bunny.new(
|
7
|
-
user: 'bunny_gem', password: 'bunny_password',
|
8
|
-
vhost: 'bunny_testbed',
|
9
|
-
port: ENV.fetch('RABBITMQ_PORT', 5672)
|
10
|
-
)
|
11
|
-
c.start
|
12
|
-
c
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'after the connection has been manually closed' do
|
16
|
-
before :each do
|
17
|
-
connection.close
|
18
|
-
end
|
19
|
-
|
20
|
-
after :each do
|
21
|
-
connection.close if connection.open?
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#create_channel' do
|
25
|
-
it 'should raise an exception' do
|
26
|
-
expect {
|
27
|
-
connection.create_channel
|
28
|
-
}.to raise_error(Bunny::ConnectionAlreadyClosed)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Bunny::Session do
|
4
|
-
context 'when retry attempts have been exhausted' do
|
5
|
-
let(:io) { StringIO.new } # keep test output clear
|
6
|
-
|
7
|
-
def create_session
|
8
|
-
described_class.new(
|
9
|
-
host: 'fake.host',
|
10
|
-
recovery_attempts: 0,
|
11
|
-
connection_timeout: 0,
|
12
|
-
network_recovery_interval: 0,
|
13
|
-
logfile: io,
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'closes the session' do
|
18
|
-
session = create_session
|
19
|
-
session.handle_network_failure(StandardError.new)
|
20
|
-
expect(session.closed?).to be true
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'stops the reader loop' do
|
24
|
-
session = create_session
|
25
|
-
reader_loop = session.reader_loop
|
26
|
-
session.handle_network_failure(StandardError.new)
|
27
|
-
expect(reader_loop.stopping?).to be true
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Bunny::Session, 'TLS certificate store' do
|
6
|
-
subject { described_class.new tls: true, tls_ca_certificates: [certificate], logger: logger }
|
7
|
-
|
8
|
-
let(:logger) { Logger.new(io).tap { |l| l.level = :debug } }
|
9
|
-
let(:io) { StringIO.new }
|
10
|
-
|
11
|
-
context 'when a Windows path given' do
|
12
|
-
let(:certificate) { 'C:/some/path/cacert.pem' }
|
13
|
-
|
14
|
-
# skipping actual work with file by Windows path as this spec runs in Linux
|
15
|
-
before do
|
16
|
-
allow(File).to receive(:readable?).with(certificate).and_return(true)
|
17
|
-
allow_any_instance_of(OpenSSL::X509::Store).to receive(:add_file)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'uses the certificate by path' do
|
21
|
-
subject
|
22
|
-
|
23
|
-
expect(log_content).to include('Using CA certificates at C:/some/path/cacert.pem')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'when a POSIX path given' do
|
28
|
-
let(:certificate) { './spec/tls/ca_certificate.pem' }
|
29
|
-
|
30
|
-
it 'uses the certificate by path' do
|
31
|
-
subject
|
32
|
-
|
33
|
-
expect(log_content).to include('Using CA certificates at ./spec/tls/ca_certificate.pem')
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'when an inline certificate given' do
|
38
|
-
let(:certificate) do
|
39
|
-
<<~CERT
|
40
|
-
-----BEGIN CERTIFICATE-----
|
41
|
-
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
-
BQAwMTEgMB4GA1UEAwwXVExTR2VuU2VsZlNpZ25lZHRSb290Q0ExDTALBgNVBAcM
|
43
|
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-
FDmUQWP0GRWZFgKCp5kNX+uaQk/KULEYc5W/+vYrpFPwOQi1uruRSyRKMddw3BJa
|
61
|
-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
-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
-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
-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
-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
-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
-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
-
IOKPOq09C3id77JsXRwEb7hkkXpTp5i63bmVvCKRDKtHMUfxfnRiZkuu79fB4y8v
|
69
|
-
eYEXqywYlmGZite4N3qb3qQnyGw=
|
70
|
-
-----END CERTIFICATE-----
|
71
|
-
CERT
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'uses the inline certificate' do
|
75
|
-
subject
|
76
|
-
|
77
|
-
expect(log_content).to include('Using 1 inline CA certificates')
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def log_content
|
82
|
-
io.tap(&:rewind).read
|
83
|
-
end
|
84
|
-
end
|