[ruby-oci8-commit] [472] trunk/ruby-oci8: fix to pass a connection pool test.

nobody at rubyforge.org nobody at rubyforge.org
Sat Dec 3 03:55:11 EST 2011


Revision: 472
Author:   kubo
Date:     2011-12-03 03:55:11 -0500 (Sat, 03 Dec 2011)

Log Message:
-----------
fix to pass a connection pool test.
OCI8::ConnectionPool#open_count after decrement depends on Oracle version. (reported by Yasuo Honda)

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/test/test_connection_pool.rb

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2011-12-03 05:16:13 UTC (rev 471)
+++ trunk/ruby-oci8/ChangeLog	2011-12-03 08:55:11 UTC (rev 472)
@@ -1,10 +1,17 @@
 2011-12-03  KUBO Takehiro  <kubo at jiubao.org>
+	* test/test_connection_pool.rb: fix to pass a connection pool test.
+	    OCI8::ConnectionPool#open_count after decrement depends on
+	    Oracle version. (reported by Yasuo Honda)
+
+2011-12-03  KUBO Takehiro  <kubo at jiubao.org>
 	* test/test_metadata.rb: Check object type availability by querying
 	    all_objects data dictionary. Fix #3 at http://github.com/kubo/ruby-oci8.
+	    (reported by Yasuo Honda)
 
 2011-12-03  KUBO Takehiro  <kubo at jiubao.org>
 	* ruby-oci8.gemspec: Use Gem::Command.build_args to get arguments
 	    after '--'. This may solve issues #4 at http://github.com/kubo/ruby-oci8.
+	    (reported by jbirdjavi)
 
 2011-12-03  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/apiwrap.yml: fix for run-time Oracle function checking.

Modified: trunk/ruby-oci8/test/test_connection_pool.rb
===================================================================
--- trunk/ruby-oci8/test/test_connection_pool.rb	2011-12-03 05:16:13 UTC (rev 471)
+++ trunk/ruby-oci8/test/test_connection_pool.rb	2011-12-03 08:55:11 UTC (rev 472)
@@ -33,18 +33,19 @@
   end
 
   def check_busy_and_open_count(min_cnt, max_cnt, incr_cnt)
+    msg = "create_pool(#{min_cnt}, #{max_cnt}, #{incr_cnt})"
     # Create a connection pool.
     pool = create_pool(min_cnt, max_cnt, incr_cnt)
-    assert_equal(min_cnt, pool.open_count)
-    assert_equal(0, pool.busy_count)
+    assert_equal(min_cnt, pool.open_count, msg)
+    assert_equal(0, pool.busy_count, msg)
 
     # Create connections from the pool.
     conns = []
     max_cnt.times do
       conns << OCI8.new($dbuser, $dbpass, pool)
     end
-    assert_equal(min_cnt, pool.open_count)
-    assert_equal(0, pool.busy_count)
+    assert_equal(min_cnt, pool.open_count, msg)
+    assert_equal(0, pool.busy_count, msg)
 
     # Execute blocking SQL statements sequentially.
     max_cnt.times do |n|
@@ -52,12 +53,12 @@
         conns[n].exec "BEGIN DBMS_LOCK.SLEEP(1); END;"
       end
       sleep(0.5)
-      assert_equal(min_cnt, pool.open_count)
-      assert_equal(1, pool.busy_count)
+      assert_equal(min_cnt, pool.open_count, msg)
+      assert_equal(1, pool.busy_count, msg)
       thread.join
     end
-    assert_equal(min_cnt, pool.open_count)
-    assert_equal(0, pool.busy_count)
+    assert_equal(min_cnt, pool.open_count, msg)
+    assert_equal(0, pool.busy_count, msg)
 
     # Execute blocking SQL statements parallel to increment open_count.
     threads = []
@@ -67,8 +68,8 @@
       end
     end
     sleep(0.5)
-    assert_equal(min_cnt + incr_cnt, pool.open_count)
-    assert_equal(min_cnt + 1, pool.busy_count)
+    assert_equal(min_cnt + incr_cnt, pool.open_count, msg)
+    assert_equal(min_cnt + 1, pool.busy_count, msg)
 
     # Execute blocking SQL statements parallel up to maximum.
     (min_cnt + 1).upto(max_cnt - 1) do |n|
@@ -77,36 +78,34 @@
       end
     end
     sleep(0.5)
-    assert_equal(max_cnt, pool.open_count)
-    assert_equal(max_cnt, pool.busy_count)
+    assert_equal(max_cnt, pool.open_count, msg)
+    assert_equal(max_cnt, pool.busy_count, msg)
 
     # 
     threads.each do |thr|
       thr.join
     end
-    assert_equal(max_cnt, pool.open_count)
-    assert_equal(0, pool.busy_count)
+    assert_equal(max_cnt, pool.open_count, msg)
+    assert_equal(0, pool.busy_count, msg)
 
     # Set timeout
     pool.timeout = 1
     sleep(1.5)
-    assert_equal(max_cnt, pool.open_count) # open_count doesn't shrink.
-    assert_equal(0, pool.busy_count)
+    assert_equal(max_cnt, pool.open_count, msg) # open_count doesn't shrink.
+    assert_equal(0, pool.busy_count, msg)
     conns[0].ping # make a network roundtrip.
     sleep(0.5)
-    expected_cnt = max_cnt
-    while expected_cnt - incr_cnt > min_cnt
-      expected_cnt -= incr_cnt
-    end
-    assert_equal(expected_cnt, pool.open_count) # open_count shrinks.
-    assert_equal(0, pool.busy_count)
+    # open_count shrinks.
+    # The decrement count depends on Oracle version.
+    assert_operator(pool.open_count, :<, max_cnt, msg)
+    assert_equal(0, pool.busy_count, msg)
 
     # Close all conections.
     conns.each do | conn |
       conn.logoff
     end
-    assert_equal(min_cnt, pool.open_count)
-    assert_equal(0, pool.busy_count)
+    assert_equal(min_cnt, pool.open_count, msg)
+    assert_equal(0, pool.busy_count, msg)
   end
 
   def test_nowait




More information about the ruby-oci8-commit mailing list