File: issue100_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 (42 lines) | stat: -rw-r--r-- 998 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
require "spec_helper"

unless ENV["CI"]
  describe Bunny::Channel, "#basic_publish" do
    before :all do
      @connection = Bunny.new(username: "bunny_gem",
                              password: "bunny_password",
                              vhost: "bunny_testbed",
                              write_timeout: 0,
                              read_timeout:  0)
      @connection.start
    end

    after :all do
      @connection.close if @connection.open?
    end


    context "when publishing thousands of messages" do
      let(:n) { 2_000 }
      let(:m) { 10 }

      it "successfully publishers them all" do
        ch = @connection.create_channel

        q  = ch.queue("", exclusive: true)
        x  = ch.default_exchange

        body = "x" * 1024
        m.times do |i|
          n.times do
            x.publish(body, routing_key:  q.name)
          end
          puts "Published #{i * n} 1K messages..."
        end

        q.purge
        ch.close
      end
    end
  end
end