Sha256: 929cd4d9ee9ec5cd19248a1cf1aeaf5e7d38010ab2f0f644331e4bf23aedf752

Contents?: true

Size: 1.46 KB

Versions: 20

Compression:

Stored size: 1.46 KB

Contents

require 'mq'

# simple function to get at the number of messages on a queue and the 
# number of consumers using it and store them in variables for later use
def get_details_of_queue(queue, host) 
  AMQP.start(:host => host) do
    jobs = MQ.queue(queue)
    jobs.status do |msgs, cns| 
      @messages = msgs
      @count = cns     
    end
    AMQP.stop{ EM.stop }
  end
end

# set up some defaults so we can compare numbers without
# raising exceptions
Before do
  @messages = 0
  @consumers = 0
end

# Step definitions for testing various conditions on the queue
Given /I have a AMQP server on (.+)$/ do |host|
  @host = host
end

And /I want to check on the (\w+) queue$/ do |queue|
  get_details_of_queue(queue, @host)
end

Then /it should have less than (\d+) messages per consumer$/ do |messages|
  @consumers.should > 0
  messages.to_i.should < @messages/@consumers
end

Then /it should have less than (\d+) messages$/ do |messages|
  @messages.should < messages.to_i
end

Then /it should have at least (\d+) messages$/ do |messages|
  @messages.should >= messages.to_i
end

Then /it should have more than (\d+) messages$/ do |messages|
  @messages.should > messages.to_i
end

Then /It should have more than (\d+) consumers$/ do |consumers|
  @consumers.should > consumers.to_i
end

Then /It should have less than (\d+) consumers$/ do |consumers|
  @consumers.should < consumers.to_i
end

Then /It should have (\d+) consumers$/ do |consumers|
  @consumers.should == consumers.to_i
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
cucumber-nagios-0.9.2 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.9.0 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.8.11 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.8.10 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.8.9 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.8.8 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.8.7 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.8.6 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.8.5 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.8.4 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.8.3 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.8.2 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.8.0 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.7.6 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.7.5 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.7.4 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.7.3 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.7.2 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.7.1 lib/cucumber/nagios/steps/amqp_steps.rb
cucumber-nagios-0.7.0 lib/cucumber/nagios/steps/amqp_steps.rb