Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bugfix omit and sync #35

Merged
3 commits merged into from

0 participants

@ghost

No description provided.

@ghost ghost merged commit c83fe67 into from
@ghost ghost deleted the branch
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 4, 2013
  1. Omit some tests if @skip flag is set

    Alexander Kolesen authored
  2. Fixed synchronization mechanisms

    Alexander Kolesen authored
  3. Added sleeps to avoid sending requests too fast

    Alexander Kolesen authored
This page is out of date. Refresh to see the latest.
View
3  test/test_base.rb
@@ -19,6 +19,9 @@ def setup
# check multiple config locations
@config = UberConfig.load
puts "config=" + @config.inspect
+
+ config = @config['iron']
+ @host = "#{config['host'] || "mq-aws-us-east-1.iron.io"}"
@client = IronMQ::Client.new(@config['iron'])
IronCore::Logger.logger.level = Logger::DEBUG
@client.queue_name = 'ironmq-ruby-tests'
View
6 test/test_beanstalkd.rb
@@ -9,11 +9,11 @@ def setup
super
config = @config['iron']
- @host = "#{config['host'] || "mq-aws-us-east-1.iron.io"}:#{config['beanstalkd_port'] || 11300}"
- puts "beanstalkd url: #{@host}"
+ beanstalkd_host = "#{@host}:#{config['beanstalkd_port'] || 11300}"
+ puts "beanstalkd url: #{beanstalkd_host}"
@skip = @host.include? 'rackspace'
return if @skip # bypass these tests if rackspace
- @beanstalk = Beanstalk::Connection.new(@host)
+ @beanstalk = Beanstalk::Connection.new(beanstalkd_host)
@beanstalk.put("oauth #{config['token']} #{config['project_id']}")
clear_tube('default')
View
14 test/test_iron_mq.rb
@@ -6,18 +6,17 @@
class IronMQTests < TestBase
def setup
super
-
+ @skip = @host.include? 'rackspace'
+ LOG.info "@host: #{@host}"
queues = @client.queues.list
p queues
-
clear_queue()
-
end
def test_performance_post_100_messages
@client.queue_name = 'test_perf_100'
# slower to rackspace since this is running on aws
- timeout = @client.host.include?('rackspace') ? 40 : 12
+ timeout = @host.include?('rackspace') ? 40 : 12
assert_performance timeout do
100.times do
@client.messages.post("hello world!")
@@ -145,6 +144,7 @@ def test_timeout
tries = MAX_TRIES
while tries > 0
+ sleep 0.5
tries -= 1
sleep 1
new_msg = @client.messages.get()
@@ -168,6 +168,7 @@ def test_timeout
tries = MAX_TRIES
while tries > 0
+ sleep 0.5
tries -= 1
sleep 1
new_msg = @client.messages.get()
@@ -218,6 +219,7 @@ def test_delay
tries = MAX_TRIES
while tries > 0
+ sleep 0.5
tries -= 1
sleep 1
msg = @client.messages.get
@@ -297,6 +299,7 @@ def test_release
tries = MAX_TRIES
while tries > 0
+ sleep 0.5
tries -= 1
sleep 1
msg = @client.messages.get
@@ -314,6 +317,7 @@ def test_release
tries = MAX_TRIES
while tries > 0
+ sleep 0.5
tries -= 1
sleep 1
msg = @client.messages.get
@@ -392,6 +396,8 @@ def test_poll
#end
def test_webhooks
+ omit_if @skip
+ puts "skip webhooks: #{@skip}"
qname ="webhook_queue"
path = "#{IronMQ::Messages.path(project_id: @client.project_id, queue_name: qname)}/webhook"
url = "#{@client.base_url}#{path}"
View
58 test/test_push_queues.rb
@@ -6,6 +6,8 @@ class TestPushQueues < TestBase
def setup
super
+ @skip = @host.include? 'rackspace'
+ return if @skip # bypass these tests if rackspace
end
def make_key(i, t, random=0)
@@ -14,7 +16,7 @@ def make_key(i, t, random=0)
def test_queue_subscriptions
-
+ omit_if @skip
types = ["multicast", "unicast"]
types.each do |t|
@@ -105,6 +107,7 @@ def test_queue_subscriptions
tries = MAX_TRIES
while tries > 0
+ sleep 0.5
tries -= 1
subscribers = queue.messages.get(m.id).subscribers
LOG.debug subscribers
@@ -115,14 +118,16 @@ def test_queue_subscriptions
assert_equal num_subscribers, found
assert_equal num_subscribers, subscribers.size
end
-
+
+ do_retry = false
subscribers.each do |s|
LOG.debug s
LOG.info "status_code=#{s['status_code']}"
LOG.info "status=#{s['status']}"
- next unless 200 == s["status_code"]
- next unless "deleted" == s["status"]
+ do_retry = true unless 200 == s["status_code"]
+ do_retry = true unless "deleted" == s["status"]
end
+ next if do_retry
break
end
assert_not_equal tries, 0
@@ -131,6 +136,7 @@ def test_queue_subscriptions
def test_failure
+ omit_if @skip
@rest = Rest::Client.new
qname = "failure-queue"
@@ -159,6 +165,7 @@ def test_failure
tries = MAX_TRIES
while tries > 0
+ sleep 0.5
tries -= 1
LOG.info 'getting status'
subscribers = queue.messages.get(m.id).subscribers
@@ -166,34 +173,38 @@ def test_failure
LOG.info "num_subscribers=#{num_subscribers} subscribers.size=#{subscribers.size}"
assert_equal num_subscribers, subscribers.size
+ do_retry = false
subscribers.each do |s|
LOG.debug s
LOG.info "status_code=#{s['status_code']}"
LOG.info "status=#{s['status']}"
- next unless 503 == s["status_code"]
- next unless ["reserved", "retrying"].include? s["status"]
+ do_retry = true unless 503 == s["status_code"]
+ do_retry = true unless ["reserved", "retrying"].include? s["status"]
end
+ next if do_retry
break
end
assert_not_equal tries, 0
tries = MAX_TRIES
while tries > 0
+ sleep 0.5
tries -= 1
subscribers = queue.messages.get(m.id).subscribers
LOG.debug subscribers
assert_equal num_subscribers, subscribers.size
+ do_retry = false
subscribers.each do |s|
LOG.debug s
-
if s["url"] == "http://rest-test.iron.io/code/503"
- next unless 503 == s["status_code"]
- next unless "error" == s["status"]
+ do_retry = true unless 503 == s["status_code"]
+ do_retry = true unless "error" == s["status"]
else
- next unless 200 == s["status_code"]
- next unless "deleted" == s["status"]
+ do_retry = true unless 200 == s["status_code"]
+ do_retry = true unless "deleted" == s["status"]
end
end
+ next if do_retry
break
end
assert_not_equal tries, 0
@@ -201,6 +212,7 @@ def test_failure
def test_202
+ omit_if @skip
types = ["multicast"]
types.each do |t|
@@ -232,15 +244,18 @@ def test_202
tries = MAX_TRIES
while tries > 0
+ sleep 0.5
tries -= 1
subscribers = queue.messages.get(m.id).subscribers
LOG.debug subscribers
assert_equal num_subscribers, subscribers.size
+ do_retry = false
subscribers.each do |s|
LOG.debug s
- next unless 202 == s["status_code"]
- next unless "reserved" == s["status"]
+ do_retry = true unless 202 == s["status_code"]
+ do_retry = true unless "reserved" == s["status"]
end
+ next if do_retry
break
end
assert_not_equal tries, 0
@@ -250,38 +265,45 @@ def test_202
tries = MAX_TRIES
while tries > 0
+ sleep 0.5
subscribers = queue.messages.get(m.id).subscribers
LOG.debug subscribers
assert_equal num_subscribers, subscribers.size
+ do_retry = false
subscribers.each do |s|
LOG.debug s
LOG.info "status_code=#{s['status_code']}"
LOG.info "status=#{s['status']}"
- next unless 202 == s["status_code"]
- next unless "reserved" == s["status"]
+ do_retry = true unless 202 == s["status_code"]
+ do_retry = true unless "reserved" == s["status"]
# now let's delete it to say we're done with it
LOG.info "Acking subscriber"
res = s.delete
LOG.debug res
end
+ next if do_retry
break
end
assert_not_equal 0, tries
tries = MAX_TRIES
while tries > 0
+ sleep 0.5
tries -= 1
subscribers = queue.messages.get(m.id).subscribers
LOG.debug subscribers
- assert_equal num_subscribers, subscribers.size
+ next unless num_subscribers == subscribers.size
+
+ do_retry = false
subscribers.each do |s|
LOG.debug s
LOG.info "status=#{s['status']}"
- next unless "deleted" == s["status"]
+ do_retry = true unless "deleted" == s["status"]
end
+ next if do_retry
break
end
assert_not_equal 0, tries
@@ -290,7 +312,7 @@ def test_202
def test_202_failure
-
+ omit_if @skip
end
end
View
12 test/test_tmp.rb
@@ -1,12 +0,0 @@
-gem 'test-unit'
-require 'test/unit'
-require 'yaml'
-require_relative 'test_base'
-
-class IronMQTests < TestBase
- def setup
- super
- end
-
-
-end
Something went wrong with that request. Please try again.