You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by my...@apache.org on 2008/10/13 20:45:16 UTC
svn commit: r704197 -
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/
Author: myrnavl
Date: Mon Oct 13 11:45:16 2008
New Revision: 704197
URL: http://svn.apache.org/viewvc?rev=704197&view=rev
Log:
DERBY-3738; add more tests for legal/illegal commands in the replication states.
Patch contributed by Ole Solberg
Added:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p2.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_showStateChange.java (with props)
Modified:
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/ReplicationRun_Distributed.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_1.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/Utils.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=704197&r1=704196&r2=704197&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 Mon Oct 13 11:45:16 2008
@@ -20,8 +20,6 @@
*/
package org.apache.derbyTesting.functionTests.tests.replicationTests;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import org.apache.derby.drda.NetworkServerControl;
import java.net.InetAddress;
@@ -34,7 +32,6 @@
import org.apache.derbyTesting.junit.BaseJDBCTestCase;
import org.apache.derbyTesting.junit.BaseTestCase;
-import org.apache.derbyTesting.junit.SecurityManagerSetup;
/**
* Framework to run replication tests.
@@ -74,7 +71,7 @@
static boolean runUnReplicated = false;
- static int tuplesToInsert = 10000;
+ static int tuplesToInsertPerf = 10000;
static int commitFreq = 0; // autocommit
static String masterDbSubPath = "db_master";
@@ -106,7 +103,7 @@
final static String JVMloc = BaseTestCase.getJavaExecutableName();
static boolean showSysinfo = false;
- static long SLEEP_TIME_MILLIS = 5000L;
+ static long PINGSERVER_SLEEP_TIME_MILLIS = 500L;
static long sleepTime = 5000L; // millisecs.
@@ -174,15 +171,6 @@
super.tearDown();
}
- public static Test suite()
- {
-
- TestSuite suite = new TestSuite("Replication Suite");
-
- suite.addTestSuite( ReplicationRun.class ); // Make sure to rename in subclasses!
-
- return SecurityManagerSetup.noSecurityManager(suite);
- }
//////////////////////////////////////////////////////////////
////
@@ -220,6 +208,8 @@
String dbURL = serverURL
+fullDbPath;
Connection conn = null;
+ String lastmsg = null;
+ long sleeptime = 200L;
boolean done = false;
int count = 0;
while ( !done )
@@ -229,25 +219,29 @@
Class.forName(DRIVER_CLASS_NAME); // Needed when running from classes!
conn = DriverManager.getConnection(dbURL);
done = true;
- util.DEBUG("Connected");
+ util.DEBUG("Got connection after "
+ + count +" * "+ sleeptime + " ms.");
conn.close();
}
catch ( SQLException se )
{
int errCode = se.getErrorCode();
- String msg = se.getMessage();
- String state = se.getSQLState();
+ lastmsg = se.getMessage();
+ String sState = se.getSQLState();
String expectedState = "08004";
- util.DEBUG("startSlave Got SQLException: " + errCode + " " + state + " " + msg);
+ lastmsg = errCode + " " + sState + " " + lastmsg
+ + ". Expected: "+ expectedState;
+ util.DEBUG("Got SQLException: " + lastmsg);
if ( (errCode == -1)
- && (state.equalsIgnoreCase(expectedState) ) )
+ && (sState.equalsIgnoreCase(expectedState) ) )
{
util.DEBUG("Failover not complete.");
- Thread.sleep(200L); // ms.
+ Thread.sleep(sleeptime); // ms.
}
else
{
se.printStackTrace(); // FIXME!
+ assertTrue("Connect failed. " + lastmsg, false);
return;
}
}
@@ -256,6 +250,115 @@
}
}
+ String showCurrentState(String ID, long waitTime,
+ String fullDbPath,
+ String serverHost, int serverPort)
+ throws Exception
+ {
+ int errCode = 0;
+ String sState = "CONNECTED";
+ String msg = null;
+ Thread.sleep(waitTime); // .... until stable...
+ try
+ {
+ ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
+ ds.setDatabaseName(fullDbPath);
+ ds.setServerName(serverHost);
+ ds.setPortNumber(serverPort);
+ Connection conn = ds.getConnection();
+ conn.close();
+ }
+ catch ( SQLException se )
+ {
+ errCode = se.getErrorCode();
+ msg = se.getMessage();
+ sState = se.getSQLState();
+ }
+ util.DEBUG(ID+": ["+serverHost+":"+serverPort+"/"+fullDbPath+"] "
+ + errCode + " " + sState + " " + msg);
+ return sState;
+ }
+ void waitForConnect(long sleepTime, int tries,
+ String fullDbPath,
+ String serverHost, int serverPort)
+ throws Exception
+ {
+ int count = 0;
+ String msg = null;
+ while ( count++ <= tries )
+ {
+ try
+ {
+ ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
+ ds.setDatabaseName(fullDbPath);
+ ds.setServerName(serverHost);
+ ds.setPortNumber(serverPort);
+ Connection conn = ds.getConnection();
+ util.DEBUG("Got connection after "
+ + (count-1) +" * "+ sleepTime + " ms.");
+ conn.close();
+ return;
+ }
+ catch ( SQLException 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,
+ String fullDbPath,
+ String serverHost, int serverPort)
+ throws Exception
+ {
+ int count = 0;
+ String msg = null;
+ while ( count++ <= tries )
+ {
+ try
+ {
+ ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
+ ds.setDatabaseName(fullDbPath);
+ ds.setServerName(serverHost);
+ ds.setPortNumber(serverPort);
+ Connection conn = ds.getConnection();
+ // Should never get here!
+ conn.close();
+ assertTrue("Expected SQLState'"+expectedState
+ + "', but got connection!",
+ false);
+ }
+ catch ( SQLException se )
+ {
+ int errCode = se.getErrorCode();
+ msg = se.getMessage();
+ String sState = se.getSQLState();
+ msg = "'" + errCode + "' '" + sState + "' '" + msg +"'";
+ util.DEBUG(count
+ + ": SQLState expected '"+expectedState+"'," +
+ " got " + msg);
+ if ( sState.equals(expectedState) )
+ {
+ util.DEBUG("Reached SQLState '" + expectedState +"' in "
+ + (count-1)+"*"+sleepTime + "ms.");
+ return; // Got desired SQLState.
+ }
+ 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,
String dbPath, String replicatedDb,
@@ -347,7 +450,7 @@
// + " -Djava.security.policy=\"<NONE>\"" // Now using noSecurityManager decorator
+ " -Dtest.serverHost=" + serverHost // Tell the test what server
+ " -Dtest.serverPort=" + serverPort // and port to connect to.
- + " -Dtest.inserts=" + tuplesToInsert // for SimplePerfTest
+ + " -Dtest.inserts=" + tuplesToInsertPerf // for SimplePerfTest
+ " -Dtest.commitFreq=" + commitFreq // for SimplePerfTest
+ " -classpath " + testingClassPath
+ " junit.textui.TestRunner"
@@ -436,7 +539,7 @@
// + " -Djava.security.policy=\"<NONE>\"" // Now using noSecurityManager decorator
+ " -Dtest.serverHost=" + serverHost // Tell the test what server
+ " -Dtest.serverPort=" + serverPort // and port to connect to.
- + " -Dtest.inserts=" + tuplesToInsert // for SimplePerfTest
+ + " -Dtest.inserts=" + tuplesToInsertPerf // for SimplePerfTest
+ " -Dtest.commitFreq=" + commitFreq // for SimplePerfTest
+ " -classpath " + testingClassPath
+ " junit.textui.TestRunner"
@@ -880,18 +983,18 @@
done = true;
conn.close();
- util.DEBUG("startMaster OK");
+ util.DEBUG("startMaster_direct connected in " + count + " * 100ms.");
}
catch ( SQLException se )
{
int errCode = se.getErrorCode();
String msg = se.getMessage();
- String state = se.getSQLState();
+ String sState = se.getSQLState();
String expectedState = "XRE04";
util.DEBUG("startMaster Got SQLException: "
- + errCode + " " + state + " " + msg + ". Expected " + expectedState);
+ + errCode + " " + sState + " " + msg + ". Expected " + expectedState);
if ( (errCode == -1)
- && (state.equalsIgnoreCase(expectedState) ) )
+ && (sState.equalsIgnoreCase(expectedState) ) )
{
util.DEBUG("Not ready to startMaster. "
+"Beware: Will also report "
@@ -901,7 +1004,7 @@
}
else
{
- if (SQLState.REPLICATION_MASTER_TIMED_OUT.equals(state)) // FIXME! CANNOT_START_MASTER_ALREADY_BOOTED
+ if (SQLState.REPLICATION_MASTER_TIMED_OUT.equals(sState)) // FIXME! CANNOT_START_MASTER_ALREADY_BOOTED
{
util.DEBUG("Master already started?");
}
@@ -1129,29 +1232,10 @@
catch (SQLException se)
{
startSlaveException = se;
- util.DEBUG("Got: "+se.getSQLState()+" Expected: "+expectedState);
- /*
- int errCode = se.getErrorCode();
- String msg = se.getMessage();
- String state = se.getSQLState();
- util.DEBUG("startSlave Got SQLException: " + errCode + " " + state + " " + msg);
- if ( (errCode == -1)
- && (state.equalsIgnoreCase(expectedState) ) )
- {
- util.DEBUG("As expected.");
- }
- else
- {
- util.DEBUG("Got Exception " + msg);
- se.printStackTrace();
- }
- ;*/
}
catch (Exception ex)
{
startSlaveException = ex;
- util.DEBUG("Got Exception " + ex.getMessage()
- +" Expected: SQLException "+expectedState);
}
}
}
@@ -1288,9 +1372,12 @@
{
int errCode = se.getErrorCode();
String msg = se.getMessage();
- String state = se.getSQLState();
+ String sState = se.getSQLState();
String expectedState = "XRE20";
- util.DEBUG("failOver_direct Got SQLException: " + errCode + " " + state + " " + msg);
+ msg = "failOver_direct Got SQLException: "
+ + errCode + " " + sState + " " + msg
+ + ". Expected: " + expectedState;
+ util.DEBUG(msg);
BaseJDBCTestCase.assertSQLState(expectedState, se);
}
}
@@ -2010,7 +2097,7 @@
util.DEBUG("--------------------------------------------------------");
// for SimplePerfTest
- tuplesToInsert = 10000;
+ tuplesToInsertPerf = 10000;
commitFreq = 1000; // "0" is autocommit
util.DEBUG("--------------------------------------------------------");
@@ -2292,8 +2379,8 @@
);
util.DEBUG(debugId+"************** Do .start().");
serverThread.start();
- pingServer(serverHost, serverPort, 15); // Wait for the server to come up in a reasonable time....
-
+ pingServer(serverHost, serverPort, 150); // Wait for the server to come up in a reasonable time....
+
}
util.DEBUG(debugId+"--- StartServer ");
@@ -2320,7 +2407,7 @@
InetAddress.getByName(interfacesToListenOn), serverPort);
server.start(null);
- pingServer(serverHost, serverPort, 15);
+ pingServer(serverHost, serverPort, 150);
Properties sp = server.getCurrentProperties();
sp.setProperty("noSecurityManager",
@@ -2629,17 +2716,21 @@
try
{
controller.ping();
- // DEBUG("Server came up in less than " + i*(SLEEP_TIME_MILLIS/1000) + " secs.");
+ util.DEBUG("Server came up in less than "+i+" * "+PINGSERVER_SLEEP_TIME_MILLIS+"ms.");
return;
}
catch (Exception e)
{ finalException = e; }
- Thread.sleep( SLEEP_TIME_MILLIS );
+ Thread.sleep( PINGSERVER_SLEEP_TIME_MILLIS );
}
- util.DEBUG( "Server did not come up: " + finalException.getMessage() );
- finalException.printStackTrace();
+ String msg = "Could not ping in "
+ + iterations + " * " + PINGSERVER_SLEEP_TIME_MILLIS + "ms.: "
+ + finalException.getMessage();
+ util.DEBUG( msg );
+ finalException.printStackTrace(); // REMOVE?
+ throw new Exception(msg);
}
@@ -3189,4 +3280,95 @@
}
}
+ void assertException(SQLException se, String expectedSqlState)
+ {
+ if (se == null ) // Did not get an exception
+ {
+ util.DEBUG("Got 'null' exception, expected '" + expectedSqlState + "'");
+ assertTrue("Expected exception: " + expectedSqlState + " got: 'null' exception",
+ expectedSqlState == null);
+ return;
+ }
+ int ec = se.getErrorCode();
+ String ss = se.getSQLState();
+ String msg = "Got " + ec + " " + ss + " " + se.getMessage()
+ + ". Expected " + expectedSqlState;
+ util.DEBUG(msg);
+
+ if ( expectedSqlState != null ) // We expect an exception
+ {
+ assertTrue(msg, ss.equals(expectedSqlState));
+ }
+ else // We do not expect an exception, but got one.
+ {
+ assertTrue(msg, false);
+ }
+ }
+
+
+ void _testInsertUpdateDeleteOnMaster(String serverHost,
+ int serverPort,
+ String dbPath,
+ int _noTuplesToInsert)
+ throws SQLException
+ {
+ util.DEBUG("_testInsertUpdateDeleteOnMaster: " + serverHost + ":" +
+ serverPort + "/" + dbPath + " " + _noTuplesToInsert);
+ ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
+ ds.setDatabaseName(dbPath);
+ ds.setServerName(serverHost);
+ ds.setPortNumber(serverPort);
+ Connection conn = ds.getConnection();
+
+ PreparedStatement ps = conn.prepareStatement("create table t(i integer primary key, s varchar(64))");
+
+ ps.execute();
+
+ ps = conn.prepareStatement("insert into t values (?,?)");
+ for (int i = 0; i< _noTuplesToInsert; i++)
+ {
+ ps.setInt(1,i);
+ ps.setString(2,"dilldall"+i);
+ ps.execute();
+ if ( (i % 10000) == 0 ) conn.commit();
+ }
+
+ _verify(conn, _noTuplesToInsert);
+
+ conn.close();
+ }
+ void _verifyDatabase(String serverHost,
+ int serverPort,
+ String dbPath,
+ int _noTuplesInserted)
+ throws SQLException
+ {
+ util.DEBUG("_verifyDatabase: "+serverHost+":"+serverPort+"/"+dbPath);
+ ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
+ ds.setDatabaseName(dbPath);
+ ds.setServerName(serverHost);
+ ds.setPortNumber(serverPort);
+ Connection conn = ds.getConnection();
+
+ _verify(conn,_noTuplesInserted);
+
+ conn.close();
+ }
+ void _verify(Connection conn, int _noTuplesInserted)
+ throws SQLException
+ {
+ Statement s = conn.createStatement();
+ ResultSet rs = s.executeQuery("select count(*) from t");
+ rs.next();
+ int count = rs.getInt(1);
+ rs = s.executeQuery("select max(i) from t");
+ rs.next();
+ int max = rs.getInt(1);
+ util.DEBUG("_verify: " + count + "/" + _noTuplesInserted + " " + max +
+ "/" + (_noTuplesInserted - 1));
+ assertEquals("Expected "+ _noTuplesInserted +" tuples, got "+ count +".",
+ _noTuplesInserted, count);
+ assertEquals("Expected " +(_noTuplesInserted-1) +" max, got " + max +".",
+ _noTuplesInserted - 1, max);
+ }
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Distributed.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Distributed.java?rev=704197&r1=704196&r2=704197&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Distributed.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Distributed.java Mon Oct 13 11:45:16 2008
@@ -301,7 +301,7 @@
System.out.println("--------------------------------------------------------");
// for SimplePerfTest
- tuplesToInsert = Integer.parseInt(cp.getProperty("test.inserts","10000"));
+ tuplesToInsertPerf = Integer.parseInt(cp.getProperty("test.inserts","10000"));
commitFreq = Integer.parseInt(cp.getProperty("test.commitFreq","0")); // "0" is autocommit
System.out.println("--------------------------------------------------------");
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java?rev=704197&r1=704196&r2=704197&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java Mon Oct 13 11:45:16 2008
@@ -77,7 +77,7 @@
////
//////////////////////////////////////////////////////////////
- public void testReplication_Local()
+ public void testReplication_Local_existingTestsAsReplLoad()
throws Exception
{
cleanAllTestHosts();
@@ -175,7 +175,7 @@
* after copying the db to the slave location
* @throws java.lang.Exception on test errors.
*/
- public void testLogFilesSynched() throws Exception {
+ public void testReplication_Local_LogFilesSynched() throws Exception {
cleanAllTestHosts();
initEnvironment();
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_1.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_1.java?rev=704197&r1=704196&r2=704197&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_1.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_1.java Mon Oct 13 11:45:16 2008
@@ -20,14 +20,8 @@
*/
package org.apache.derbyTesting.functionTests.tests.replicationTests;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.apache.derby.jdbc.ClientDataSource;
import org.apache.derbyTesting.junit.SecurityManagerSetup;
@@ -60,7 +54,7 @@
}
- public void testReplication_Local_1()
+ public void testReplication_Local_1_InsertUpdateDeleteOnMaster()
throws Exception
{
cleanAllTestHosts();
@@ -105,8 +99,10 @@
// Replication "load"
String dbPath = masterDatabasePath + FS + masterDbSubPath + FS +
replicatedDb;
+
+ int tuplesToInsert = 10000;
_testInsertUpdateDeleteOnMaster(masterServerHost, masterServerPort,
- dbPath);
+ dbPath, tuplesToInsert);
failOver(jvmVersion,
masterDatabasePath, masterDbSubPath, replicatedDb,
@@ -120,77 +116,12 @@
// verifySlave();
dbPath = slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb;
_verifyDatabase(slaveServerHost, slaveServerPort,
- dbPath);
+ dbPath, tuplesToInsert);
// We should verify the master as well,
// at least to see that we still can connect.
// verifyMaster();
dbPath = masterDatabasePath +FS+masterDbSubPath +FS+ replicatedDb;
_verifyDatabase(masterServerHost, masterServerPort,
- dbPath);
- }
-
- private final int noTuplesToInsert = 10000;
- private void _testInsertUpdateDeleteOnMaster(String serverHost,
- int serverPort,
- String dbPath)
- throws SQLException
- {
- util.DEBUG("_testInsertUpdateDeleteOnMaster: " + serverHost + ":" +
- serverPort + "/" + dbPath);
- ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
- ds.setDatabaseName(dbPath);
- ds.setServerName(serverHost);
- ds.setPortNumber(serverPort);
- Connection conn = ds.getConnection();
-
- PreparedStatement ps = conn.prepareStatement("create table t(i integer primary key, s varchar(64))");
-
- ps.execute();
-
- ps = conn.prepareStatement("insert into t values (?,?)");
- for (int i = 0; i< noTuplesToInsert; i++)
- {
- ps.setInt(1,i);
- ps.setString(2,"dilldall"+i);
- ps.execute();
- if ( (i % 10000) == 0 ) conn.commit();
- }
-
- _verify(conn);
-
- conn.close();
- }
- private void _verifyDatabase(String serverHost,
- int serverPort,
- String dbPath)
- throws SQLException
- {
- util.DEBUG("_verifyDatabase: "+serverHost+":"+serverPort+"/"+dbPath);
- ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
- ds.setDatabaseName(dbPath);
- ds.setServerName(serverHost);
- ds.setPortNumber(serverPort);
- Connection conn = ds.getConnection();
-
- _verify(conn);
-
- conn.close();
- }
- private void _verify(Connection conn)
- throws SQLException
- {
- Statement s = conn.createStatement();
- ResultSet rs = s.executeQuery("select count(*) from t");
- rs.next();
- int count = rs.getInt(1);
- rs = s.executeQuery("select max(i) from t");
- rs.next();
- int max = rs.getInt(1);
- util.DEBUG("_verify: " + count + "/" + noTuplesToInsert + " " + max +
- "/" + (noTuplesToInsert - 1));
- assertEquals("Expected "+ noTuplesToInsert +" tuples, got "+ count +".",
- noTuplesToInsert, count);
- assertEquals("Expected " +(noTuplesToInsert-1) +" max, got " + max +".",
- noTuplesToInsert - 1, max);
+ dbPath, tuplesToInsert);
}
}
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java?rev=704197&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java Mon Oct 13 11:45:16 2008
@@ -0,0 +1,146 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_3
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+ */
+package org.apache.derbyTesting.functionTests.tests.replicationTests;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import org.apache.derby.jdbc.ClientDataSource;
+
+
+/**
+ * Run a replication test on localhost
+ * by using default values for master and slave hosts,
+ * and master and slave ports.
+ *
+ */
+
+public class ReplicationRun_Local_3 extends ReplicationRun
+{
+
+ /**
+ * Creates a new instance of ReplicationRun_Local
+ * @param testcaseName Identifying the test.
+ */
+ public ReplicationRun_Local_3(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ //////////////////////////////////////////////////////////////
+ ////
+ //// The replication test framework (testReplication()):
+ //// a) "clean" replication run starting master and slave servers,
+ //// preparing master and slave databases,
+ //// starting and stopping replication and doing
+ //// failover for a "normal"/"failure free" replication
+ //// test run.
+ ////
+ //////////////////////////////////////////////////////////////
+
+
+ SQLException _failOver(String serverHost, int serverPort, String dbPath)
+ {
+ util.DEBUG("BEGIN _failOver");
+ ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
+ ds.setDatabaseName(dbPath);
+ ds.setServerName(serverHost);
+ ds.setPortNumber(serverPort);
+ ds.setConnectionAttributes("failover=true");
+ try {
+ Connection conn = ds.getConnection(); //
+ conn.close();
+ util.DEBUG("END _failOver. Got Connection");
+ return null; // If successfull - could only happen on slave after a master stopMaster.
+ } catch (SQLException se) {
+ util.DEBUG("END _failOver. " + se.getSQLState());
+ return se;
+ }
+
+ }
+
+ SQLException _startSlaveTrueAndCreateTrue(String serverHost,
+ int serverPort,
+ String dbPath)
+ throws SQLException
+ {
+ util.DEBUG("_startSlaveTrueAndCreateTrue");
+ ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
+ ds.setDatabaseName(dbPath);
+ ds.setServerName(serverHost);
+ ds.setPortNumber(serverPort);
+ ds.setConnectionAttributes("startSlave=true;create=true");
+ try {
+ Connection conn = ds.getConnection(); // XRE10 - REPLICATION_CONFLICTING_ATTRIBUTES
+ conn.close();
+ return null; // Should never get here.
+ } catch (SQLException se) {
+ return se;
+ }
+ }
+
+ SQLException _stopMaster(String masterServerHost, int masterServerPort, String dbPath)
+ {
+ util.DEBUG("_stopMaster");
+ ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
+ ds.setDatabaseName(dbPath);
+ ds.setServerName(masterServerHost);
+ ds.setPortNumber(masterServerPort);
+ ds.setConnectionAttributes("stopMaster=true");
+ try {
+ Connection conn = ds.getConnection(); //
+ conn.close();
+ return null; // If successfull.
+ } catch (SQLException se) {
+ util.DEBUG(se.getErrorCode()+" "+se.getSQLState()+" "+se.getMessage());
+ return se;
+ }
+ }
+
+ SQLException _stopSlave(String slaveServerHost, int slaveServerPort,
+ String dbPath)
+ throws SQLException
+ {
+ util.DEBUG("_stopSlave");
+ ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
+ ds.setDatabaseName(dbPath);
+ ds.setServerName(slaveServerHost);
+ ds.setPortNumber(slaveServerPort);
+ ds.setConnectionAttributes("stopSlave=true");
+ try {
+ Connection conn = ds.getConnection();
+ conn.close();
+ return null; // If successfull.
+ } catch (SQLException se) {
+ return se;
+ }
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java?rev=704197&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java Mon Oct 13 11:45:16 2008
@@ -0,0 +1,229 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_3_p1
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+ */
+package org.apache.derbyTesting.functionTests.tests.replicationTests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.SecurityManagerSetup;
+
+
+/**
+ * Run a replication test on localhost
+ * by using default values for master and slave hosts,
+ * and master and slave ports.
+ *
+ */
+
+public class ReplicationRun_Local_3_p1 extends ReplicationRun_Local_3
+{
+
+ /**
+ * Creates a new instance of ReplicationRun_Local
+ * @param testcaseName Identifying the test.
+ */
+ public ReplicationRun_Local_3_p1(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("ReplicationRun_Local_3_p1 Suite");
+
+ suite.addTestSuite( ReplicationRun_Local_3_p1.class );
+
+ return SecurityManagerSetup.noSecurityManager(suite);
+
+ }
+
+ //////////////////////////////////////////////////////////////
+ ////
+ //// The replication test framework (testReplication()):
+ //// a) "clean" replication run starting master and slave servers,
+ //// preparing master and slave databases,
+ //// starting and stopping replication and doing
+ //// failover for a "normal"/"failure free" replication
+ //// test run.
+ ////
+ //////////////////////////////////////////////////////////////
+
+ public void testReplication_Local_3_p1_StateNegativeTests()
+ throws Exception
+ {
+ cleanAllTestHosts();
+
+ initEnvironment();
+
+ initMaster(masterServerHost,
+ replicatedDb);
+
+ masterServer = startServer(masterJvmVersion, derbyMasterVersion,
+ masterServerHost,
+ ALL_INTERFACES, // masterServerHost, // "0.0.0.0", // All. or use masterServerHost for interfacesToListenOn,
+ masterServerPort,
+ masterDbSubPath); // Distinguishing master/slave
+
+ slaveServer = startServer(slaveJvmVersion, derbySlaveVersion,
+ slaveServerHost,
+ ALL_INTERFACES, // slaveServerHost, // "0.0.0.0", // All. or use slaveServerHost for interfacesToListenOn,
+ slaveServerPort,
+ slaveDbSubPath); // Distinguishing master/slave
+
+ startServerMonitor(slaveServerHost);
+
+ bootMasterDatabase(jvmVersion,
+ masterDatabasePath +FS+ masterDbSubPath,
+ replicatedDb,
+ masterServerHost, // Where the startreplication command must be given
+ masterServerPort, // master server interface accepting client requests
+ null // bootLoad, // The "test" to start when booting db.
+ );
+
+ // 4. separate test
+ // master db created...
+ // slave: connect 'startSlave=true;create=true'
+ assertException(
+ _startSlaveTrueAndCreateTrue(slaveServerHost, slaveServerPort,
+ masterDatabasePath +FS+ masterDbSubPath +FS+ replicatedDb),
+ "XRE10"); // REPLICATION_CONFLICTING_ATTRIBUTES // OK to continue.
+
+ initSlave(slaveServerHost,
+ jvmVersion,
+ replicatedDb); // Trunk and Prototype V2: copy master db to db_slave.
+
+ startSlave(jvmVersion, replicatedDb,
+ slaveServerHost, // slaveClientInterface // where the slave db runs
+ slaveServerPort,
+ slaveServerHost, // for slaveReplInterface
+ slaveReplPort,
+ testClientHost);
+
+ startMaster(jvmVersion, replicatedDb,
+ masterServerHost, // Where the startMaster command must be given
+ masterServerPort, // master server interface accepting client requests
+ masterServerHost, // An interface on the master: masterClientInterface (==masterServerHost),
+ slaveServerPort, // Not used since slave don't allow clients.
+ slaveServerHost, // for slaveReplInterface
+ slaveReplPort);
+
+ runTest(null, // Returns immediatly if replicationTest is null.
+ jvmVersion,
+ testClientHost,
+ masterServerHost, masterServerPort,
+ replicatedDb);
+
+ // 1. separate test
+ // slave: stopSlave
+ assertException(
+ _stopSlave(slaveServerHost, slaveServerPort,
+ slaveDatabasePath + FS + slaveDbSubPath + FS + replicatedDb),
+ "XRE41"); // SLAVE_OPERATION_DENIED_WHILE_CONNECTED // OK to continue
+
+ // 2. separate test
+ // master: stopSlave
+ // master: stopMaster
+ // slave: stopSlave
+ assertException(
+ _stopSlave(masterServerHost, masterServerPort,
+ masterDatabasePath + FS + masterDbSubPath + FS + replicatedDb),
+ "XRE40"); // REPLICATION_NOT_IN_SLAVE_MODE // OK to continue
+ assertException(
+ _stopMaster(masterServerHost, masterServerPort,
+ masterDatabasePath + FS + masterDbSubPath + FS + replicatedDb),
+ null); // Implies failover. // OK to continue. We have failover.
+ /* showCurrentState("Post stopMaster", 0L,
+ slaveDatabasePath + FS + slaveDbSubPath + FS + replicatedDb,
+ slaveServerHost, slaveServerPort);
+ showCurrentState("Post stopMaster +1s", 1000L,
+ slaveDatabasePath + FS + slaveDbSubPath + FS + replicatedDb,
+ slaveServerHost, slaveServerPort); */
+ waitForConnect(100L, 10,
+ slaveDatabasePath + FS + slaveDbSubPath + FS + replicatedDb,
+ slaveServerHost, slaveServerPort);
+ assertException(
+ _stopSlave(slaveServerHost, slaveServerPort,
+ slaveDatabasePath + FS + slaveDbSubPath + FS + replicatedDb),
+ "XRE40"); // REPLICATION_NOT_IN_SLAVE_MODE // OK to continue
+ /* showCurrentState("Post stopMaster, stopSlave", 0L,
+ slaveDatabasePath + FS + slaveDbSubPath + FS + replicatedDb,
+ slaveServerHost, slaveServerPort);
+ showCurrentState("Post stopMaster, stopSlave +1s", 1000L,
+ slaveDatabasePath + FS + slaveDbSubPath + FS + replicatedDb,
+ slaveServerHost, slaveServerPort); */
+ /* showCurrentState("Post stopMaster, stopSlave +1s", 0L,
+ masterDatabasePath + FS + masterDbSubPath + FS + replicatedDb,
+ masterServerHost, masterServerPort); */
+ waitForConnect(100L, 10,
+ masterDatabasePath + FS + masterDbSubPath + FS + replicatedDb,
+ masterServerHost, masterServerPort);
+
+
+ /* BEGIN In ReplicationRun_Local_3_p2.java:
+ // 3. separate test
+ // stopMaster
+ // failover on slave
+
+ // 5. separate test
+ // slave: "normal" connect to slave db
+
+ // 6. separate test
+ // slave: 'internal-stopslave=true'
+ END */
+
+ /* failOver(jvmVersion,
+ masterDatabasePath, masterDbSubPath, replicatedDb,
+ masterServerHost, // Where the master db is run.
+ masterServerPort,
+ testClientHost);
+ */
+ assertException(
+ _failOver(masterServerHost, masterServerPort,
+ masterDatabasePath+FS+masterDbSubPath+FS+replicatedDb),
+ "XRE07"); // REPLICATION_NOT_IN_MASTER_MODE
+
+ connectPing(slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb,
+ slaveServerHost,slaveServerPort,
+ testClientHost);
+
+ verifySlave();
+
+ // We should verify the master as well, at least to see that we still can connect.
+ verifyMaster();
+
+ stopServer(jvmVersion, derbyVersion,
+ slaveServerHost, slaveServerPort);
+
+ stopServer(jvmVersion, derbyVersion,
+ masterServerHost, masterServerPort);
+
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p2.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p2.java?rev=704197&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p2.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p2.java Mon Oct 13 11:45:16 2008
@@ -0,0 +1,254 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_3_p2
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+ */
+package org.apache.derbyTesting.functionTests.tests.replicationTests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.SecurityManagerSetup;
+
+
+/**
+ * Run a replication test on localhost
+ * by using default values for master and slave hosts,
+ * and master and slave ports.
+ *
+ */
+
+public class ReplicationRun_Local_3_p2 extends ReplicationRun_Local_3
+{
+
+ /**
+ * Creates a new instance of ReplicationRun_Local
+ * @param testcaseName Identifying the test.
+ */
+ public ReplicationRun_Local_3_p2(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("ReplicationRun_Local_3_p2 Suite");
+
+ suite.addTestSuite( ReplicationRun_Local_3_p2.class );
+
+ return SecurityManagerSetup.noSecurityManager(suite);
+
+ }
+
+ //////////////////////////////////////////////////////////////
+ ////
+ //// The replication test framework (testReplication()):
+ //// a) "clean" replication run starting master and slave servers,
+ //// preparing master and slave databases,
+ //// starting and stopping replication and doing
+ //// failover for a "normal"/"failure free" replication
+ //// test run.
+ ////
+ //////////////////////////////////////////////////////////////
+
+ public void replication_Local_3_p2_StateTests(boolean bigInsert,
+ boolean immediateStopMaster) // no sleep between startMaster and stopMaster.
+ throws Exception
+ {
+ cleanAllTestHosts();
+
+ initEnvironment();
+
+ initMaster(masterServerHost,
+ replicatedDb);
+
+ masterServer = startServer(masterJvmVersion, derbyMasterVersion,
+ masterServerHost,
+ ALL_INTERFACES, // masterServerHost, // "0.0.0.0", // All. or use masterServerHost for interfacesToListenOn,
+ masterServerPort,
+ masterDbSubPath); // Distinguishing master/slave
+
+ slaveServer = startServer(slaveJvmVersion, derbySlaveVersion,
+ slaveServerHost,
+ ALL_INTERFACES, // slaveServerHost, // "0.0.0.0", // All. or use slaveServerHost for interfacesToListenOn,
+ slaveServerPort,
+ slaveDbSubPath); // Distinguishing master/slave
+
+ startServerMonitor(slaveServerHost);
+
+ bootMasterDatabase(jvmVersion,
+ masterDatabasePath +FS+ masterDbSubPath,
+ replicatedDb,
+ masterServerHost, // Where the startreplication command must be given
+ masterServerPort, // master server interface accepting client requests
+ null // bootLoad, // The "test" to start when booting db.
+ );
+
+ /* In ReplicationRun_Local_3_p1
+ // 4 separate test
+ // master db created...
+ // slave: connect 'startSlave=true;create=true'
+ */
+
+ initSlave(slaveServerHost,
+ jvmVersion,
+ replicatedDb); // Trunk and Prototype V2: copy master db to db_slave.
+
+ startSlave(jvmVersion, replicatedDb,
+ slaveServerHost, // slaveClientInterface // where the slave db runs
+ slaveServerPort,
+ slaveServerHost, // for slaveReplInterface
+ slaveReplPort,
+ testClientHost);
+
+ startMaster(jvmVersion, replicatedDb,
+ masterServerHost, // Where the startMaster command must be given
+ masterServerPort, // master server interface accepting client requests
+ masterServerHost, // An interface on the master: masterClientInterface (==masterServerHost),
+ slaveServerPort, // Not used since slave don't allow clients.
+ slaveServerHost, // for slaveReplInterface
+ slaveReplPort);
+
+ /* runTest(null, // Returns immediatly if replicationTest is null.
+ jvmVersion,
+ testClientHost,
+ masterServerHost, masterServerPort,
+ replicatedDb); */
+ String masterDb = masterDatabasePath+FS+masterDbSubPath+FS+replicatedDb;
+ // boolean bigInsert = true;
+ // boolean immediateStopMaster = false; // no sleep between startMaster and stopMaster.
+ int tupsInserted = (bigInsert)?9876:10;
+ _testInsertUpdateDeleteOnMaster(masterServerHost, masterServerPort,
+ masterDb, tupsInserted);
+
+ /* In ReplicationRun_Local_3_p1
+ // 1 separate test
+ // slave: stopSlave
+
+ // 2 separate test
+ // master: stopSlave
+ // master: stopMaster
+ // slave: stopSlave
+ */
+
+ // 3 separate test
+ // stopMaster
+ // failover on slave
+ if ( ! immediateStopMaster) {
+ util.DEBUG("sleep(10000L)");
+ Thread.sleep(10000L); // Do we try stopMaster too "close" to startmaster/startSlave?
+ }
+ assertException(
+ _stopMaster(masterServerHost, masterServerPort,
+ masterDb),
+ null); // Implies failover. // OK to continue.
+ // Appears that failover is NOT done when bigInsert==false && immediateStopMaster== true:
+ // See below.
+
+ waitForConnect(100L, 200,
+ masterDb,
+ masterServerHost, masterServerPort);
+
+ String slaveDb = slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb;
+ if ( bigInsert==false && immediateStopMaster== true ) // UNEXPECTED BEHAVIOUR
+ { // ..._smallInsert_immediateStopMaster()
+ waitForSQLState("08004", 100L, 200, // Doing this to reach failover below also in this case! But will fail there!
+ slaveDb,
+ slaveServerHost, slaveServerPort);
+ }else
+ { // Correctly gets connection, i.e. failover has happened.
+ waitForConnect(100L, 200,
+ slaveDb,
+ slaveServerHost, slaveServerPort);
+
+ // Only if we can connect:
+ _verifyDatabase(slaveServerHost, slaveServerPort, slaveDb,
+ tupsInserted); // Will all tuples be transferred to slave here?
+ }
+
+ // 5 separate test
+ // slave: "normal" connect to slave db
+
+ // 6 separate test
+ // slave: 'internal-stopslave=true'
+
+ String expected = "XRE07"; // REPLICATION_NOT_IN_MASTER_MODE is correct when failover did happen above w/stopMaster.
+ if ( bigInsert==false && immediateStopMaster== true ) expected = null; // UNEXPECTED BEHAVIOUR: null or hang!
+ assertException(
+ _failOver(slaveServerHost, slaveServerPort,
+ slaveDb),
+ expected);
+
+ waitForConnect(100L, 200,
+ slaveDb,
+ slaveServerHost, slaveServerPort);
+
+ connectPing(slaveDb,
+ slaveServerHost,slaveServerPort,
+ testClientHost); //
+
+ // verifySlave();
+ _verifyDatabase(slaveServerHost, slaveServerPort, slaveDb,
+ tupsInserted);
+
+ // We should verify the master as well, at least to see that we still can connect.
+ // verifyMaster();
+ _verifyDatabase(masterServerHost, masterServerPort, masterDb,
+ tupsInserted);
+
+ stopServer(jvmVersion, derbyVersion,
+ slaveServerHost, slaveServerPort);
+
+ stopServer(jvmVersion, derbyVersion,
+ masterServerHost, masterServerPort);
+
+ }
+ public void testReplication_Local_3_p2_StateTests_bigInsert_immediateStopMaster()
+ throws Exception
+ {
+ replication_Local_3_p2_StateTests(true, true);
+ }
+ public void testReplication_Local_3_p2_StateTests_smallInsert_immediateStopMaster_DISABLED()
+ throws Exception
+ {
+ // FIXME! ENABLE when DERBY-3617 is RESOLVED - otherwise hangs....
+ // ... Now gets connection instead of XRE07!
+ // And then we experience hang again...
+ // replication_Local_3_p2_StateTests(false, true);
+ }
+ public void testReplication_Local_3_p2_StateTests_bigInsert_sleepBeforeStopMaster()
+ throws Exception
+ {
+ replication_Local_3_p2_StateTests(true, false);
+ }
+ public void testReplication_Local_3_p2_StateTests_smallInsert_sleepBeforeStopMaster()
+ throws Exception
+ {
+ replication_Local_3_p2_StateTests(false, false);
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p2.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java?rev=704197&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java Mon Oct 13 11:45:16 2008
@@ -0,0 +1,223 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_3_p3
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+ */
+package org.apache.derbyTesting.functionTests.tests.replicationTests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.SecurityManagerSetup;
+
+
+/**
+ * Run a replication test on localhost
+ * by using default values for master and slave hosts,
+ * and master and slave ports.
+ *
+ */
+
+public class ReplicationRun_Local_3_p3 extends ReplicationRun_Local_3
+{
+
+ /**
+ * Creates a new instance of ReplicationRun_Local
+ * @param testcaseName Identifying the test.
+ */
+ public ReplicationRun_Local_3_p3(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("ReplicationRun_Local_3_p3 Suite");
+
+ suite.addTestSuite( ReplicationRun_Local_3_p3.class );
+
+ return SecurityManagerSetup.noSecurityManager(suite);
+
+ }
+
+ //////////////////////////////////////////////////////////////
+ ////
+ //// The replication test framework (testReplication()):
+ //// a) "clean" replication run starting master and slave servers,
+ //// preparing master and slave databases,
+ //// starting and stopping replication and doing
+ //// failover for a "normal"/"failure free" replication
+ //// test run.
+ ////
+ //////////////////////////////////////////////////////////////
+
+ public void testReplication_Local_3_p3_StateNegativeTests()
+ throws Exception
+ {
+ cleanAllTestHosts();
+
+ initEnvironment();
+
+ initMaster(masterServerHost,
+ replicatedDb);
+
+ masterServer = startServer(masterJvmVersion, derbyMasterVersion,
+ masterServerHost,
+ ALL_INTERFACES, // masterServerHost, // "0.0.0.0", // All. or use masterServerHost for interfacesToListenOn,
+ masterServerPort,
+ masterDbSubPath); // Distinguishing master/slave
+
+ slaveServer = startServer(slaveJvmVersion, derbySlaveVersion,
+ slaveServerHost,
+ ALL_INTERFACES, // slaveServerHost, // "0.0.0.0", // All. or use slaveServerHost for interfacesToListenOn,
+ slaveServerPort,
+ slaveDbSubPath); // Distinguishing master/slave
+
+ startServerMonitor(slaveServerHost);
+
+ bootMasterDatabase(jvmVersion,
+ masterDatabasePath +FS+ masterDbSubPath,
+ replicatedDb,
+ masterServerHost, // Where the startreplication command must be given
+ masterServerPort, // master server interface accepting client requests
+ null // bootLoad, // The "test" to start when booting db.
+ );
+
+ /* In ReplicationRun_Local_3_p1
+ // 4 separate test
+ // master db created...
+ // slave: connect 'startSlave=true;create=true'
+ */
+
+ initSlave(slaveServerHost,
+ jvmVersion,
+ replicatedDb); // Trunk and Prototype V2: copy master db to db_slave.
+
+ startSlave(jvmVersion, replicatedDb,
+ slaveServerHost, // slaveClientInterface // where the slave db runs
+ slaveServerPort,
+ slaveServerHost, // for slaveReplInterface
+ slaveReplPort,
+ testClientHost);
+
+ startMaster(jvmVersion, replicatedDb,
+ masterServerHost, // Where the startMaster command must be given
+ masterServerPort, // master server interface accepting client requests
+ masterServerHost, // An interface on the master: masterClientInterface (==masterServerHost),
+ slaveServerPort, // Not used since slave don't allow clients.
+ slaveServerHost, // for slaveReplInterface
+ slaveReplPort);
+
+ runTest(null, // Returns immediatly if replicationTest is null.
+ jvmVersion,
+ testClientHost,
+ masterServerHost, masterServerPort,
+ replicatedDb);
+
+ /* In ReplicationRun_Local_3_p1
+ // 1 separate test
+ // slave: stopSlave
+
+ // 2 separate test
+ // master: stopSlave
+ // master: stopMaster
+ // slave: stopSlave
+ */
+
+ // 3 separate test
+ // stopMaster
+ // failover on slave
+ assertException(
+ _stopMaster(masterServerHost, masterServerPort,
+ masterDatabasePath + FS + masterDbSubPath + FS + replicatedDb),
+ null); // Implies failover. // OK to continue.
+ /* showCurrentState("Post stopMaster +1s", 1000L,
+ masterDatabasePath + FS + masterDbSubPath + FS + replicatedDb,
+ masterServerHost, masterServerPort); */
+ waitForConnect(100L, 10,
+ masterDatabasePath + FS + masterDbSubPath + FS + replicatedDb,
+ masterServerHost, masterServerPort);
+ /* showCurrentState("Post stopMaster +1s", 0L,
+ slaveDatabasePath + FS + slaveDbSubPath + FS + replicatedDb,
+ slaveServerHost, slaveServerPort);
+ showCurrentState("Post stopMaster +5s", 5000L,
+ slaveDatabasePath + FS + slaveDbSubPath + FS + replicatedDb,
+ slaveServerHost, slaveServerPort); */
+ waitForSQLState("08004", 100L, 20, // 08004.C.7 - CANNOT_CONNECT_TO_DB_IN_SLAVE_MODE
+ slaveDatabasePath + FS + slaveDbSubPath + FS + replicatedDb,
+ slaveServerHost, slaveServerPort);
+ /* Got it above... showCurrentState("Post stopMaster +30s", 30000L,
+ slaveDatabasePath + FS + slaveDbSubPath + FS + replicatedDb,
+ slaveServerHost, slaveServerPort); // 08004 */
+ /* Got it above... showCurrentState("Post stopMaster +60s", 30000L,
+ masterDatabasePath + FS + masterDbSubPath + FS + replicatedDb,
+ masterServerHost, masterServerPort); // CONNECTED */
+ assertException(
+ _failOver(masterServerHost, masterServerPort,
+ masterDatabasePath+FS+masterDbSubPath+FS+replicatedDb),
+ "XRE07");
+ /* _p2: assertException(
+ _failOver(slaveServerHost, slaveServerPort,
+ slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb),
+ "XRE07"); // Hangs!? even after killMaster server. */
+
+ // 5 separate test
+ // slave: "normal" connect to slave db
+
+ // 6 separate test
+ // slave: 'internal-stopslave=true'
+
+ /* failOver(jvmVersion,
+ masterDatabasePath, masterDbSubPath, replicatedDb,
+ masterServerHost, // Where the master db is run.
+ masterServerPort,
+ testClientHost); // XRE07 Could not perform operation because the database is not in replication master mode.
+ */
+
+ waitForSQLState("08004", 100L, 20, // 08004.C.7 - CANNOT_CONNECT_TO_DB_IN_SLAVE_MODE
+ slaveDatabasePath + FS + slaveDbSubPath + FS + replicatedDb,
+ slaveServerHost, slaveServerPort); // _failOver above fails...
+ /*
+ connectPing(slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb,
+ slaveServerHost,slaveServerPort,
+ testClientHost); //
+ */
+
+ // Not relevant as we can not connect. verifySlave();
+
+ // We should verify the master as well, at least to see that we still can connect.
+ verifyMaster();
+
+ stopServer(jvmVersion, derbyVersion,
+ slaveServerHost, slaveServerPort);
+
+ stopServer(jvmVersion, derbyVersion,
+ masterServerHost, masterServerPort);
+
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java?rev=704197&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java Mon Oct 13 11:45:16 2008
@@ -0,0 +1,216 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_3_p4
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+ */
+package org.apache.derbyTesting.functionTests.tests.replicationTests;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derby.jdbc.ClientDataSource;
+import org.apache.derbyTesting.junit.SecurityManagerSetup;
+
+
+/**
+ * Run a replication test on localhost
+ * by using default values for master and slave hosts,
+ * and master and slave ports.
+ *
+ */
+
+public class ReplicationRun_Local_3_p4 extends ReplicationRun
+{
+
+ /**
+ * Creates a new instance of ReplicationRun_Local
+ * @param testcaseName Identifying the test.
+ */
+ public ReplicationRun_Local_3_p4(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("ReplicationRun_Local_3_p4 Suite");
+
+ suite.addTestSuite( ReplicationRun_Local_3_p4.class );
+
+ return SecurityManagerSetup.noSecurityManager(suite);
+
+ }
+
+ //////////////////////////////////////////////////////////////
+ ////
+ //// The replication test framework (testReplication()):
+ //// a) "clean" replication run starting master and slave servers,
+ //// preparing master and slave databases,
+ //// starting and stopping replication and doing
+ //// failover for a "normal"/"failure free" replication
+ //// test run.
+ ////
+ //////////////////////////////////////////////////////////////
+
+ public void testReplication_Local_3_p4_StateNegativeTests()
+ throws Exception
+ {
+ cleanAllTestHosts();
+
+ initEnvironment();
+
+ initMaster(masterServerHost,
+ replicatedDb);
+
+ masterServer = startServer(masterJvmVersion, derbyMasterVersion,
+ masterServerHost,
+ ALL_INTERFACES, // masterServerHost, // "0.0.0.0", // All. or use masterServerHost for interfacesToListenOn,
+ masterServerPort,
+ masterDbSubPath); // Distinguishing master/slave
+
+ slaveServer = startServer(slaveJvmVersion, derbySlaveVersion,
+ slaveServerHost,
+ ALL_INTERFACES, // slaveServerHost, // "0.0.0.0", // All. or use slaveServerHost for interfacesToListenOn,
+ slaveServerPort,
+ slaveDbSubPath); // Distinguishing master/slave
+
+ startServerMonitor(slaveServerHost);
+
+ bootMasterDatabase(jvmVersion,
+ masterDatabasePath +FS+ masterDbSubPath,
+ replicatedDb,
+ masterServerHost, // Where the startreplication command must be given
+ masterServerPort, // master server interface accepting client requests
+ null // bootLoad, // The "test" to start when booting db.
+ );
+
+ initSlave(slaveServerHost,
+ jvmVersion,
+ replicatedDb); // Trunk and Prototype V2: copy master db to db_slave.
+
+ startSlave(jvmVersion, replicatedDb,
+ slaveServerHost, // slaveClientInterface // where the slave db runs
+ slaveServerPort,
+ slaveServerHost, // for slaveReplInterface
+ slaveReplPort,
+ testClientHost);
+
+ startMaster(jvmVersion, replicatedDb,
+ masterServerHost, // Where the startMaster command must be given
+ masterServerPort, // master server interface accepting client requests
+ masterServerHost, // An interface on the master: masterClientInterface (==masterServerHost),
+ slaveServerPort, // Not used since slave don't allow clients.
+ slaveServerHost, // for slaveReplInterface
+ slaveReplPort);
+
+
+ runTest(null, // Returns immediatly if replicationTest is null.
+ jvmVersion,
+ testClientHost,
+ masterServerHost, masterServerPort,
+ replicatedDb);
+
+
+ // 5 separate test
+ // slave: "normal" connect to slave db
+ assertException(
+ _connectToSlave(slaveServerHost, slaveServerPort,
+ slaveDatabasePath + FS + slaveDbSubPath + FS + replicatedDb),
+ "08004");
+
+ // 6 separate test
+ // slave: 'internal_stopslave=true'
+ assertException(
+ _internal_stopSlave(slaveServerHost, slaveServerPort,
+ slaveDatabasePath + FS + slaveDbSubPath + FS + replicatedDb),
+ "XRE43"); // REPLICATION_STOPSLAVE_NOT_INITIATED
+ // - Unexpected error when trying to stop replication slave mode. To stop repliation slave mode, use operation 'stopSlave' or 'failover'.
+
+ failOver(jvmVersion,
+ masterDatabasePath, masterDbSubPath, replicatedDb,
+ masterServerHost, // Where the master db is run.
+ masterServerPort,
+ testClientHost);
+
+ connectPing(slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb,
+ slaveServerHost,slaveServerPort,
+ testClientHost);
+
+ verifySlave();
+
+ // We should verify the master as well, at least to see that we still can connect.
+ verifyMaster();
+
+ stopServer(jvmVersion, derbyVersion,
+ slaveServerHost, slaveServerPort);
+
+ stopServer(jvmVersion, derbyVersion,
+ masterServerHost, masterServerPort);
+
+ }
+
+ private SQLException _connectToSlave(String slaveServerHost,
+ int slaveServerPort,
+ String dbPath) {
+ util.DEBUG("_connectToSlave");
+ ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
+ ds.setDatabaseName(dbPath);
+ ds.setServerName(slaveServerHost);
+ ds.setPortNumber(slaveServerPort);
+ try {
+ Connection conn = ds.getConnection(); //
+ conn.close();
+ return null; // If successfull -
+ } catch (SQLException se) {
+ util.DEBUG(se.getErrorCode()+" "+se.getSQLState()+" "+se.getMessage());
+ return se;
+ }
+ }
+
+ private SQLException _internal_stopSlave(String slaveServerHost,
+ int slaveServerPort,
+ String dbPath) {
+ util.DEBUG("_internal_stopSlave");
+ ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
+ ds.setDatabaseName(dbPath);
+ ds.setServerName(slaveServerHost);
+ ds.setPortNumber(slaveServerPort);
+ ds.setConnectionAttributes("internal_stopslave=true");
+ try {
+ Connection conn = ds.getConnection(); //
+ conn.close();
+ return null; // If successfull -
+ } catch (SQLException se) {
+ util.DEBUG(se.getErrorCode()+" "+se.getSQLState()+" "+se.getMessage());
+ return se;
+ }
+ }
+
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java?rev=704197&r1=704196&r2=704197&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java Mon Oct 13 11:45:16 2008
@@ -254,13 +254,16 @@
/* No value-adding suggestions here exept that calling startSlave
* should hang now.
*/
- util.DEBUG("_testPostStoppedSlaveServer Not yet implemented");
+ util.DEBUG("_testPostStoppedSlave Not yet implemented."
+ + " No value-adding suggestions here"
+ + " exept that calling startSlave should hang now.");
}
private void _testPostStoppedSlaveServer()
{
/* No value-adding suggestions here */
- util.DEBUG("_testPostStoppedSlave Not yet implemented");
+ util.DEBUG("_testPostStoppedSlaveServer Not yet implemented."
+ + " No value-adding suggestions here.");
}
private void _testPostStoppedMaster()
@@ -268,42 +271,16 @@
/* No value-adding suggestions here since the stopMaster method will
* not do anything when called after failover
*/
- util.DEBUG("_testPostStoppedMaster Not yet implemented");
+ util.DEBUG("_testPostStoppedMaster Not yet implemented."
+ + "No value-adding suggestions here since the stopMaster method"
+ + " will not do anything when called after failover");
}
private void _testPostStoppedServer()
{
/* No value-adding suggestions here */
- util.DEBUG("_testPostStoppedServer Not yet implemented");
- }
-
- //////////////////////////////////////////////////////////////////
- // FIXME! The following should be moved to ReplicationRun!
- // Use the pattern 'assertException(replCmd()),expectedException);'
- // also in the other replication tests!
- void assertException(SQLException se, String expectedSqlState)
- {
- if (se == null ) // Did not get an exception
- {
- util.DEBUG("Got 'null' exception, expected '" + expectedSqlState + "'");
- assertTrue("Expected exception " + expectedSqlState,
- expectedSqlState == null);
- return;
- }
- int ec = se.getErrorCode();
- String ss = se.getSQLState();
- String msg = "Got " + ec + " " + ss + " " + se.getMessage()
- + ". Expected " + expectedSqlState;
- util.DEBUG(msg);
-
- if ( expectedSqlState != null ) // We expect an exception
- {
- assertTrue(msg, ss.equals(expectedSqlState));
- }
- else // We do not expect an exception, but got one.
- {
- assertTrue(msg, false);
- }
+ util.DEBUG("_testPostStoppedServer Not yet implemented."
+ + " No value-adding suggestions here.");
}
SQLException startSlave(String slaveServerHost, int slaveServerPort,
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_showStateChange.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_showStateChange.java?rev=704197&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_showStateChange.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_showStateChange.java Mon Oct 13 11:45:16 2008
@@ -0,0 +1,167 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Local_showStateChange
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+ */
+package org.apache.derbyTesting.functionTests.tests.replicationTests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.SecurityManagerSetup;
+
+
+/**
+ * Run a replication test on localhost
+ * by using default values for master and slave hosts,
+ * and master and slave ports.
+ * This test is intended to be run separatly showing
+ * state change during a "normal" replication session.
+ */
+
+public class ReplicationRun_Local_showStateChange extends ReplicationRun
+{
+
+ /**
+ * Creates a new instance of ReplicationRun_Local
+ * @param testcaseName Identifying the test.
+ */
+ public ReplicationRun_Local_showStateChange(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("ReplicationRun_Local_showStateChange Suite");
+
+ suite.addTestSuite( ReplicationRun_Local_showStateChange.class );
+
+ return SecurityManagerSetup.noSecurityManager(suite);
+
+ }
+
+ public void testReplication_Local_showStateChange_showReplState()
+ throws Exception
+ {
+ util.DEBUG(""); // Just to get a nicer print of showCurrentState()...
+
+ cleanAllTestHosts();
+
+ initEnvironment();
+
+ initMaster(masterServerHost,
+ replicatedDb);
+
+ masterServer = startServer(masterJvmVersion, derbyMasterVersion,
+ masterServerHost, ALL_INTERFACES, masterServerPort,
+ masterDbSubPath);
+
+ slaveServer = startServer(slaveJvmVersion, derbySlaveVersion,
+ slaveServerHost, ALL_INTERFACES, slaveServerPort,
+ slaveDbSubPath);
+
+ final long L=0L;//1000L;
+ final long S=0L;
+ boolean outerPrintDebug = util.printDebug;
+ util.printDebug = true;
+ String masterDb = masterDatabasePath +FS+masterDbSubPath +FS+ replicatedDb;
+ String slaveDb = slaveDatabasePath +FS+slaveDbSubPath +FS+ replicatedDb;
+ showCurrentState("1 started servers",S, masterDb, masterServerHost, masterServerPort);
+ showCurrentState("1 started servers",S, slaveDb, slaveServerHost, slaveServerPort);
+
+ startServerMonitor(slaveServerHost);
+
+ bootMasterDatabase(jvmVersion,
+ masterDatabasePath +FS+ masterDbSubPath, replicatedDb,
+ masterServerHost, masterServerPort,
+ null // bootLoad, // The "test" to start when booting db.
+ );
+ showCurrentState("2 master booted",S, masterDb, masterServerHost, masterServerPort);
+ showCurrentState("2 master booted",S, slaveDb, slaveServerHost, slaveServerPort);
+
+ initSlave(slaveServerHost,
+ jvmVersion,
+ replicatedDb);
+ showCurrentState("3 slave filled",S, masterDb, masterServerHost, masterServerPort);
+ // Causes XRE09 'The database has already been booted' in startSlave - CORRECT?:
+ // showCurrentState("3 slave filled",S, slaveDb, slaveServerHost, slaveServerPort);
+
+ startSlave(jvmVersion, replicatedDb,
+ slaveServerHost, slaveServerPort,
+ slaveServerHost,
+ slaveReplPort,
+ testClientHost);
+ showCurrentState("4 slave started",S, masterDb, masterServerHost, masterServerPort);
+ // HANGS! on ClientDataSource.getConnection:
+ // showCurrentState("4 slave started",S, slaveDb, slaveServerHost, slaveServerPort);
+
+ startMaster(jvmVersion, replicatedDb,
+ masterServerHost, masterServerPort,
+ masterServerHost,
+ slaveServerPort, slaveServerHost,
+ slaveReplPort);
+ showCurrentState("5 master started",S, masterDb, masterServerHost, masterServerPort);
+ showCurrentState("5 master started",S, slaveDb, slaveServerHost, slaveServerPort);
+
+ // Replication "load"
+ util.DEBUG("Running replication load.");
+ int tuplesToInsert = 10000;
+ _testInsertUpdateDeleteOnMaster(masterServerHost, masterServerPort,
+ masterDb, tuplesToInsert);
+
+ failOver(jvmVersion,
+ masterDatabasePath, masterDbSubPath, replicatedDb,
+ masterServerHost, masterServerPort,
+ testClientHost);
+ waitForSQLState("08004",
+ 10L, 100,
+ slaveDb, slaveServerHost, slaveServerPort);
+ showCurrentState("6 failover initiated",S, masterDb, masterServerHost, masterServerPort);
+ showCurrentState("6 failover initiated",S, slaveDb, slaveServerHost, slaveServerPort);
+ waitForConnect(100L, 200,
+ slaveDb, slaveServerHost, slaveServerPort);
+ showCurrentState("6 failover initiated + wait..",S, masterDb, masterServerHost, masterServerPort);
+ showCurrentState("6 failover initiated + wait..",S, slaveDb, slaveServerHost, slaveServerPort);
+
+ connectPing(slaveDb,
+ slaveServerHost,slaveServerPort,
+ testClientHost);
+
+ showCurrentState("7 failover completed",S, masterDb, masterServerHost, masterServerPort);
+ showCurrentState("7 failover completed",S, slaveDb, slaveServerHost, slaveServerPort);
+ util.printDebug = outerPrintDebug;
+ // verifySlave();
+ _verifyDatabase(slaveServerHost, slaveServerPort,
+ slaveDb, tuplesToInsert);
+ // We should verify the master as well, at least to see that we still can connect.
+ // verifyMaster();
+ _verifyDatabase(masterServerHost, masterServerPort,
+ masterDb, tuplesToInsert);
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_showStateChange.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java?rev=704197&r1=704196&r2=704197&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java Mon Oct 13 11:45:16 2008
@@ -57,6 +57,14 @@
suite.addTest(ReplicationRun_Local_StateTest_part2.suite());
+ // Run this separatly as it produces extra output:
+ // suite.addTest(ReplicationRun_Local_showStateChange.suite());
+
+ suite.addTest(ReplicationRun_Local_3_p1.suite());
+ suite.addTest(ReplicationRun_Local_3_p2.suite());
+ suite.addTest(ReplicationRun_Local_3_p3.suite());
+ suite.addTest(ReplicationRun_Local_3_p4.suite());
+
return suite;
}
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/Utils.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/Utils.java?rev=704197&r1=704196&r2=704197&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/Utils.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/Utils.java Mon Oct 13 11:45:16 2008
@@ -96,20 +96,22 @@
{
// DEBUG("delete file " + f.getAbsolutePath());
boolean deleted = f.delete();
- // DEBUG("file deleted " + deleted);
+ if (!deleted) DEBUG("file NOT deleted " + f.getAbsolutePath());
}
}
if (rmdir)
{
DEBUG("deleting directory " + dir.getAbsolutePath());
- dir.delete();
+ boolean deleted = dir.delete();
+ if (!deleted) DEBUG("dir NOT deleted " + dir.getAbsolutePath());
}
}
else
{
DEBUG("deleting file " +dir.getAbsolutePath());
- dir.delete();
+ boolean deleted = dir.delete();
+ if (!deleted) DEBUG("file NOT deleted " + dir.getAbsolutePath());
}
}