<commit_before># -*- coding: utf-8 -*-
require "spec_helper"

unless ENV["CI"]
  describe "x-consistent-hash exchanges" do
    let(:connection) do
      c = Bunny.new(:user => "bunny_gem", :password => "<PASSWORD>", :vhost => "bunny_testbed")
      c.start
      c
    end

    after :all do
      connection.close
    end

    let(:list) { Range.new(0, 30).to_a.map(&:to_s) }

    let(:n) { 20 }
    let(:m) { 10_000 }

    it "can be used" do
      ch   = connection.create_channel
      body = "сообщение"
      # requires the consistent hash exchange plugin,
      # enable it with
      #
      # $ [sudo] rabbitmq-plugins enable rabbitmq_consistent_hash_exchange
      x    = ch.exchange("bunny.stress.concurrent.consumers", :type => "x-consistent-hash", :durable => true)

      qs = []

      q1 = ch.queue("", :exclusive => true).bind(x, :routing_key => "15")
      q2 = ch.queue("", :exclusive => true).bind(x, :routing_key => "15")

      sleep 1.0

      5.times do |i|
        m.times do
          x.publish(body, :routing_key => list.sample)
        end
        puts "Published #{(i + 1) * m} messages..."
      end

      sleep 4.0
      q1.message_count.should be > 1000
      q2.message_count.should be > 1000

      ch.close
    end
  end
end
<commit_msg>Now that we have stress tests, functional tests can use lower msg counts<commit_after># -*- coding: utf-8 -*-
require "spec_helper"

unless ENV["CI"]
  describe "x-consistent-hash exchange" do
    let(:connection) do
      c = Bunny.new(:user => "bunny_gem", :password => "<PASSWORD>", :vhost => "bunny_testbed")
      c.start
      c
    end

    after :all do
      connection.close
    end

    let(:list) { Range.new(0, 6).to_a.map(&:to_s) }

    let(:m) { 1500 }

    it "distributes messages between queues bound with the same routing key" do
      ch   = connection.create_channel
      body = "сообщение"
      # requires the consistent hash exchange plugin,
      # enable it with
      #
      # $ [sudo] rabbitmq-plugins enable rabbitmq_consistent_hash_exchange
      x    = ch.exchange("bunny.stress.concurrent.consumers", :type => "x-consistent-hash", :durable => true)

      qs = []

      q1 = ch.queue("", :exclusive => true).bind(x, :routing_key => "5")
      q2 = ch.queue("", :exclusive => true).bind(x, :routing_key => "5")

      sleep 1.0

      5.times do |i|
        m.times do
          x.publish(body, :routing_key => list.sample)
        end
        puts "Published #{(i + 1) * m} tiny messages..."
      end

      sleep 3.0
      q1.message_count.should be > 100
      q2.message_count.should be > 100

      ch.close
    end
  end
end

{'fraction_non_alphanumeric': 0.14020462296324365, 'fraction_numerical': 0.02197802197802198, 'mean_word_length': 2.279503105590062, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6720640', 'n_tokens_mistral': 954, 'n_tokens_neox': 876, 'n_words': 230}