bunny 2.7.4 → 2.22.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.
Files changed (156) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +61 -35
  3. data/lib/bunny/channel.rb +186 -50
  4. data/lib/bunny/channel_id_allocator.rb +3 -1
  5. data/lib/bunny/consumer.rb +2 -2
  6. data/lib/bunny/consumer_work_pool.rb +2 -1
  7. data/lib/bunny/cruby/socket.rb +3 -0
  8. data/lib/bunny/cruby/ssl_socket.rb +6 -1
  9. data/lib/bunny/delivery_info.rb +1 -1
  10. data/lib/bunny/heartbeat_sender.rb +2 -1
  11. data/lib/bunny/jruby/ssl_socket.rb +5 -0
  12. data/lib/bunny/queue.rb +36 -8
  13. data/lib/bunny/reader_loop.rb +22 -10
  14. data/lib/bunny/session.rb +152 -65
  15. data/lib/bunny/test_kit.rb +14 -0
  16. data/lib/bunny/transport.rb +132 -49
  17. data/lib/bunny/version.rb +1 -1
  18. data/lib/bunny.rb +45 -4
  19. metadata +37 -225
  20. data/.github/ISSUE_TEMPLATE.md +0 -18
  21. data/.gitignore +0 -28
  22. data/.rspec +0 -1
  23. data/.travis.yml +0 -20
  24. data/.yardopts +0 -8
  25. data/CONTRIBUTING.md +0 -111
  26. data/ChangeLog.md +0 -1831
  27. data/Gemfile +0 -53
  28. data/LICENSE +0 -21
  29. data/Rakefile +0 -46
  30. data/benchmarks/basic_publish/with_128K_messages.rb +0 -35
  31. data/benchmarks/basic_publish/with_1k_messages.rb +0 -35
  32. data/benchmarks/basic_publish/with_4K_messages.rb +0 -35
  33. data/benchmarks/basic_publish/with_64K_messages.rb +0 -35
  34. data/benchmarks/channel_open.rb +0 -28
  35. data/benchmarks/mutex_and_monitor.rb +0 -42
  36. data/benchmarks/queue_declare.rb +0 -29
  37. data/benchmarks/queue_declare_and_bind.rb +0 -29
  38. data/benchmarks/queue_declare_bind_and_delete.rb +0 -29
  39. data/benchmarks/synchronized_sorted_set.rb +0 -53
  40. data/benchmarks/write_vs_write_nonblock.rb +0 -49
  41. data/bin/ci/before_build +0 -46
  42. data/bunny.gemspec +0 -35
  43. data/docker/Dockerfile +0 -16
  44. data/docker/docker-entrypoint.sh +0 -37
  45. data/docker-compose.yml +0 -18
  46. data/examples/connection/authentication_failure.rb +0 -16
  47. data/examples/connection/automatic_recovery_with_basic_get.rb +0 -40
  48. data/examples/connection/automatic_recovery_with_client_named_queues.rb +0 -36
  49. data/examples/connection/automatic_recovery_with_multiple_consumers.rb +0 -46
  50. data/examples/connection/automatic_recovery_with_republishing.rb +0 -109
  51. data/examples/connection/automatic_recovery_with_server_named_queues.rb +0 -35
  52. data/examples/connection/channel_level_exception.rb +0 -27
  53. data/examples/connection/disabled_automatic_recovery.rb +0 -34
  54. data/examples/connection/heartbeat.rb +0 -17
  55. data/examples/connection/manually_reconnecting_consumer.rb +0 -23
  56. data/examples/connection/manually_reconnecting_publisher.rb +0 -28
  57. data/examples/connection/unknown_host.rb +0 -16
  58. data/examples/consumers/high_and_low_priority.rb +0 -50
  59. data/examples/guides/exchanges/direct_exchange_routing.rb +0 -36
  60. data/examples/guides/exchanges/fanout_exchange_routing.rb +0 -28
  61. data/examples/guides/exchanges/headers_exchange_routing.rb +0 -31
  62. data/examples/guides/exchanges/mandatory_messages.rb +0 -30
  63. data/examples/guides/extensions/alternate_exchange.rb +0 -30
  64. data/examples/guides/extensions/basic_nack.rb +0 -33
  65. data/examples/guides/extensions/connection_blocked.rb +0 -35
  66. data/examples/guides/extensions/consumer_cancellation_notification.rb +0 -39
  67. data/examples/guides/extensions/dead_letter_exchange.rb +0 -32
  68. data/examples/guides/extensions/exchange_to_exchange_bindings.rb +0 -29
  69. data/examples/guides/extensions/per_message_ttl.rb +0 -36
  70. data/examples/guides/extensions/per_queue_message_ttl.rb +0 -36
  71. data/examples/guides/extensions/publisher_confirms.rb +0 -28
  72. data/examples/guides/extensions/queue_lease.rb +0 -26
  73. data/examples/guides/extensions/sender_selected_distribution.rb +0 -32
  74. data/examples/guides/getting_started/blabbr.rb +0 -27
  75. data/examples/guides/getting_started/hello_world.rb +0 -22
  76. data/examples/guides/getting_started/weathr.rb +0 -49
  77. data/examples/guides/queues/one_off_consumer.rb +0 -25
  78. data/examples/guides/queues/redeliveries.rb +0 -81
  79. data/profiling/basic_publish/with_4K_messages.rb +0 -33
  80. data/repl +0 -3
  81. data/spec/config/enabled_plugins +0 -1
  82. data/spec/config/rabbitmq.config +0 -19
  83. data/spec/higher_level_api/integration/basic_ack_spec.rb +0 -230
  84. data/spec/higher_level_api/integration/basic_cancel_spec.rb +0 -142
  85. data/spec/higher_level_api/integration/basic_consume_spec.rb +0 -349
  86. data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +0 -54
  87. data/spec/higher_level_api/integration/basic_get_spec.rb +0 -80
  88. data/spec/higher_level_api/integration/basic_nack_spec.rb +0 -82
  89. data/spec/higher_level_api/integration/basic_publish_spec.rb +0 -74
  90. data/spec/higher_level_api/integration/basic_qos_spec.rb +0 -57
  91. data/spec/higher_level_api/integration/basic_reject_spec.rb +0 -152
  92. data/spec/higher_level_api/integration/basic_return_spec.rb +0 -33
  93. data/spec/higher_level_api/integration/channel_close_spec.rb +0 -25
  94. data/spec/higher_level_api/integration/channel_open_spec.rb +0 -57
  95. data/spec/higher_level_api/integration/connection_recovery_spec.rb +0 -471
  96. data/spec/higher_level_api/integration/connection_spec.rb +0 -559
  97. data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -83
  98. data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +0 -128
  99. data/spec/higher_level_api/integration/dead_lettering_spec.rb +0 -75
  100. data/spec/higher_level_api/integration/exchange_bind_spec.rb +0 -31
  101. data/spec/higher_level_api/integration/exchange_declare_spec.rb +0 -237
  102. data/spec/higher_level_api/integration/exchange_delete_spec.rb +0 -105
  103. data/spec/higher_level_api/integration/exchange_unbind_spec.rb +0 -40
  104. data/spec/higher_level_api/integration/exclusive_queue_spec.rb +0 -28
  105. data/spec/higher_level_api/integration/heartbeat_spec.rb +0 -49
  106. data/spec/higher_level_api/integration/merry_go_round_spec.rb +0 -85
  107. data/spec/higher_level_api/integration/message_properties_access_spec.rb +0 -95
  108. data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +0 -24
  109. data/spec/higher_level_api/integration/publisher_confirms_spec.rb +0 -191
  110. data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +0 -87
  111. data/spec/higher_level_api/integration/queue_bind_spec.rb +0 -109
  112. data/spec/higher_level_api/integration/queue_declare_spec.rb +0 -221
  113. data/spec/higher_level_api/integration/queue_delete_spec.rb +0 -41
  114. data/spec/higher_level_api/integration/queue_purge_spec.rb +0 -30
  115. data/spec/higher_level_api/integration/queue_unbind_spec.rb +0 -54
  116. data/spec/higher_level_api/integration/read_only_consumer_spec.rb +0 -60
  117. data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +0 -36
  118. data/spec/higher_level_api/integration/tls_connection_spec.rb +0 -222
  119. data/spec/higher_level_api/integration/tx_commit_spec.rb +0 -21
  120. data/spec/higher_level_api/integration/tx_rollback_spec.rb +0 -21
  121. data/spec/higher_level_api/integration/with_channel_spec.rb +0 -25
  122. data/spec/issues/issue100_spec.rb +0 -42
  123. data/spec/issues/issue141_spec.rb +0 -43
  124. data/spec/issues/issue202_spec.rb +0 -15
  125. data/spec/issues/issue224_spec.rb +0 -40
  126. data/spec/issues/issue465_spec.rb +0 -32
  127. data/spec/issues/issue78_spec.rb +0 -72
  128. data/spec/issues/issue83_spec.rb +0 -30
  129. data/spec/issues/issue97_attachment.json +0 -1
  130. data/spec/issues/issue97_spec.rb +0 -175
  131. data/spec/lower_level_api/integration/basic_cancel_spec.rb +0 -83
  132. data/spec/lower_level_api/integration/basic_consume_spec.rb +0 -99
  133. data/spec/spec_helper.rb +0 -51
  134. data/spec/stress/channel_close_stress_spec.rb +0 -64
  135. data/spec/stress/channel_open_stress_spec.rb +0 -84
  136. data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +0 -28
  137. data/spec/stress/concurrent_consumers_stress_spec.rb +0 -71
  138. data/spec/stress/concurrent_publishers_stress_spec.rb +0 -54
  139. data/spec/stress/connection_open_close_spec.rb +0 -52
  140. data/spec/stress/long_running_consumer_spec.rb +0 -84
  141. data/spec/tls/ca_certificate.pem +0 -29
  142. data/spec/tls/ca_key.pem +0 -52
  143. data/spec/tls/client_certificate.pem +0 -29
  144. data/spec/tls/client_key.pem +0 -51
  145. data/spec/tls/generate-server-cert.sh +0 -8
  146. data/spec/tls/server-openssl.cnf +0 -10
  147. data/spec/tls/server.csr +0 -16
  148. data/spec/tls/server_certificate.pem +0 -29
  149. data/spec/tls/server_key.pem +0 -51
  150. data/spec/unit/bunny_spec.rb +0 -15
  151. data/spec/unit/concurrent/atomic_fixnum_spec.rb +0 -35
  152. data/spec/unit/concurrent/condition_spec.rb +0 -82
  153. data/spec/unit/concurrent/linked_continuation_queue_spec.rb +0 -35
  154. data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +0 -73
  155. data/spec/unit/exchange_recovery_spec.rb +0 -39
  156. data/spec/unit/version_delivery_tag_spec.rb +0 -28
@@ -1,471 +0,0 @@
1
- require "spec_helper"
2
- require "rabbitmq/http/client"
3
-
4
- describe "Connection recovery" do
5
- let(:http_client) { RabbitMQ::HTTP::Client.new("http://127.0.0.1:15672") }
6
- let(:logger) { Logger.new($stderr).tap {|logger| logger.level = ENV["BUNNY_LOG_LEVEL"] || Logger::WARN } }
7
- let(:recovery_interval) { 0.2 }
8
-
9
- it "reconnects after grace period" do
10
- with_open do |c|
11
- close_all_connections!
12
- wait_for_recovery_with { connections.any? }
13
- end
14
- end
15
-
16
- it "reconnects after grace period (with multiple hosts)" do
17
- with_open_multi_host do |c|
18
- close_all_connections!
19
- wait_for_recovery_with { connections.any? }
20
- end
21
- end
22
-
23
- it "reconnects after grace period (with multiple hosts, including a broken one)" do
24
- with_open_multi_broken_host do |c|
25
- close_all_connections!
26
- wait_for_recovery_with { connections.any? }
27
- end
28
- end
29
-
30
- it "recovers channels" do
31
- with_open do |c|
32
- ch1 = c.create_channel
33
- ch2 = c.create_channel
34
- sleep 1.5
35
- close_all_connections!
36
- sleep 0.5
37
- poll_until { channels.count == 2 }
38
- expect(ch1).to be_open
39
- expect(ch2).to be_open
40
- end
41
- end
42
-
43
- it "recovers channels (with multiple hosts)" do
44
- with_open_multi_host do |c|
45
- ch1 = c.create_channel
46
- ch2 = c.create_channel
47
- sleep 1.5
48
- close_all_connections!
49
- sleep 0.5
50
- poll_until { channels.count == 2 }
51
- expect(ch1).to be_open
52
- expect(ch2).to be_open
53
- end
54
- end
55
-
56
- it "recovers channels (with multiple hosts, including a broken one)" do
57
- with_open_multi_broken_host do |c|
58
- ch1 = c.create_channel
59
- ch2 = c.create_channel
60
- sleep 1.5
61
- close_all_connections!
62
- sleep 0.5
63
- poll_until { channels.count == 2 }
64
- expect(ch1).to be_open
65
- expect(ch2).to be_open
66
- end
67
- end
68
-
69
- it "recovers basic.qos prefetch setting" do
70
- with_open do |c|
71
- ch = c.create_channel
72
- ch.prefetch(11)
73
- expect(ch.prefetch_count).to eq 11
74
- expect(ch.prefetch_global).to be false
75
- sleep 1.5
76
- close_all_connections!
77
- sleep 0.5
78
- wait_for_recovery_with { connections.any? }
79
- expect(ch).to be_open
80
- expect(ch.prefetch_count).to eq 11
81
- expect(ch.prefetch_global).to be false
82
- end
83
- end
84
-
85
- it "recovers basic.qos prefetch global setting" do
86
- with_open do |c|
87
- ch = c.create_channel
88
- ch.prefetch(42, true)
89
- expect(ch.prefetch_count).to eq 42
90
- expect(ch.prefetch_global).to be true
91
- sleep 1.5
92
- close_all_connections!
93
- sleep 0.5
94
- wait_for_recovery_with { connections.any? }
95
- expect(ch).to be_open
96
- expect(ch.prefetch_count).to eq 42
97
- expect(ch.prefetch_global).to be true
98
- end
99
- end
100
-
101
- it "recovers publisher confirms setting" do
102
- with_open do |c|
103
- ch = c.create_channel
104
- ch.confirm_select
105
- expect(ch).to be_using_publisher_confirms
106
- sleep 1.5
107
- close_all_connections!
108
- sleep 0.5
109
- wait_for_recovery_with { connections.any? }
110
- expect(ch).to be_open
111
- expect(ch).to be_using_publisher_confirms
112
- end
113
- end
114
-
115
- it "recovers transactionality setting" do
116
- with_open do |c|
117
- ch = c.create_channel
118
- ch.tx_select
119
- expect(ch).to be_using_tx
120
- sleep 1.5
121
- close_all_connections!
122
- sleep 0.5
123
- wait_for_recovery_with { connections.any? }
124
- expect(ch).to be_open
125
- expect(ch).to be_using_tx
126
- end
127
- end
128
-
129
- it "recovers client-named queues" do
130
- with_open do |c|
131
- ch = c.create_channel
132
- q = ch.queue("bunny.tests.recovery.client-named#{rand}")
133
- close_all_connections!
134
- wait_for_recovery_with { connections.any? }
135
- expect(ch).to be_open
136
- ensure_queue_recovery(ch, q)
137
- q.delete
138
- end
139
- end
140
-
141
- # a very simplistic test for queues inspired by #422
142
- it "recovers client-named queues declared with no_declare: true" do
143
- with_open do |c|
144
- ch = c.create_channel
145
- ch2 = c.create_channel
146
-
147
- n = rand
148
- s = "bunny.tests.recovery.client-named#{n}"
149
-
150
- q = ch.queue(s)
151
- q2 = ch2.queue(s, no_declare: true)
152
-
153
- close_all_connections!
154
- wait_for_recovery_with { connections.any? }
155
- expect(ch).to be_open
156
- ensure_queue_recovery(ch, q)
157
- q.delete
158
- end
159
- end
160
-
161
- # a test for #422
162
- it "recovers client-named queues declared with passive: true" do
163
- with_open do |c|
164
- ch = c.create_channel
165
- ch2 = c.create_channel
166
-
167
- n = rand
168
- s = "bunny.tests.recovery.client-named#{n}"
169
-
170
- q = ch.queue(s)
171
- q2 = ch2.queue(s, passive: true)
172
-
173
- close_all_connections!
174
- wait_for_recovery_with { connections.any? }
175
- expect(ch).to be_open
176
- ensure_queue_recovery(ch, q)
177
- ensure_queue_recovery(ch, q2)
178
- q.delete
179
- end
180
- end
181
-
182
- it "recovers server-named queues" do
183
- with_open do |c|
184
- ch = c.create_channel
185
- q = ch.queue("", exclusive: true)
186
- close_all_connections!
187
- wait_for_recovery_with { connections.any? }
188
- expect(ch).to be_open
189
- ensure_queue_recovery(ch, q)
190
- end
191
- end
192
-
193
- it "recovers queue bindings" do
194
- with_open do |c|
195
- ch = c.create_channel
196
- x = ch.fanout("amq.fanout")
197
- q = ch.queue("", exclusive: true)
198
- q.bind(x)
199
- close_all_connections!
200
- wait_for_recovery_with { connections.any? }
201
- expect(ch).to be_open
202
- ensure_queue_binding_recovery(ch, x, q)
203
- end
204
- end
205
-
206
- it "recovers exchanges and their bindings" do
207
- with_open do |c|
208
- ch = c.create_channel
209
- source = ch.fanout("source.exchange.recovery.example", auto_delete: true)
210
- destination = ch.fanout("destination.exchange.recovery.example", auto_delete: true)
211
-
212
- destination.bind(source)
213
-
214
- # Exchanges won't get auto-deleted on connection loss unless they have
215
- # had an exclusive queue bound to them.
216
- dst_queue = ch.queue("", exclusive: true)
217
- dst_queue.bind(destination, routing_key: "")
218
-
219
- src_queue = ch.queue("", exclusive: true)
220
- src_queue.bind(source, routing_key: "")
221
-
222
- close_all_connections!
223
-
224
- wait_for_recovery_with { exchange_names_in_vhost("/").include?(source.name) }
225
- ch.confirm_select
226
-
227
- source.publish("msg", routing_key: "")
228
- ch.wait_for_confirms
229
- expect(dst_queue.message_count).to eq 1
230
- destination.delete
231
- end
232
- end
233
-
234
- it "recovers passively declared exchanges and their bindings" do
235
- with_open do |c|
236
- ch = c.create_channel
237
- ch.confirm_select
238
-
239
- source = ch.fanout("amq.fanout", passive: true)
240
- destination = ch.fanout("destination.exchange.recovery.example", auto_delete: true)
241
-
242
- destination.bind(source)
243
-
244
- # Exchanges won't get auto-deleted on connection loss unless they have
245
- # had an exclusive queue bound to them.
246
- dst_queue = ch.queue("", exclusive: true)
247
- dst_queue.bind(destination, routing_key: "")
248
-
249
- src_queue = ch.queue("", exclusive: true)
250
- src_queue.bind(source, routing_key: "")
251
-
252
- close_all_connections!
253
-
254
- wait_for_recovery_with { connections.any? }
255
-
256
- source.publish("msg", routing_key: "")
257
- ch.wait_for_confirms
258
-
259
- expect(dst_queue.message_count).to eq 1
260
- destination.delete
261
- end
262
- end
263
-
264
- # this is a simplistic test that primarily execises the code path from #412
265
- it "recovers exchanges that were declared with passive = true" do
266
- with_open do |c|
267
- ch = c.create_channel
268
- ch2 = c.create_channel
269
- source = ch.fanout("source.exchange.recovery.example", auto_delete: true)
270
- destination = ch.fanout("destination.exchange.recovery.example", auto_delete: true)
271
-
272
- source2 = ch2.fanout("source.exchange.recovery.example", no_declare: true)
273
- destination2 = ch2.fanout("destination.exchange.recovery.example", no_declare: true)
274
-
275
- destination.bind(source)
276
-
277
- # Exchanges won't get auto-deleted on connection loss unless they have
278
- # had an exclusive queue bound to them.
279
- dst_queue = ch.queue("", exclusive: true)
280
- dst_queue.bind(destination, routing_key: "")
281
-
282
- src_queue = ch.queue("", exclusive: true)
283
- src_queue.bind(source, routing_key: "")
284
-
285
- close_all_connections!
286
-
287
- wait_for_recovery_with { exchange_names_in_vhost("/").include?(source.name) }
288
-
289
- ch2.confirm_select
290
-
291
- source2.publish("msg", routing_key: "")
292
- ch2.wait_for_confirms
293
- expect(dst_queue.message_count).to eq 1
294
- end
295
- end
296
-
297
- it "recovers allocated channel ids" do
298
- with_open do |c|
299
- q = "queue#{Time.now.to_i}"
300
- 10.times { c.create_channel }
301
- expect(c.queue_exists?(q)).to eq false
302
- close_all_connections!
303
- wait_for_recovery_with { channels.any? }
304
- # make sure the connection isn't closed shortly after
305
- # due to "second 'channel.open' seen". MK.
306
- expect(c).to be_open
307
- sleep 0.1
308
- expect(c).to be_open
309
- sleep 0.1
310
- expect(c).to be_open
311
- end
312
- end
313
-
314
- it "recovers consumers" do
315
- with_open do |c|
316
- delivered = false
317
-
318
- ch = c.create_channel
319
- ch.confirm_select
320
- q = ch.queue("", exclusive: true)
321
- q.subscribe do |_, _, _|
322
- delivered = true
323
- end
324
- close_all_connections!
325
- wait_for_recovery_with { connections.any? }
326
- expect(ch).to be_open
327
-
328
- q.publish("")
329
- ch.wait_for_confirms
330
-
331
- poll_until { delivered }
332
- end
333
- end
334
-
335
- it "recovers all consumers" do
336
- n = 32
337
-
338
- with_open do |c|
339
- ch = c.create_channel
340
- q = ch.queue("", exclusive: true)
341
- n.times { q.subscribe { |_, _, _| } }
342
- close_all_connections!
343
- wait_for_recovery_with { connections.any? }
344
- expect(ch).to be_open
345
- sleep 0.5
346
-
347
- expect(q.consumer_count).to eq n
348
- end
349
- end
350
-
351
- it "recovers all queues" do
352
- n = 32
353
-
354
- qs = []
355
-
356
- with_open do |c|
357
- ch = c.create_channel
358
-
359
- n.times do
360
- qs << ch.queue("", exclusive: true)
361
- end
362
- close_all_connections!
363
- wait_for_recovery_with { queue_names.include?(qs.first.name) }
364
- sleep 0.5
365
- expect(ch).to be_open
366
-
367
- qs.each do |q|
368
- ch.queue_declare(q.name, passive: true)
369
- end
370
- end
371
- end
372
-
373
- def exchange_names_in_vhost(vhost)
374
- http_client.list_exchanges(vhost).map {|e| e["name"]}
375
- end
376
-
377
- def connections
378
- http_client.list_connections
379
- end
380
-
381
- def channels
382
- http_client.list_channels
383
- end
384
-
385
- def queue_names
386
- http_client.list_queues.map {|q| q["name"]}
387
- end
388
-
389
- def close_all_connections!
390
- # let whatever actions were taken before
391
- # this call a chance to propagate, e.g. to make
392
- # sure that connections are accounted for in the
393
- # stats DB.
394
- #
395
- # See bin/ci/before_build for management plugin
396
- # pre-configuration.
397
- #
398
- # MK.
399
- sleep 1.1
400
- connections.each do |conn_info|
401
- close_ignoring_permitted_exceptions(conn_info.name)
402
- end
403
- end
404
-
405
- def close_ignoring_permitted_exceptions(connection_name)
406
- http_client.close_connection(connection_name)
407
- rescue Bunny::ConnectionForced, Faraday::ResourceNotFound
408
- # ignored
409
- end
410
-
411
- def wait_for_recovery_with(&probe)
412
- poll_until &probe
413
- end
414
-
415
- def poll_while(&probe)
416
- Timeout.timeout(20) {
417
- sleep 0.1 while probe.call
418
- }
419
- end
420
-
421
- def poll_until(&probe)
422
- Timeout.timeout(20) {
423
- sleep 0.1 until probe.call
424
- }
425
- end
426
-
427
- def with_open(c = Bunny.new(network_recovery_interval: recovery_interval,
428
- recover_from_connection_close: true,
429
- logger: logger), &block)
430
- c.start
431
- block.call(c)
432
- ensure
433
- c.close
434
- end
435
-
436
- def with_open_multi_host(&block)
437
- c = Bunny.new(hosts: ["127.0.0.1", "localhost"],
438
- network_recovery_interval: recovery_interval,
439
- recover_from_connection_close: true,
440
- logger: logger)
441
- with_open(c, &block)
442
- end
443
-
444
- def with_open_multi_broken_host(&block)
445
- c = Bunny.new(hosts: ["broken", "127.0.0.1", "localhost"],
446
- hosts_shuffle_strategy: Proc.new { |hosts| hosts }, # We do not shuffle for these tests so we always hit the broken host
447
- network_recovery_interval: recovery_interval,
448
- recover_from_connection_close: true,
449
- logger: logger)
450
- with_open(c, &block)
451
- end
452
-
453
- def ensure_queue_recovery(ch, q)
454
- ch.confirm_select
455
- q.purge
456
- x = ch.default_exchange
457
- x.publish("msg", routing_key: q.name)
458
- ch.wait_for_confirms
459
- expect(q.message_count).to eq 1
460
- q.purge
461
- end
462
-
463
- def ensure_queue_binding_recovery(ch, x, q, routing_key = "")
464
- ch.confirm_select
465
- q.purge
466
- x.publish("msg", routing_key: routing_key)
467
- ch.wait_for_confirms
468
- expect(q.message_count).to eq 1
469
- q.purge
470
- end
471
- end