Sha256: b736ac364cf6e54864c360e7386fc68334310d3d809c8075534b2445571a0b9d

Contents?: true

Size: 1.29 KB

Versions: 19

Compression:

Stored size: 1.29 KB

Contents

require "spec_helper"

describe "Rapidly closing lots of temporary channels" do
  before :all do
    @connection = Bunny.new(:automatic_recovery => false).tap do |c|
      c.start
    end
  end

  after :all do
    @connection.close
  end

  100.times do |i|
    context "in a multi-threaded scenario A (take #{i})" do
      let(:n) { 20 }

      it "works correctly" do
        ts = []

        n.times do
          t = Thread.new do
            @connection.with_channel do |ch1|
              q   = ch1.queue("", :exclusive => true)
              q.delete
              ch1.close
            end

            ch2 = @connection.create_channel
            ch2.close
          end
          t.abort_on_exception = true
          ts << t
        end

        ts.each { |t| t.join }
      end
    end
  end

  100.times do |i|
    context "in a multi-threaded scenario B (take #{i})" do
      let(:n) { 20 }

      it "works correctly" do
        ts = []

        n.times do
          t = Thread.new do
            3.times do
              @connection.with_channel do |ch|
                x  = ch.topic('bunny.stress.topics.t2', :durable => false)
              end
            end
          end
          t.abort_on_exception = true
          ts << t
        end

        ts.each { |t| t.join }
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
bunny-2.6.3 spec/stress/channel_close_stress_spec.rb
bunny-2.6.2 spec/stress/channel_close_stress_spec.rb
bunny-2.6.1 spec/stress/channel_close_stress_spec.rb
bunny-2.6.0 spec/stress/channel_close_stress_spec.rb
bunny-2.5.1 spec/stress/channel_close_stress_spec.rb
bunny-2.5.0 spec/stress/channel_close_stress_spec.rb
bunny-2.4.0 spec/stress/channel_close_stress_spec.rb
bunny-2.3.1 spec/stress/channel_close_stress_spec.rb
bunny-2.3.0 spec/stress/channel_close_stress_spec.rb
bunny-2.2.2 spec/stress/channel_close_stress_spec.rb
bunny-2.2.1 spec/stress/channel_close_stress_spec.rb
bunny-2.2.0 spec/stress/channel_close_stress_spec.rb
bunny-1.7.1 spec/stress/channel_close_stress_spec.rb
bunny-2.1.0 spec/stress/channel_close_stress_spec.rb
bunny-2.0.1 spec/stress/channel_close_stress_spec.rb
bunny-2.0.0 spec/stress/channel_close_stress_spec.rb
bunny-2.0.0.rc2 spec/stress/channel_close_stress_spec.rb
bunny-2.0.0.rc1 spec/stress/channel_close_stress_spec.rb
bunny-1.7.0 spec/stress/channel_close_stress_spec.rb