support Informix common tests over shared mem
Rafael Kitover [Fri, 6 Apr 2012 16:08:39 +0000 (12:08 -0400)]
Support the default Informix connections over shared memory rather than
TCP for running the common tests, including the extra tests.

Shared memory connections have the limitation that a process may only
open one connection to the DB server at a time.

Also fix the t/lib/dbixcsl_common_tests.pm to work with only one
database connection at a time.

t/10_10informix_common.t
t/lib/dbixcsl_common_tests.pm

index e2f77c9..aada1ea 100644 (file)
@@ -144,7 +144,6 @@ my $tester = dbixcsl_common_tests->new(
                 });
 
                 my $dbh1 = $schema->storage->dbh;
-                my $dbh2 = $extra_schema->storage->dbh;
 
                 $dbh1->do(<<'EOF');
                     CREATE TABLE informix_loader_test4 (
@@ -162,6 +161,13 @@ EOF
                 $dbh1->do(<<'EOF');
 ALTER TABLE informix_loader_test5 ADD CONSTRAINT UNIQUE (four_id) CONSTRAINT loader_test5_uniq
 EOF
+
+                my $db1 = db_name($schema);
+
+                $dbh1->disconnect;
+
+                my $dbh2 = $extra_schema->storage->dbh;
+
                 $dbh2->do(<<'EOF');
                     CREATE TABLE informix_loader_test5 (
                         pk SERIAL PRIMARY KEY,
@@ -186,9 +192,10 @@ EOF
                     )
 EOF
 
-                my $db1 = db_name($schema);
                 my $db2 = db_name($extra_schema);
 
+                $dbh2->disconnect;
+
                 my $db1_moniker = join '', map ucfirst lc, split_name to_identifier $db1;
                 my $db2_moniker = join '', map ucfirst lc, split_name to_identifier $db2;
 
@@ -211,6 +218,8 @@ EOF
                             [ $dsn, $user, $password ],
                         );
 
+                        InformixMultiDatabase->storage->disconnect;
+
                         diag join "\n", @warns if @warns;
 
                         is @warns, 0;
@@ -338,23 +347,37 @@ sub db_name {
     local $schema->loader->{schema} = $schema;
 
     return $schema->loader->_current_db;
+
+    $schema->storage->disconnect;
 }
 
 END {
     if (not $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}) {
         if (my $dbh2 = try { $extra_schema->storage->dbh }) {
-            my $dbh1 = $schema->storage->dbh;
 
             try {
                 $dbh2->do('DROP TABLE informix_loader_test7');
                 $dbh2->do('DROP TABLE informix_loader_test6');
                 $dbh2->do('DROP TABLE informix_loader_test5');
+            }
+            catch {
+                die "Error dropping test tables: $_";
+            };
+
+            $dbh2->disconnect;
+        }
+
+        if (my $dbh1 = try { $schema->storage->dbh }) {
+            
+            try {
                 $dbh1->do('DROP TABLE informix_loader_test5');
                 $dbh1->do('DROP TABLE informix_loader_test4');
             }
             catch {
                 die "Error dropping test tables: $_";
             };
+
+            $dbh1->disconnect;
         }
 
         rmtree EXTRA_DUMP_DIR;
index 5b04a41..74bef9d 100644 (file)
@@ -1297,7 +1297,7 @@ sub test_preserve_case {
 
     my ($oqt, $cqt) = $self->get_oqt_cqt(always => 1); # open quote, close quote
 
-    my $dbh = $self->dbconnect;
+    my $dbh = $conn->storage->dbh;
 
     my ($table40_name, $table41_name) = @{ $self->{preserve_case_tests_table_names} };