Permalink
Browse files

Removed try loops that just need a sleep

  • Loading branch information...
1 parent 780d9bf commit a059c05bb21deb32fc8ffc32e72140fec34f0b49 @treeder treeder committed May 22, 2013
Showing with 109 additions and 142 deletions.
  1. +4 −3 Gemfile.lock
  2. +1 −2 iron_mq.gemspec
  3. +57 −59 test/quick_run.rb
  4. +46 −77 test/test_iron_mq.rb
  5. +1 −1 test/test_push_queues.rb
View
@@ -8,12 +8,13 @@ GEM
remote: https://rubygems.org/
specs:
beanstalk-client (1.1.1)
- concur (2.1.0)
- concur
+ concur (2.1.1)
ethon (0.5.12)
ffi (>= 1.3.0)
mime-types (~> 1.18)
ffi (1.8.1)
+ go (1.1.0)
+ concur
iron_core (0.6.1)
rest (>= 2.2.0)
iron_worker_ng (0.16.4)
@@ -40,7 +41,7 @@ PLATFORMS
DEPENDENCIES
beanstalk-client
- concur
+ go
iron_mq!
iron_worker_ng
minitest
View
@@ -24,10 +24,9 @@ Gem::Specification.new do |gem|
gem.add_development_dependency "beanstalk-client"
gem.add_development_dependency "uber_config"
gem.add_development_dependency "typhoeus", ">= 0.5.4"
- gem.add_development_dependency "concur"
gem.add_development_dependency "net-http-persistent"
gem.add_development_dependency "quicky"
gem.add_development_dependency "iron_worker_ng"
-
+ gem.add_development_dependency "go"
end
View
@@ -1,7 +1,9 @@
require 'quicky'
+require 'go'
require File.expand_path('test_base.rb', File.dirname(__FILE__))
-TIMES = 100
+THREADS = 1
+TIMES_PER_THREAD = 100
class QuickRun < TestBase
@@ -10,81 +12,77 @@ def setup
end
def test_quick
- queue_name = 'ironmq-gem_quick'
- clear_queue(queue_name)
- queue = @client.queue(queue_name)
+ THREADS.times do |i|
+ # todo: should connect first to cut off the initial connection time.
+
+ queue_name = "ironmq_gem_quick_a_#{i}"
+ clear_queue(queue_name)
+ queue = @client.queue(queue_name)
+
+ quicky = Quicky::Timer.new
+ quicky.loop(:test_quick, TIMES_PER_THREAD) do |i|
+ puts "==== LOOP #{i} =================================="
+
+ post_id = nil
+ quicky.time(:post) do
+ res = queue.post("hello world!")
+ # p res
+ assert_not_nil res
+ assert_not_nil res.id
+ post_id = res.id
+ assert !(res.msg.nil? || res.msg.empty?)
+ end
+
+ quicky.time(:get) do
+ msg = queue.get
+ assert_not_nil msg.id
+ assert_equal msg.id, post_id
+ assert !(msg.body.nil? || msg.body.empty?)
+ end
+
+ quicky.time(:delete) do
+ res = queue.delete(post_id)
+ # p res
+ assert_not_nil res
+ assert !(res.msg.nil? || res.msg.empty?)
+ end
+
+ puts "queue size: #{queue.reload.size}"
- quicky = Quicky::Timer.new
-
- # make connection
- res2 = queue.get
- # p res2
+ msg = queue.get
+ # p msg
+ assert_nil msg
- quicky.loop(:test_quick, TIMES) do |i|
- puts "==== LOOP #{i} =================================="
- post_id = nil
- quicky.time(:post) do
- res = queue.post("hello world!")
+ q = @client.queue('test2')
+ res = q.post("hello world!")
# p res
- assert_not_nil res
assert_not_nil res.id
- post_id = res.id
- assert !(res.msg.nil? || res.msg.empty?)
- end
+ assert_not_nil res.msg
- quicky.time(:get) do
- msg = queue.get
+ msg = q.get
+ # p res
+ assert_not_nil msg
assert_not_nil msg.id
- assert_equal msg.id, post_id
- assert !(msg.body.nil? || msg.body.empty?)
- end
+ assert_not_nil msg.body
- quicky.time(:delete) do
- res = queue.delete(post_id)
+ res = msg.delete
# p res
- assert_not_nil res
- assert !(res.msg.nil? || res.msg.empty?)
+ assert_equal 200, res.code, "API must delete message and respond with HTTP 200 status, but returned HTTP #{res.code}"
end
-
+ puts "count: #{quicky.results(:post).count}"
+ puts "avg post: #{quicky.results(:post).duration}"
+ puts "avg get: #{quicky.results(:get).duration}"
+ puts "avg delete: #{quicky.results(:delete).duration}"
puts "queue size: #{queue.reload.size}"
+ resp = queue.delete_queue
+ assert_equal 200, resp.code, "API must respond with HTTP 200 status, but returned HTTP #{resp.code}"
- msg = queue.get
- # p msg
- assert_nil msg
-
-
- q = @client.queue('test2')
- res = q.post("hello world!")
- # p res
- assert_not_nil res.id
- assert_not_nil res.msg
- msg = q.get
- # p res
- assert_not_nil msg
- assert_not_nil msg.id
- assert_not_nil msg.body
-
- res = msg.delete
- # p res
- assert_equal 200, res.code, "API must delete message and respond with HTTP 200 status, but returned HTTP #{res.code}"
end
- puts "count: #{quicky.results(:post).count}"
- puts "avg post: #{quicky.results(:post).duration}"
- puts "avg get: #{quicky.results(:get).duration}"
- puts "avg delete: #{quicky.results(:delete).duration}"
sleep 5
- puts "queue size: #{queue.reload.size}"
-
- # delete queue on test complete
- resp = queue.delete_queue
- assert_equal 200, resp.code, "API must respond with HTTP 200 status, but returned HTTP #{resp.code}"
-
- resp = @client.queue('test2').delete_queue
- assert_equal 200, resp.code, "API must respond with HTTP 200 status, but returned HTTP #{resp.code}"
end
Oops, something went wrong.

0 comments on commit a059c05

Please sign in to comment.