File: connection_open_close_spec.rb

package info (click to toggle)
ruby-bunny 2.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,644 kB
  • sloc: ruby: 10,256; sh: 70; makefile: 8
file content (52 lines) | stat: -rw-r--r-- 1,294 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require "spec_helper"

unless defined?(JRUBY_VERSION) && !ENV["FORCE_JRUBY_RUN"]
  describe Bunny::Session do
    # creating thousands of connections means creating
    # twice as many threads and this won't fly with the JVM
    # in CI containers. MK.
    n = if defined?(JRUBY_VERSION)
          250
        else
          2500
        end

    n.times do |i|
      it "can be closed (automatic recovery disabled, take #{i})" do
        c  = Bunny.new(automatically_recover: false)
        c.start
        ch = c.create_channel

        expect(c).to be_connected
        c.stop
        expect(c).to be_closed
      end
    end

    n.times do |i|
      it "can be closed (automatic recovery enabled, take #{i})" do
        c  = Bunny.new(automatically_recover: true)
        c.start
        ch = c.create_channel

        expect(c).to be_connected
        c.stop
        expect(c).to be_closed
      end
    end

    context "in the single threaded mode" do
      n.times do |i|
        it "can be closed (single threaded mode, take #{i})" do
          c  = Bunny.new(automatically_recover: false, threaded: false)
          c.start
          ch = c.create_channel

          expect(c).to be_connected
          c.stop
          expect(c).to be_closed
        end
      end
    end
  end
end