Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 61312 invoked from network); 8 Dec 2010 22:45:45 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Dec 2010 22:45:45 -0000 Received: (qmail 70388 invoked by uid 500); 8 Dec 2010 22:45:45 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 70351 invoked by uid 500); 8 Dec 2010 22:45:45 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 70344 invoked by uid 99); 8 Dec 2010 22:45:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Dec 2010 22:45:45 +0000 X-ASF-Spam-Status: No, hits=-1996.4 required=10.0 tests=ALL_TRUSTED,FS_REPLICA X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Dec 2010 22:45:44 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5E2C423888E4; Wed, 8 Dec 2010 22:45:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1043748 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java Date: Wed, 08 Dec 2010 22:45:24 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101208224524.5E2C423888E4@eris.apache.org> Author: kahatlen Date: Wed Dec 8 22:45:24 2010 New Revision: 1043748 URL: http://svn.apache.org/viewvc?rev=1043748&view=rev Log: DERBY-4910: Report underlying exception when replication tests fail Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java?rev=1043748&r1=1043747&r2=1043748&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java Wed Dec 8 22:45:24 2010 @@ -338,18 +338,19 @@ public class ReplicationRun extends Base if ( (errCode == -1) && (sState.equalsIgnoreCase(expectedState) ) ) { + if (count++ >= 600) { + // Have tried 600 * 200 ms == 2 minutes without + // success, so give up now. + fail("Failover did not succeed", se); + } util.DEBUG("Failover not complete."); Thread.sleep(sleeptime); // ms. } else { - se.printStackTrace(); // FIXME! - assertTrue("Connect failed. " + lastmsg, false); - return; + fail("Connect failed", se); } } - - assertTrue("Failover did not succeed.", count++ < 600); // 600*200ms = 120s = 2mins. } } @@ -389,7 +390,7 @@ public class ReplicationRun extends Base { int count = 0; String msg = null; - while ( count++ <= tries ) + while (true) { try { @@ -406,14 +407,16 @@ public class ReplicationRun extends Base } catch ( SQLException se ) { + if (count++ > tries) { + fail("Could not connect in " + (tries * sleepTime) + " ms", + se); + } msg = se.getErrorCode() + "' '" + se.getSQLState() + "' '" + se.getMessage(); util.DEBUG(count + " got '" + msg +"'."); Thread.sleep(sleepTime); // ms. Sleep and try again... } } - assertTrue(msg + ": Could NOT connect in " - + tries+"*"+sleepTime + "ms.",false); } void waitForSQLState(String expectedState, long sleepTime, int tries, @@ -423,7 +426,7 @@ public class ReplicationRun extends Base { int count = 0; String msg = null; - while ( count++ <= tries ) + while (true) { try { @@ -454,16 +457,17 @@ public class ReplicationRun extends Base + (count-1)+"*"+sleepTime + "ms."); return; // Got desired SQLState. } + else if (count++ > tries) + { + fail("SQLState '" + expectedState + "' was not reached in " + + (tries * sleepTime) + " ms", se); + } else { Thread.sleep(sleepTime); // ms. Sleep and try again... } } - } - assertTrue(msg + ": SQLState '"+expectedState+"' was not reached in " - + tries+"*"+sleepTime + "ms.",false); - } void shutdownDb(String jvmVersion, // Not yet used String serverHost, int serverPort, @@ -482,10 +486,11 @@ public class ReplicationRun extends Base try{ Class.forName(DRIVER_CLASS_NAME); // Needed when running from classes! DriverManager.getConnection(dbURL+";shutdown=true"); + fail("Database shutdown should throw exception"); } catch (SQLException se) { - + BaseJDBCTestCase.assertSQLState("08006", se); } } @@ -1051,6 +1056,11 @@ public class ReplicationRun extends Base if ( (errCode == -1) && (sState.equalsIgnoreCase(expectedState) ) ) { + if (count++ > 1200) { + // Have tried for 1200 * 100 ms == 2 minutes + // without success. Give up. + fail("startMaster did not succeed", se); + } util.DEBUG("Not ready to startMaster. " +"Beware: Will also report " + "'... got a fatal error for database '...../'" @@ -1068,8 +1078,6 @@ public class ReplicationRun extends Base throw se; } } - - assertTrue("startMaster did not succeed.", count++ < 1200); // 1200*100ms = 120s = 2mins. } util.DEBUG("startMaster_direct exit."); } @@ -1078,14 +1086,10 @@ public class ReplicationRun extends Base * Get a connection to the master database. * @return A connection to the master database */ - protected Connection getMasterConnection() { + protected Connection getMasterConnection() throws SQLException { if (masterConn == null) { String url = masterURL(replicatedDb); - try { - masterConn = DriverManager.getConnection(url); - } catch (SQLException sqle) { - fail("Could not connect to master database"); - } + masterConn = DriverManager.getConnection(url); } return masterConn; } @@ -1094,14 +1098,10 @@ public class ReplicationRun extends Base * Get a connection to the slave database. * @return A connection to the slave database */ - protected Connection getSlaveConnection() { + protected Connection getSlaveConnection() throws SQLException { if (slaveConn == null) { String url = slaveURL(replicatedDb); - try { - slaveConn = DriverManager.getConnection(url); - } catch (SQLException sqle) { - fail("Could not connect to slave database"); - } + slaveConn = DriverManager.getConnection(url); } return slaveConn; }