Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 42503 invoked from network); 28 Mar 2008 10:54:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Mar 2008 10:54:51 -0000 Received: (qmail 99656 invoked by uid 500); 28 Mar 2008 10:54:51 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 99631 invoked by uid 500); 28 Mar 2008 10:54:51 -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 99620 invoked by uid 99); 28 Mar 2008 10:54:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Mar 2008 03:54:50 -0700 X-ASF-Spam-Status: No, hits=-1998.8 required=10.0 tests=ALL_TRUSTED,FS_REPLICA X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Mar 2008 10:54:07 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2913A1A9832; Fri, 28 Mar 2008 03:54:26 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r642193 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: suites/All.java tests/replicationTests/ReplicationRun.java tests/replicationTests/ReplicationRun_Local_1.java tests/replicationTests/ReplicationSuite.java Date: Fri, 28 Mar 2008 10:54:23 -0000 To: derby-commits@db.apache.org From: oysteing@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080328105426.2913A1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: oysteing Date: Fri Mar 28 03:54:09 2008 New Revision: 642193 URL: http://svn.apache.org/viewvc?rev=642193&view=rev Log: DERBY-3162: Make replication tests run when starting with a relative path for classpath Enable ReplicationSuite in suites.All Contributed by Ole Solberg Details: 1. java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java .1 Added ReplicationRun_Local_1.suite() which does a simple consistency test on contents in master and slave db's after replication. 2. java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java .1 Set user.dir and derby.system.home correctly when starting servers. (StartServer()) .2 Minor cleanup on detecting we are running in a "localhost" environment. .3 Cleanup some DEBUG. .4 Do master and slave verification directly from the ReplicationRun VM. (verifySlave(), verifyMaster()) .5 Set user.dir correctly when running existing JUnit tests as "replication load". (runUserCommandLocally()) 3. java/testing/org/apache/derbyTesting/functionTests/suites/All.java .1 Add ReplicationSuite.suite() to suites.All. Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_1.java (with props) Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/All.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/All.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/All.java?rev=642193&r1=642192&r2=642193&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/All.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/All.java Fri Mar 28 03:54:09 2008 @@ -51,8 +51,7 @@ suite.addTest(EncryptionSuite.suite()); // Replication tests - // These tests currently don't behave well on Windows: - // suite.addTest(ReplicationSuite.suite()); + suite.addTest(ReplicationSuite.suite()); return suite; } 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=642193&r1=642192&r2=642193&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 Fri Mar 28 03:54:09 2008 @@ -338,7 +338,7 @@ } else { // JUnit - if ( classPath != null ) // "localhost" case... + if ( testClientHost.equals("localhost") ) { testingClassPath = classPath; // Using the complete classpath } @@ -359,7 +359,7 @@ String results = null; if ( testClientHost.equalsIgnoreCase("localhost") ) { - runUserCommandLocally(command, userDir, "runTest "); + runUserCommandLocally(command, userDir+FS+masterDbSubPath, "runTest "); } else { @@ -378,7 +378,7 @@ String dbName) throws Exception { - util.DEBUG("runTest(" + replicationTest + util.DEBUG("runTestOnSlave(" + replicationTest + ", " + clientVM + ", " + testClientHost + ", " + serverHost @@ -427,7 +427,7 @@ } else { // JUnit - if ( classPath != null ) // "localhost" case... + if ( testClientHost.equals("localhost") ) { testingClassPath = classPath; // Using the complete classpath } @@ -448,14 +448,14 @@ String results = null; if ( testClientHost.equalsIgnoreCase("localhost") ) { - runUserCommandLocally(command, userDir, "runTest "); + runUserCommandLocally(command, userDir+FS+slaveDbSubPath, "runTestOnSlave "); } else { command = "cd "+ userDir +";" // Must be positioned where the properties file is located. + command; results = runUserCommandRemotely(command, testClientHost, testUser, - "runTest "); + "runTestOnSlave "); } util.DEBUG("Time: " + (System.currentTimeMillis() - startTime) / 1000.0); @@ -892,14 +892,14 @@ String state = se.getSQLState(); String expectedState = "XRE04"; util.DEBUG("startMaster Got SQLException: " - + errCode + " " + state + " " + msg); + + errCode + " " + state + " " + msg + ". Expected " + expectedState); if ( (errCode == -1) && (state.equalsIgnoreCase(expectedState) ) ) { util.DEBUG("Not ready to startMaster. " +"Beware: Will also report " + "'... got a fatal error for database '...../'" - + " in master derby-log."); + + " in master derby.log."); Thread.sleep(100L); // ms. } else @@ -908,12 +908,14 @@ { util.DEBUG("Master already started?"); } + util.DEBUG("Got: "+state+" Expected "+expectedState); throw se; } } this.assertTrue("startMaster did not succeed.", count++ < 100); // 100*100ms = 10s. } + util.DEBUG("startMaster_direct exit."); } /** @@ -1109,6 +1111,7 @@ { startSlaveException = null; Connection conn = null; + String expectedState = "XRE08"; try { // NB! WIll hang here until startMaster is executed! /*On 1.5 locking of Drivermanager.class prevents @@ -1128,11 +1131,11 @@ catch (SQLException se) { startSlaveException = se; + util.DEBUG("Got: "+se.getSQLState()+" Expected: "+expectedState); /* int errCode = se.getErrorCode(); String msg = se.getMessage(); String state = se.getSQLState(); - String expectedState = "XRE08"; util.DEBUG("startSlave Got SQLException: " + errCode + " " + state + " " + msg); if ( (errCode == -1) && (state.equalsIgnoreCase(expectedState) ) ) @@ -1149,12 +1152,14 @@ catch (Exception ex) { startSlaveException = ex; - util.DEBUG("Got Exception " + ex.getMessage()); + util.DEBUG("Got Exception " + ex.getMessage() + +" Expected: SQLException "+expectedState); } } } ); connThread.start(); + util.DEBUG("startSlave_direct exit."); } private void stopSlave(String dbName) @@ -1413,26 +1418,56 @@ void verifySlave() throws Exception { - util.DEBUG("BEGIN verifySlave PROTOTYPE VARIANT!"); - + util.DEBUG("BEGIN verifySlave "+slaveServerHost+":" + +slaveServerPort+"/"+slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb); + ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource(); + ds.setDatabaseName(slaveDatabasePath + FS + slaveDbSubPath + FS + + replicatedDb); + ds.setServerName(slaveServerHost); + ds.setPortNumber(slaveServerPort); + Connection conn = ds.getConnection(); + + simpleVerify(conn); + conn.close(); + /* runSlaveVerificationCLient(jvmVersion, testClientHost, replicatedDb, slaveServerHost, slaveServerPort); - - util.DEBUG("END verifySlave PROTOTYPE VARIANT!"); + */ + util.DEBUG("END verifySlave"); } void verifyMaster() throws Exception { - util.DEBUG("BEGIN verifyMaster PROTOTYPE VARIANT!"); - + util.DEBUG("BEGIN verifyMaster " + masterServerHost + ":" + +masterServerPort+"/"+masterDatabasePath+FS+masterDbSubPath+FS+replicatedDb); + ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource(); + ds.setDatabaseName(masterDatabasePath + FS + masterDbSubPath + FS + + replicatedDb); + ds.setServerName(masterServerHost); + ds.setPortNumber(masterServerPort); + Connection conn = ds.getConnection(); + + simpleVerify(conn); + conn.close(); + /* runMasterVerificationCLient(jvmVersion, testClientHost, replicatedDb, masterServerHost, masterServerPort); - - util.DEBUG("END verifyMaster PROTOTYPE VARIANT!"); + */ + util.DEBUG("END verifyMaster"); + } + private void simpleVerify(Connection conn) // Verification code.. + throws SQLException + { + Statement s = conn.createStatement(); + ResultSet rs = s.executeQuery("select SCHEMAID, TABLENAME from sys.systables"); + while (rs.next()) + { + util.DEBUG(rs.getString(1) + " " + rs.getString(2)); + } } private void runSlaveVerificationCLient(String jvmVersion, @@ -1605,21 +1640,18 @@ return output; } - private void runUserCommandLocally(String command, String userDir, String ID) + private void runUserCommandLocally(String command, String user_dir, String ID) { // Running on localhost. util.DEBUG(""); final String debugId = "runUserCommandLocally " + ID + " "; - util.DEBUG("+++ runUserCommandLocally " + command + " / " + userDir); + util.DEBUG("+++ runUserCommandLocally " + command + " / " + user_dir); - String workingDirName = userDir; - util.DEBUG(debugId+"user.dir: " + workingDirName); - String tmp =""; util.DEBUG(debugId+command); final String fullCmd = command; - String[] envElements = null; + String[] envElements = null; // rt.exec() will inherit.. /* tmp =""; for ( int i=0;i/db_master or ..slave - util.DEBUG(debugId+"user.dir: " + workingDirName); String tmp =""; for ( int i=0;i