[ruby-oci8-commit] [243] branches/ruby-oci8-1.0: * test/config.rb, test/test_break.rb, test/ test_dbi.rb,
nobody at rubyforge.org
nobody at rubyforge.org
Sun Feb 17 05:31:04 EST 2008
Revision: 243
Author: kubo
Date: 2008-02-17 05:31:02 -0500 (Sun, 17 Feb 2008)
Log Message:
-----------
* test/config.rb, test/test_break.rb, test/test_dbi.rb,
test/test_dbi_clob.rb, test/test_metadata.rb, test/test_oci8.rb
sleep a few seconds and retry if an attempt to connect to
a database server fails and its error code is ORA-12516
or ORA-12520 in test cases.
Modified Paths:
--------------
branches/ruby-oci8-1.0/ChangeLog
branches/ruby-oci8-1.0/test/config.rb
branches/ruby-oci8-1.0/test/test_break.rb
branches/ruby-oci8-1.0/test/test_dbi.rb
branches/ruby-oci8-1.0/test/test_dbi_clob.rb
branches/ruby-oci8-1.0/test/test_metadata.rb
branches/ruby-oci8-1.0/test/test_oci8.rb
Modified: branches/ruby-oci8-1.0/ChangeLog
===================================================================
--- branches/ruby-oci8-1.0/ChangeLog 2008-01-15 15:52:14 UTC (rev 242)
+++ branches/ruby-oci8-1.0/ChangeLog 2008-02-17 10:31:02 UTC (rev 243)
@@ -1,3 +1,10 @@
+2008-02-17 KUBO Takehiro <kubo at jiubao.org>
+ * test/config.rb, test/test_break.rb, test/test_dbi.rb,
+ test/test_dbi_clob.rb, test/test_metadata.rb, test/test_oci8.rb
+ sleep a few seconds and retry if an attempt to connect to
+ a database server fails and its error code is ORA-12516
+ or ORA-12520 in test cases.
+
2008-01-12 KUBO Takehiro <kubo at jiubao.org>
* lib/oci8.rb.in: fix OCI8#non_blocking = false problem.
Once the connection became non-bocking mode, it could
Modified: branches/ruby-oci8-1.0/test/config.rb
===================================================================
--- branches/ruby-oci8-1.0/test/config.rb 2008-01-15 15:52:14 UTC (rev 242)
+++ branches/ruby-oci8-1.0/test/config.rb 2008-02-17 10:31:02 UTC (rev 243)
@@ -47,6 +47,29 @@
$test_clob = true
end
+def do_connect ()
+ begin
+ yield
+ rescue OCIError
+ raise if $!.code != 12516 && $!.code != 12520
+ # sleep a few seconds and try again if
+ # the error code is ORA-12516 or ORA-12520.
+ #
+ # ORA-12516 - TNS:listener could not find available handler with
+ # matching protocol stack
+ # ORA-12520 - TNS:listener could not find available handler for
+ # requested type of server
+ #
+ # Thanks to Christopher Jones.
+ #
+ # Ref: The Underground PHP and Oracle Manual (page 175 in vesion 1.4)
+ # http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf
+ #
+ sleep(5)
+ yield
+ end
+end
+
$env_is_initialized = false
def setup_lowapi()
if ! $env_is_initialized
@@ -58,11 +81,19 @@
$env_is_initialized = true
end
env = OCIEnv.init()
- svc = env.logon($dbuser, $dbpass, $dbname)
+ svc = do_connect { env.logon($dbuser, $dbpass, $dbname) }
stmt = env.alloc(OCIStmt)
return env, svc, stmt
end
+def get_oci_connection()
+ do_connect { OCI8.new($dbuser, $dbpass, $dbname) }
+end
+
+def get_dbi_connection()
+ do_connect { DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false) }
+end
+
module RUNIT
class TestCase
def drop_table(table_name)
Modified: branches/ruby-oci8-1.0/test/test_break.rb
===================================================================
--- branches/ruby-oci8-1.0/test/test_break.rb 2008-01-15 15:52:14 UTC (rev 242)
+++ branches/ruby-oci8-1.0/test/test_break.rb 2008-02-17 10:31:02 UTC (rev 243)
@@ -37,7 +37,7 @@
end
def test_set_blocking_mode
- conn = OCI8.new($dbuser, $dbpass, $dbname)
+ conn = get_oci_connection()
conn.non_blocking = true
assert_equal(true, conn.non_blocking?)
conn.non_blocking = false
@@ -48,7 +48,7 @@
end
def test_blocking_mode
- conn = OCI8.new($dbuser, $dbpass, $dbname)
+ conn = get_oci_connection()
conn.non_blocking = false
expect = []
expect[PLSQL_DONE] = TIME_IN_PLSQL
@@ -59,7 +59,7 @@
end
def test_non_blocking_mode
- conn = OCI8.new($dbuser, $dbpass, $dbname)
+ conn = get_oci_connection()
conn.non_blocking = true
expect = []
expect[PLSQL_DONE] = "Invalid status"
Modified: branches/ruby-oci8-1.0/test/test_dbi.rb
===================================================================
--- branches/ruby-oci8-1.0/test/test_dbi.rb 2008-01-15 15:52:14 UTC (rev 242)
+++ branches/ruby-oci8-1.0/test/test_dbi.rb 2008-02-17 10:31:02 UTC (rev 243)
@@ -7,7 +7,7 @@
class TestDBI < RUNIT::TestCase
def setup
- @dbh = DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
+ @dbh = get_dbi_connection()
end
def test_select
Modified: branches/ruby-oci8-1.0/test/test_dbi_clob.rb
===================================================================
--- branches/ruby-oci8-1.0/test/test_dbi_clob.rb 2008-01-15 15:52:14 UTC (rev 242)
+++ branches/ruby-oci8-1.0/test/test_dbi_clob.rb 2008-02-17 10:31:02 UTC (rev 243)
@@ -7,7 +7,7 @@
class TestDbiCLob < RUNIT::TestCase
def setup
- @dbh = DBI.connect("dbi:OCI8:#{$dbname}", $dbuser, $dbpass, 'AutoCommit' => false)
+ @dbh = get_dbi_connection()
end
def test_insert
Modified: branches/ruby-oci8-1.0/test/test_metadata.rb
===================================================================
--- branches/ruby-oci8-1.0/test/test_metadata.rb 2008-01-15 15:52:14 UTC (rev 242)
+++ branches/ruby-oci8-1.0/test/test_metadata.rb 2008-02-17 10:31:02 UTC (rev 243)
@@ -6,7 +6,7 @@
class TestMetadata < RUNIT::TestCase
def setup
- @conn = OCI8.new($dbuser, $dbpass, $dbname)
+ @conn = get_oci_connection()
end
def teardown
Modified: branches/ruby-oci8-1.0/test/test_oci8.rb
===================================================================
--- branches/ruby-oci8-1.0/test/test_oci8.rb 2008-01-15 15:52:14 UTC (rev 242)
+++ branches/ruby-oci8-1.0/test/test_oci8.rb 2008-02-17 10:31:02 UTC (rev 243)
@@ -6,7 +6,7 @@
class TestOCI8 < RUNIT::TestCase
def setup
- @conn = OCI8.new($dbuser, $dbpass, $dbname)
+ @conn = get_oci_connection()
end
def teardown
More information about the ruby-oci8-commit
mailing list