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 oy...@apache.org on 2008/02/29 17:10:27 UTC
svn commit: r632371 [1/5] - in /db/derby/code/trunk/java/testing: ./
org/apache/derbyTesting/functionTests/tests/replicationTests/
Author: oysteing
Date: Fri Feb 29 08:10:21 2008
New Revision: 632371
URL: http://svn.apache.org/viewvc?rev=632371&view=rev
Log:
DERBY-3162: Create a framework for replication tests
Contributed by Ole Solberg
Added:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ClientRunner.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/DestroySlaveDB.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/KillMaster.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/KillSlave.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.framework
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.runningTests
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.testReplication
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.testproperties
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Distributed.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationTestRun.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationTestRun_Verify.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMaster.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterDb.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServer.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServerByOsKill.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServerViaNwSrvCtrl.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlave.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveDb.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServer.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServerByOsKill.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServerViaNwSrvCtrl.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/StandardTests.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/TestPostStartedMasterAndSlave_Failover.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/TestPostStartedMasterAndSlave_StopMaster.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/TestPostStartedMasterAndSlave_StopSlave.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/TestPostStoppedSlaveServer.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/TestPreInitSlave.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/TestPreStartedMaster.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/TestPreStartedMasterServer.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/TestPreStartedSlave.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/TestPreStartedSlaveServer.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/TestPreStoppedMaster.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/TestPreStoppedMasterServer.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/TestPreStoppedSlave.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/TestPreStoppedSlaveServer.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/Utils.java (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/build.xml (with props)
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/replicationtest.properties (with props)
Modified:
db/derby/code/trunk/java/testing/build.xml
Modified: db/derby/code/trunk/java/testing/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/build.xml?rev=632371&r1=632370&r2=632371&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/build.xml (original)
+++ db/derby/code/trunk/java/testing/build.xml Fri Feb 29 08:10:21 2008
@@ -79,6 +79,7 @@
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/management"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/memory"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/upgradeTests"/>
+ <ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/replicationTests"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/largedata"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/multi/stress"/>
<ant dir="${derby.testing.src.dir}/${derby.testing.functest.dir}/master"/>
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ClientRunner.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ClientRunner.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ClientRunner.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ClientRunner.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,86 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ClientRunner
+
+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.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+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.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+public class ClientRunner extends BaseJDBCTestCase // FIXME! Use ClientRunner in e.g. Shutdown.... etc.
+{
+ private static ReplicationRun repRun = new ReplicationRun("ClientRunner");
+
+ public ClientRunner(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ /* */
+ // Client reads from the same property file as the 'ReplicationRun' test
+ // which controls the complete replication test!
+ static String replicatedDb = null;
+ static String jvmVersion = null;
+ static String slaveJvmVersion = null;
+ static String derbyVersion = null;
+ static String derbySlaveVersion = null;
+ static String masterServerHost = null;
+ static int masterServerPort = -1;
+ static String slaveServerHost = null;
+ static int slaveServerPort = -1;
+ static int slaveReplPort = -1;
+ static String masterDatabasePath = null;
+ static String slaveDatabasePath = null;
+ static String testClientHost = null;
+ /* */
+
+ public static void initEnvironment()
+ throws Exception
+ {
+ System.out.println("**** ClientRunner.init()");
+ System.out.println("'ClientRunner' can not be run outside the 'ReplicationRun' framework.");
+
+ repRun.initEnvironment();
+ testClientHost= repRun.testClientHost;
+ derbyVersion = repRun.derbyVersion;
+ jvmVersion = repRun.jvmVersion;
+ replicatedDb = repRun.replicatedDb;
+ masterServerHost = repRun.masterServerHost;
+ masterServerPort = repRun.masterServerPort;
+ masterDatabasePath = repRun.masterDatabasePath;
+ slaveServerHost = repRun.slaveServerHost;
+ slaveServerPort = repRun.slaveServerPort;
+ slaveReplPort = repRun.slaveReplPort;
+ slaveDatabasePath = repRun.slaveDatabasePath;
+ slaveJvmVersion = repRun.slaveJvmVersion;
+ derbySlaveVersion = repRun.derbySlaveVersion;
+
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ClientRunner.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/DestroySlaveDB.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/DestroySlaveDB.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/DestroySlaveDB.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/DestroySlaveDB.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,109 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.DestroySlaveDB
+
+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.io.IOException;
+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.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+public class DestroySlaveDB extends BaseJDBCTestCase
+{
+ private static String slaveServerHost = null;
+ private static ReplicationRun repRun = new ReplicationRun("DestroySlaveDB");
+
+ public DestroySlaveDB(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("**** DestroySlaveDB.suite()");
+ System.out.println("'DestroySlaveDB' can not be run outside the 'ReplicationRun' framework.");
+
+ TestSuite suite = new TestSuite("DestroySlaveDB");
+
+ String masterHostName = System.getProperty("test.serverHost", "localhost");
+ int masterPortNo = Integer.parseInt(System.getProperty("test.serverPort", "1527"));
+
+ repRun.initEnvironment();
+ slaveServerHost = ReplicationRun.slaveServerHost;
+
+ suite.addTest(DestroySlaveDB.suite(masterHostName,masterPortNo));
+ return (Test)suite;
+ }
+ /**
+ * Adds this class to the *existing server* suite.
+ */
+ public static Test suite(String serverHost, int serverPort)
+ {
+ System.out.println("*** DestroySlaveDB.suite("+serverHost+","+serverPort+")");
+
+ Test t = TestConfiguration.existingServerSuite(DestroySlaveDB.class,false,serverHost,serverPort);
+ System.out.println("*** Done TestConfiguration.existingServerSuite(DestroySlaveDB.class,false,"
+ +serverHost+","+serverPort+")");
+ return t;
+ }
+
+ /**
+ * Test killing slave during replication.
+ *
+ * @throws SQLException, IOException, InterruptedException
+ */
+ public void testDestroySlaveDB()
+ throws SQLException, IOException, InterruptedException
+ {
+ System.out.println("**** DestroySlaveDB.testDestroySlaveDB() "+
+ getTestConfiguration().getJDBCClient().getJDBCDriverName());
+
+ Connection conn = getConnection();
+ Statement s = conn.createStatement();
+ s.executeUpdate("create table t (i integer primary key, vc varchar(20))");
+
+ PreparedStatement pSt = prepareStatement("insert into t values (?,?)");
+
+ for (int i=0;i<1000;i++)
+ {
+ pSt.setInt(1, i);
+ pSt.setString(2, "i"+i);
+ pSt.execute();
+ System.out.println("i: "+i);
+ if ( i == 500 )
+ {
+ repRun.destroySlaveDB(slaveServerHost);
+ }
+ }
+ ResultSet rs = s.executeQuery("select count(*) from t");
+ rs.next();
+ int count = rs.getInt(1);
+ System.out.println("count: "+count);
+ // s.executeUpdate("drop table t");
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/DestroySlaveDB.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/KillMaster.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/KillMaster.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/KillMaster.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/KillMaster.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,148 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.KillMaster
+
+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.io.File;
+import java.io.IOException;
+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.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+public class KillMaster extends BaseJDBCTestCase
+{
+
+ public KillMaster(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ /* */
+ private static String masterJvmVersion = null;
+ private static String derbyMasterVersion = null;
+ private static String masterServerHost = null;
+ private static int masterServerPort = -1;
+ private static ReplicationRun repRun = new ReplicationRun("KillMaster");
+ /* */
+
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("**** KillMaster.suite()");
+ System.out.println("'KillMaster' can not be run outside the 'ReplicationRun' framework.");
+ TestSuite suite = new TestSuite("KillMaster");
+
+ String masterHostName = System.getProperty("test.serverHost", "localhost");
+ int masterPortNo = Integer.parseInt(System.getProperty("test.serverPort", "1527"));
+
+ masterServerHost = masterHostName;
+ masterServerPort = masterPortNo;
+
+ repRun.initEnvironment();
+ masterJvmVersion = ReplicationRun.masterJvmVersion;
+ derbyMasterVersion = ReplicationRun.derbyMasterVersion;
+
+ suite.addTest(KillMaster.suite(masterHostName,masterPortNo));
+ return (Test)suite;
+ }
+ /**
+ * Adds this class to the *existing server* suite.
+ */
+ public static Test suite(String serverHost, int serverPort)
+ throws IOException
+ {
+ System.out.println("*** KillMaster.replSuite(serverHost,serverPort)");
+
+ Test t = TestConfiguration.existingServerSuite(KillMaster.class,false,serverHost,serverPort);
+ System.out.println("*** Done TestConfiguration.defaultExistingServerSuite(KillMaster.class,false,serverHost,serverPort)");
+ return t;
+ }
+
+ /**
+ * Test killing master during replication.
+ *
+ * @throws Exception
+ */
+ public void testKillMaster()
+ throws Exception
+ {
+ System.out.println("**** KillMaster.testKillMaster() "+
+ getTestConfiguration().getJDBCClient().getJDBCDriverName());
+
+ Connection conn = getConnection();
+ Statement s = conn.createStatement();
+ s.executeUpdate("create table t (i integer primary key, vc varchar(20))");
+
+ PreparedStatement pSt = prepareStatement("insert into t values (?,?)");
+ int i=0;
+ try{
+ for (;i<1000;i++)
+ {
+ pSt.setInt(1, i);
+ pSt.setString(2, "i"+i);
+ pSt.execute();
+ System.out.println("i: "+i);
+ if ( i == 500 )
+ {
+ /*
+ ReplicationRun.stopServer(masterJvmVersion, derbyMasterVersion,
+ masterServerHost, masterServerPort);
+ */
+ repRun.killMaster(masterServerHost, masterServerPort);
+ }
+ }
+ }catch (SQLException se) {
+ System.out.println("SQLException @ i="+i+" ("+se.getMessage()+")");
+ if ( i <=500)
+ {
+ fail("**** Unexpected SQLException @ i="+i+" ("+se.getMessage()+")");
+ }
+ }
+ /* Master not available any more. VerificationClient should check both Master and Slave db!
+ */
+ conn.close();
+
+ Thread.sleep(5000L); // Better sleep a little until master is totally gone?
+ repRun.startServer(masterJvmVersion, derbyMasterVersion,
+ masterServerHost,
+ ReplicationRun.ALL_INTERFACES, // masterServerHost, // "0.0.0.0", // All. or use masterServerHost for interfacesToListenOn,
+ masterServerPort,
+ ReplicationRun.masterDatabasePath +File.separator+ ReplicationRun.masterDbSubPath); // Distinguishing master/slave
+ // Will only work if default/initial values are used!
+ // MUST BE FULL PATH!!!
+
+ /* */
+ conn = getConnection();
+ s = conn.createStatement();
+ ResultSet rs = s.executeQuery("select count(*) from t");
+ rs.next();
+ int count = rs.getInt(1);
+ System.out.println("count: "+count);
+ // s.executeUpdate("drop table t");
+ /* */
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/KillMaster.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/KillSlave.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/KillSlave.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/KillSlave.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/KillSlave.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,114 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.KillSlave
+
+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.io.IOException;
+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.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+public class KillSlave extends BaseJDBCTestCase
+{
+ private static ReplicationRun repRun = new ReplicationRun("KillSlave");
+
+ public KillSlave(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ private static String slaveServerHost = null;
+ private static int slaveServerPort = -1;
+
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("**** KillSlave.suite()");
+ System.out.println("'KillSlave' can not be run outside the 'ReplicationRun' framework.");
+
+ TestSuite suite = new TestSuite("KillSlave");
+
+ String masterHostName = System.getProperty("test.serverHost", "localhost");
+ int masterPortNo = Integer.parseInt(System.getProperty("test.serverPort", "1527"));
+
+ repRun.initEnvironment();
+ slaveServerHost = ReplicationRun.slaveServerHost;
+ slaveServerPort = ReplicationRun.slaveServerPort;
+
+ suite.addTest(KillSlave.suite(masterHostName,masterPortNo));
+ return (Test)suite;
+ }
+ /**
+ * Adds this class to the *existing server* suite.
+ */
+ public static Test suite(String serverHost, int serverPort)
+ {
+ System.out.println("*** KillSlave.suite(serverHost,serverPort)");
+ Test t = TestConfiguration.existingServerSuite(KillSlave.class,false,serverHost,serverPort);
+ System.out.println("*** Done TestConfiguration.defaultExistingServerSuite(KillSlave.class,false,serverHost,serverPort)");
+ return t;
+ }
+
+ /**
+ * Test killing slave during replication.
+ *
+ * @throws SQLException, IOException, InterruptedException
+ */
+ public void testKillSlave()
+ throws SQLException, IOException, InterruptedException
+ {
+ System.out.println("**** KillSlave.testKillSlave() "+
+ getTestConfiguration().getJDBCClient().getJDBCDriverName());
+
+ Connection conn = getConnection();
+ Statement s = conn.createStatement();
+ s.executeUpdate("create table t (i integer primary key, vc varchar(20))");
+
+ PreparedStatement pSt = prepareStatement("insert into t values (?,?)");
+
+ for (int i=0;i<1000;i++)
+ {
+ pSt.setInt(1, i);
+ pSt.setString(2, "i"+i);
+ pSt.execute();
+ System.out.println("i: "+i);
+ if ( i == 500 )
+ {
+ /* The current PoC does not allow other connections, so this just hangs.
+ ReplicationRun.stopServer(slaveJvmVersion, derbySlaveVersion,
+ slaveServerHost, slaveServerPort);
+ */
+ repRun.killSlave(slaveServerHost, slaveServerPort);
+ }
+ }
+ ResultSet rs = s.executeQuery("select count(*) from t");
+ rs.next();
+ int count = rs.getInt(1);
+ System.out.println("count: "+count);
+ // s.executeUpdate("drop table t");
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/KillSlave.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.framework
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.framework?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.framework (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.framework Fri Feb 29 08:10:21 2008
@@ -0,0 +1,45 @@
+The current replication tests are run against the Proof of Concept (PoC) code for
+replication.
+
+The intention is that when the replication code is enabled on trunk, the
+replication test framework and tests are in place.
+
+
+The test framework for replication testing is so far only available for running
+on Unix'es, specifically Linux and Solaris.
+Cygwin on Windows should also work but this has not yet been tried.
+
+The test frame work relies on Secure Shell (ssh) to start servers on the master and slave hosts,
+and to run test clients and load clients on a set of client and load hosts.
+
+The PoC code has special variants of the Derby code for the master and slave servers.
+This must be specified in the '${user.dir}/replicationtest.properties' file
+which will contain property definitions similar to what is shown below:
+
+#######################
+# Derby version to be used for client and as default for master and slave:
+#-----------------------------
+derby.version=/home/os136789/Apache/myDerbySandbox/trunk/jars/insane
+
+# Optional specific Derby to be used for master. REQUIRED for PoC code!
+derby.masterversion=/home/os136789/Replication/trunk_master/jars/insane
+
+# Optional specific Derby to be used for slave. REQUIRED for PoC code!
+derby.slaveversion=/home/os136789/Replication/trunk_slave/jars/insane
+#-----------------------------
+#######################
+
+See README.properties for a description of the '${user.dir}/replicationtest.properties' file
+
+See java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/replicationtest.properties
+for a complete replicationtest.properties file example.
+
+
+See DERBY-2872 / proof-of-concept_v2b-howto.txt for a description of how to create and build
+the PoC code.
+
+
+See README.runningTests for how to run replication tests.
+
+
+See README.testReplication for a description of ReplicationRun.testReplication.
\ No newline at end of file
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.runningTests
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.runningTests?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.runningTests (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.runningTests Fri Feb 29 08:10:21 2008
@@ -0,0 +1,25 @@
+Running replication tests
+*************************
+
+cd <testing dir>/ # ${user.dir}
+
+java -Djava.security.policy="<NONE>" \
+ junit.textui.TestRunner \
+ org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun
+
+which runs (*the only test* - the "test framework") ReplicationRun.testReplication.
+See README.testReplication for a description.
+
+
+ReplicationRun.testReplication relies on '${user.dir}/replicationtest.properties'
+to find
+- master and slave jar files (special Derby code variants in the Proof of Concept code)
+- test and test verification code to be run (the actual test...)
+- master and slave server hostnames and portnumbers
+- test client host names
+- load client hostnames
+- ..
+- .
+See README.properties for a description of properties used by
+org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun
+and tests.
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.testReplication
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.testReplication?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.testReplication (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.testReplication Fri Feb 29 08:10:21 2008
@@ -0,0 +1,137 @@
+ReplicationRun.testReplication
+******************************
+
+The test method testReplication in org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun
+executes the replication tests:
+
+
+Short story:
+------------
+
+startServer
+ - start server on master host.
+
+startServer
+ - start server on slave host.
+
+startReplication
+ - tells master server that the/a database is to be replicated on
+ the slave server.
+
+startSlave
+ - tells slave server to act as slave for the database on master
+ server which is to be replicated.
+
+runTest
+ - runs the specified test while replication is active.
+
+stopReplication
+ - tells the master server to stop replicating the database
+ - "NOOP" in PoC (Proof of concept) code.
+
+stopServer
+ - In the PoC code shutdown of or killing the master server
+ forces failover on the slave.
+
+
+
+Detailed story:
+--------------
+
+initEnvironment()
+ - gets test specifications from the ${user.dir}/replicationtest.properties file.
+
+initMaster(masterServerHost,replicatedDb)
+ - The PoC code (Proof of concept) requires that the master database is copied by OS commands
+ from some original database (possibly empty) to the master database (in
+ <test.master.databasepath>/db_master/). Also see README.properties.
+
+startServer(masterJvmVersion, derbyMasterVersion,
+ masterServerHost,
+ ALL_INTERFACES,
+ masterServerPort,
+ masterDatabasePath +PS+ masterDbSubPath)
+ - start the master server
+
+startLoad(masterPreRepl,
+ masterDbSubPath,
+ masterServerHost,
+ masterServerPort)
+
+ - Optionally start load on the master server.
+
+startServer(slaveJvmVersion, derbySlaveVersion,
+ slaveServerHost,
+ ALL_INTERFACES,
+ slaveServerPort,
+ slaveDatabasePath +PS+ slaveDbSubPath)
+ - start the slave server
+
+startReplication(jvmVersion, replicatedDb,
+ masterServerHost, // Where the startreplication command must be given
+ masterServerPort, // master server interface accepting client requests
+ masterServerHost, // An interface on the master: masterClientInterface (==masterServerHost),
+ slaveServerPort,
+ slaveServerHost,
+ slaveReplPort)
+ - tell master server to start replication 'replicatedDb' on 'slaveServerHost'.
+
+startLoad(masterPostRepl,
+ masterDbSubPath,
+ masterServerHost,
+ masterServerPort)
+ - Optionally start load on master server.
+
+startLoad(slavePreSlave,
+ slaveDbSubPath,
+ slaveServerHost,
+ slaveServerPort)
+ - Optionally start load on slave server.
+
+startSlave(jvmVersion, replicatedDb,
+ masterServerHost, // masterClientInterface (==masterServerHost)
+ masterServerPort, // masterServerPort
+ slaveServerHost, // slaveClientInterface // where the startslave command must be given
+ slaveServerPort,
+ slaveServerHost, // for slaveReplInterface
+ slaveReplPort)
+ - Tell slave server to take replication slave role for database 'replicatedDb' on (master)
+ server 'masterServerHost' with port 'masterServerPort'.
+
+startLoad(masterPostSlave,
+ masterDbSubPath,
+ masterServerHost,
+ masterServerPort)
+ - Optionally start load on master server.
+
+startLoad(slavePostSlave,
+ slaveDbSubPath,
+ slaveServerHost,
+ slaveServerPort)
+ - Optionally start load on slave server.
+
+runTest(replicationTest,
+ jvmVersion,
+ testClientHost,
+ masterServerHost, masterServerPort,
+ replicatedDb)
+ - Run the 'replicationTest' against the 'replicatedDb' on the master server.
+
+stopReplication(replicatedDb)
+ - Tell master server to stop replication of 'replicatedDb'. A "NOOP" on PoC:
+
+stopServer(masterJvmVersion, derbyMasterVersion, // V2b: forces failover on slave
+ masterServerHost, masterServerPort)
+ - In the PoC shutdown of or killing the master server forces failover on
+ the slave server, i.e. "simulating" a "failover" command on the slave!
+
+verifySlave()
+ - run the sql script or JUnit "test" to verify correct state in the replicated database on the slave server.
+
+
+Full story:
+-----------
+See org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun.
+
+
+
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.testproperties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.testproperties?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.testproperties (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/README.testproperties Fri Feb 29 08:10:21 2008
@@ -0,0 +1,103 @@
+${user.dir}/replicationtest.properties
+**************************************
+
+The test framework for replication testing relies on the file
+'replicationtest.properties' which must be located in 'user.dir'.
+
+The replication test framework assumes tests are run from jar files.
+
+The replication test framework allows different jars to be specified for
+the master server, the slave server and the server used when verifying
+database consistency of the slave database after completing the
+replication itself.
+
+
+The following properties are used by the replication test framework:
+
+
+Derby server hosts and port numbers:
+------------------------------------
+test.masterServerHost - where to run the master server
+test.masterServerPort
+
+test.slaveServerHost - where to run the slave server
+test.slaveServerPort
+
+test.slaveReplPort - which port to use on slave server for receiving replication data from master.
+
+test.testClientHost - host where the replication test is to be run.
+
+
+Derby master and slave database locations:
+-----------------------------------------
+test.master.databasepath - absolute path specifying where on master server the test database should reside.
+test.slave.databasepath - ditto for slave
+test.databaseName - name of database to be replicated.
+ - the full database path name on the master / slave will be
+ <test.master.databasepath>/db_master/<test.databaseName> /
+ <test.slave.databasepath>/db_slave/<test.databaseName>
+
+
+Replication tests and associated verification:
+----------------------------------------------
+test.replicationTest - either
+ a sql script - e.g. /home/os136789/Replication/testing/insert.sql or
+ a JUnit test - e.g. org.apache.derbyTesting.functionTests.tests.replicationTests.SimplePerfTest
+test.replicationVerify - the verification "test" to be run against the slave server after the
+ test.replicationTest is completed.
+
+test.derbyTestingJar - jar files of Derby version where tests are available
+jvm.version - jvm version used by test client(s)
+
+jvm.masterversion - jvm version used by master server
+jvm.slaveversion - ditto for slave
+
+derby.version - Derby version used.
+ Observe that while using the PoC (Proof of concept) code we have
+ specific variants of the Derby code for master and slave respectivly - both
+ being modifications to the "plain" Derby code.
+ Thus while using the PoC derby.version represents the Derby used by the test client(s),
+ and load clients.
+
+derby.masterversion - Specific variant of Derby for master PoC.
+derby.slaveversion - ditto for slave
+
+junit_jar - JUnit jars to use in tests and loads.
+
+test.sleepTime
+
+test.runUnReplicated - set to true to include a test run without replication:
+ Used for simple (performance) comparisons.
+
+
+Load specific properties:
+------------------------
+test.sqlLoadInit - sql script to initialize load client database.
+ NB! FIXME! must be specific per load id below!
+
+Properties that specifies if load clients are to be started at predefined states
+during the replication process:
+test.masterPreRepl - start a load client against the master server before 'startreplication'.
+test.masterPostRepl - start a load client against the master server when 'startreplication' is done.
+test.slavePreSlave - start a load client against the slave server when 'startreplication' is done,
+ but before 'startslave' is done.
+test.masterPostSlave - start a load client against the master server after 'startslave' is done.
+test.slavePostSlave - start a load client against the slave server after 'startslave' is done.
+(I.e. test.<load id>)
+
+For each of these load "id"s we have properties specifying
+"test." + id + ".load" - the sql script or JUnit test to use for load.
+"test." + id + ".database" - database name in <test.master.databasepath>/db_master/ or
+ <test.slave.databasepath>/db_slave/
+"test." + id + ".existingDB" - whether the database exists or should be created before running the load.
+"test." + id + ".clientHost" - the host to run the load client.
+
+General:
+--------
+test.testUser
+test.printDebug
+test.showSysinfo
+
+-------------------------------
+See java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/replicationtest.properties
+for an example.