Permalink
Browse files

Merge branch 'visit-queue-fixes' into dev

  • Loading branch information...
2 parents 653c1b1 + 14b3ea2 commit e2643ab35e769b6dd908027e99697d283ae3e014 @dekellum committed Dec 4, 2012
Showing with 42 additions and 0 deletions.
  1. +42 −0 iudex-core/test/test_visit_queue.rb
@@ -171,6 +171,48 @@ def test_configure_type
assert_queue_empty
end
+ def test_configure_type_2
+ @visit_q.config( :delay => 50, :cons => 1 )
+ @visit_q.config( :domain => 'h2.com',
+ :delay => 75, :cons => 2 )
+ @visit_q.config( :domain => 'h2.com', :type => 'ALT',
+ :rate => 20, :cons => 1 )
+ @visit_q = @visit_q.clone
+
+ LOG.debug { "As configured:\n" + @visit_q.dump }
+
+ [ %w[ h2 a 2.2 ],
+ %w[ w.h2:AL2 b 2.1 ],
+ %w[ h2:ALT c 3.2 ],
+ %w[ h2:ALT d 3.1 ],
+ %w[ h1:AL2 a 1.2 ],
+ %w[ h1 b 1.1 ] ].each do |oinp|
+
+ @visit_q.add( order( oinp ) )
+
+ end
+
+ LOG.debug { "After add:\n" + @visit_q.dump }
+
+ assert_equal( 3, @visit_q.host_count, "host count" )
+
+ expected = [ %w[ h2:ALT c 3.2 ],
+ %w[ h2 a 2.2 ],
+ %w[ h1:AL2 a 1.2 ],
+ %w[ h2:ALT d 3.1 ],
+ %w[ h1 b 1.1 ],
+ %w[ w.h2:AL2 b 2.1 ] ]
+
+ p = 0
+ expected.each do |o|
+ assert_equal( o, acquire_order, p += 1 )
+ end
+
+ LOG.debug { "After consumed:\n" + @visit_q.dump }
+
+ assert_queue_empty
+ end
+
def test_multi_access_2
@visit_q.default_max_access_per_host = 2
add_common_orders

0 comments on commit e2643ab

Please sign in to comment.