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 [3/5] - in /db/derby/code/trunk/java/testing: ./
org/apache/derbyTesting/functionTests/tests/replicationTests/
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Distributed.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Distributed.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,323 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun
+
+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.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+
+/**
+ * Run a replication test in a distributed
+ * environment, where master and slave hosts, and
+ * master and slave ports are specified in a property file.
+ * Which test to run is also specified in the property file.
+ *
+ */
+
+public class ReplicationRun_Distributed extends ReplicationRun
+{
+
+ /**
+ * Creates a new instance of ReplicationRun_Distributed
+ * @param testcaseName Identifying the test.
+ */
+ public ReplicationRun_Distributed(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_Distributed Suite");
+
+ suite.addTestSuite( ReplicationRun_Distributed.class );
+
+ return 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()
+ 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,
+ masterDatabasePath +FS+ masterDbSubPath); // Distinguishing master/slave
+
+ slaveServer = startServer(slaveJvmVersion, derbySlaveVersion,
+ slaveServerHost,
+ ALL_INTERFACES, // slaveServerHost, // "0.0.0.0", // All. or use slaveServerHost for interfacesToListenOn,
+ slaveServerPort,
+ slaveDatabasePath +FS+ 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);
+
+
+ // Used to run positive tests.
+ // Handle negative testing in State.testPostStartedMasterAndSlave().
+ // Observe that it will not be meaningful to do runTest if State.XXXX()
+ // has led to incorrect replication state wrt. replicationTest.
+ runTest(replicationTest, // Returns immediatly if replicationTest is null.
+ jvmVersion,
+ testClientHost,
+ masterServerHost, masterServerPort,
+ replicatedDb);
+
+ 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);
+ // As of 2008-02-06 master does not accept shutdown after replication, so:
+ // do a 'kill pid' after ending the test run
+
+ }
+
+ /**
+ * When running in a distributed context,
+ * the environment is defined via the REPLICATIONTEST_PROPFILE.
+ */
+ void initEnvironment()
+ throws IOException
+ {
+
+ System.out.println("*** Properties -----------------------------------------");
+ userDir = System.getProperty("user.dir");
+ System.out.println("user.dir: " + userDir);
+
+ System.out.println("derby.system.home: " + System.getProperty("derby.system.home"));
+
+ String realPropertyFile = REPLICATIONTEST_PROPFILE; // Is just the plain file name in ${user.dir}
+ System.out.println("realPropertyFile: " + realPropertyFile);
+
+ InputStream isCp = new FileInputStream(userDir + FS + realPropertyFile);
+ Properties cp = new Properties();
+ // testRunProperties = cp; // Make available for e.g. new Load(loadId)
+ cp.load(isCp);
+ // testRunProperties = cp; // Make available for e.g. new Load(loadId)
+ // Now we can get the derby jar path, jvm path etc.
+
+ util.printDebug = cp.getProperty("test.printDebug","false").equalsIgnoreCase("true");
+ System.out.println("printDebug: " + util.printDebug);
+
+ showSysinfo = cp.getProperty("test.showSysinfo","false").equalsIgnoreCase("true");
+ System.out.println("showSysinfo: " + showSysinfo);
+
+ testUser = cp.getProperty("test.testUser","false");
+ System.out.println("testUser: " + testUser);
+
+ masterServerHost = cp.getProperty("test.masterServerHost",masterServerHost);
+ System.out.println("masterServerHost: " + masterServerHost);
+
+ masterServerPort = Integer.parseInt(cp.getProperty("test.masterServerPort",""+masterServerPort));
+ System.out.println("masterServerPort: " + masterServerPort);
+
+ slaveServerHost = cp.getProperty("test.slaveServerHost",slaveServerHost);
+ System.out.println("slaveServerHost: " + slaveServerHost);
+
+ slaveServerPort = Integer.parseInt(cp.getProperty("test.slaveServerPort",""+slaveServerPort));
+ System.out.println("slaveServerPort: " + slaveServerPort);
+
+ slaveReplPort = Integer.parseInt(cp.getProperty("test.slaveReplPort",""+slaveReplPort));
+ System.out.println("slaveReplPort: " + slaveReplPort);
+
+ testClientHost = cp.getProperty("test.testClientHost",testClientHost);
+ System.out.println("testClientHost: " + testClientHost);
+
+ masterDatabasePath = cp.getProperty("test.master.databasepath");
+ System.out.println("masterDatabasePath: " + masterDatabasePath);
+
+ slaveDatabasePath = cp.getProperty("test.slave.databasepath");
+ System.out.println("slaveDatabasePath: " + slaveDatabasePath);
+
+ replicatedDb = cp.getProperty("test.databaseName","test");
+ System.out.println("replicatedDb: " + replicatedDb);
+
+ bootLoad = cp.getProperty("test.bootLoad");
+ System.out.println("bootLoad: " + bootLoad);
+
+ freezeDB = cp.getProperty("test.freezeDB");
+ System.out.println("freezeDB: " + freezeDB);
+
+ unFreezeDB = cp.getProperty("test.unFreezeDB");
+ System.out.println("unFreezeDB: " + unFreezeDB);
+
+ replicationTest = cp.getProperty("test.replicationTest");
+ System.out.println("replicationTest: " + replicationTest);
+ replicationVerify = cp.getProperty("test.replicationVerify");
+ System.out.println("replicationVerify: " + replicationVerify);
+
+ sqlLoadInit = cp.getProperty("test.sqlLoadInit");
+ System.out.println("sqlLoadInit: " + sqlLoadInit);
+
+
+ specialTestingJar = cp.getProperty("test.derbyTestingJar", null);
+ System.out.println("specialTestingJar: " + specialTestingJar);
+
+ jvmVersion = cp.getProperty("jvm.version");
+ System.out.println("jvmVersion: " + jvmVersion);
+
+ masterJvmVersion = cp.getProperty("jvm.masterversion");
+ if ( masterJvmVersion == null )
+ {masterJvmVersion = jvmVersion;}
+ System.out.println("masterJvmVersion: " + masterJvmVersion);
+
+ slaveJvmVersion = cp.getProperty("jvm.slaveversion");
+ if ( slaveJvmVersion == null )
+ {slaveJvmVersion = jvmVersion;}
+ System.out.println("slaveJvmVersion: " + slaveJvmVersion);
+
+ derbyVersion = cp.getProperty("derby.version");
+ System.out.println("derbyVersion: " + derbyVersion);
+
+ derbyMasterVersion = cp.getProperty("derby.masterversion");
+ if ( derbyMasterVersion == null )
+ {derbyMasterVersion = derbyVersion;}
+ System.out.println("derbyMasterVersion: " + derbyMasterVersion);
+
+ derbySlaveVersion = cp.getProperty("derby.slaveversion");
+ if ( derbySlaveVersion == null )
+ {derbySlaveVersion = derbyVersion;}
+ System.out.println("derbySlaveVersion: " + derbySlaveVersion);
+
+ String derbyTestingJar = derbyVersion + FS+"derbyTesting.jar";
+ if ( specialTestingJar != null ) derbyTestingJar = specialTestingJar;
+ System.out.println("derbyTestingJar: " + derbyTestingJar);
+
+ junit_jar = cp.getProperty("junit_jar");
+ System.out.println("junit_jar: " + junit_jar);
+
+ test_jars = derbyTestingJar
+ + ":" + junit_jar
+ ;
+ System.out.println("test_jars: " + test_jars);
+
+ sleepTime = Integer.parseInt(cp.getProperty("test.sleepTime","15000"));
+ System.out.println("sleepTime: " + sleepTime);
+
+ runUnReplicated = cp.getProperty("test.runUnReplicated","false").equalsIgnoreCase("true");
+ System.out.println("runUnReplicated: " + runUnReplicated);
+
+ localEnv = cp.getProperty("test.localEnvironment","false").equalsIgnoreCase("true");
+ System.out.println("localEnv: " + localEnv);
+
+ derbyProperties =
+ "derby.infolog.append=true"+LF
+ +"derby.drda.logConnections=true"+LF
+ +"derby.drda.traceAll=true"+LF;
+
+
+ System.out.println("--------------------------------------------------------");
+
+ masterPreRepl = new Load("masterPreRepl", cp);
+ masterPostRepl = new Load("masterPostRepl", cp);
+ slavePreSlave = new Load("slavePreSlave", cp);
+ masterPostSlave = new Load("masterPostSlave", cp);
+ slavePostSlave = new Load("slavePostSlave", cp);
+
+ System.out.println("--------------------------------------------------------");
+ // for SimplePerfTest
+ tuplesToInsert = Integer.parseInt(cp.getProperty("test.inserts","10000"));
+ commitFreq = Integer.parseInt(cp.getProperty("test.commitFreq","0")); // "0" is autocommit
+
+ System.out.println("--------------------------------------------------------");
+
+ state.initEnvironment(cp);
+
+ System.out.println("--------------------------------------------------------");
+
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Distributed.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: 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=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,170 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun
+
+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;
+
+
+/**
+ * Run a replication test on localhost
+ * by using default values for master and slave hosts,
+ * and master and slave ports.
+ *
+ */
+
+public class ReplicationRun_Local extends ReplicationRun
+{
+
+ /**
+ * Creates a new instance of ReplicationRun_Local
+ * @param testcaseName Identifying the test.
+ */
+ public ReplicationRun_Local(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 Suite");
+
+ suite.addTestSuite( ReplicationRun_Local.class );
+
+ return 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()
+ 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,
+ masterDatabasePath +FS+ masterDbSubPath); // Distinguishing master/slave
+
+ slaveServer = startServer(slaveJvmVersion, derbySlaveVersion,
+ slaveServerHost,
+ ALL_INTERFACES, // slaveServerHost, // "0.0.0.0", // All. or use slaveServerHost for interfacesToListenOn,
+ slaveServerPort,
+ slaveDatabasePath +FS+ 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);
+
+
+ // Used to run positive tests.
+ // Handle negative testing in State.testPostStartedMasterAndSlave().
+ // Observe that it will not be meaningful to do runTest if State.XXXX()
+ // has led to incorrect replication state wrt. replicationTest.
+
+ replicationTest = "org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationTestRun";
+ util.DEBUG("replicationTest: " + replicationTest);
+ replicationVerify = "org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationTestRun_Verify";
+ // replicationVerify = "/home/os136789/Replication/testing/verify_ReplicationTestRun.sql";
+ util.DEBUG("replicationVerify: " + replicationVerify);
+
+ runTest(replicationTest, // Returns immediatly if replicationTest is null.
+ jvmVersion,
+ testClientHost,
+ masterServerHost, masterServerPort,
+ replicatedDb);
+
+ 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);
+ // As of 2008-02-06 master does not accept shutdown after replication, so:
+ // do a 'kill pid' after ending the test run
+
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationTestRun.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationTestRun.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationTestRun.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationTestRun.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,93 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationTestRun
+
+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.functionTests.tests.derbynet.PrepareStatementTest;
+import org.apache.derbyTesting.functionTests.tests.lang.AnsiTrimTest;
+import org.apache.derbyTesting.functionTests.tests.lang.CreateTableFromQueryTest;
+import org.apache.derbyTesting.functionTests.tests.lang.SimpleTest;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.JDBCClient;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+public class ReplicationTestRun extends BaseJDBCTestCase
+{
+
+ /** Creates a new instance of ReplicationTestRun */
+ public ReplicationTestRun(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("*** ReplicationTestRun.suite()");
+
+ TestSuite suite = new TestSuite("ReplicationTestRun");
+ System.out.println("*** Done new TestSuite()");
+
+ String masterHostName = System.getProperty("test.serverHost", "localhost");
+ int masterPortNo = Integer.parseInt(System.getProperty("test.serverPort", "1527"));
+
+ suite.addTest(StandardTests.simpleTest(masterHostName, masterPortNo));
+ System.out.println("*** Done suite.addTest(StandardTests.simpleTest())");
+
+ /* PoC: Gives 'Something wrong with the instants!' Seems to be volume related? * /
+ suite.addTest(StandardTests.prepareStatementTest(masterHostName, masterPortNo));
+ System.out.println("*** Done suite.addTest(StandardTests.prepareStatementTest())");
+ / * */
+
+ suite.addTest(StandardTests.ansiTrimTest(masterHostName, masterPortNo)); // Something wrong with the instants!
+ System.out.println("*** Done suite.addTest(StandardTests.ansiTrimTest())");
+
+ suite.addTest(StandardTests.createTableFromQueryTest(masterHostName, masterPortNo));
+ System.out.println("*** Done suite.addTest(StandardTests.createTableFromQueryTest())");
+
+ /*
+ suite.addTest(DatabaseClassLoadingTest.suite());
+ suite.addTest(DynamicLikeOptimizationTest.suite());
+ suite.addTest(ExistsWithSetOpsTest.suite());
+ suite.addTest(GrantRevokeTest.suite());
+ suite.addTest(GroupByExpressionTest.suite());
+ suite.addTest(LangScripts.suite());
+ suite.addTest(MathTrigFunctionsTest.suite());
+ suite.addTest(PrepareExecuteDDL.suite());
+ suite.addTest(RoutineSecurityTest.suite());
+ suite.addTest(RoutineTest.suite());
+ suite.addTest(SQLAuthorizationPropTest.suite());
+ suite.addTest(StatementPlanCacheTest.suite());
+ suite.addTest(StreamsTest.suite());
+ suite.addTest(TimeHandlingTest.suite());
+ suite.addTest(TriggerTest.suite());
+ suite.addTest(VTITest.suite());
+ */
+ /*
+ suite.addTest(org.apache.derbyTesting.functionTests.suites.All.replSuite());
+ */
+
+ return (Test)suite;
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationTestRun.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationTestRun_Verify.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationTestRun_Verify.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationTestRun_Verify.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationTestRun_Verify.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,81 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationTestRun
+
+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.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.functionTests.tests.derbynet.PrepareStatementTest;
+import org.apache.derbyTesting.functionTests.tests.lang.AnsiTrimTest;
+import org.apache.derbyTesting.functionTests.tests.lang.CreateTableFromQueryTest;
+import org.apache.derbyTesting.functionTests.tests.lang.SimpleTest;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.JDBCClient;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+public class ReplicationTestRun_Verify extends BaseJDBCTestCase
+{
+
+ public ReplicationTestRun_Verify(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("*** ReplicationTestRun_Verify.suite()");
+
+ TestSuite suite = new TestSuite("ReplicationTestRun_Verify");
+ System.out.println("*** Done new TestSuite()");
+
+ String masterHostName = System.getProperty("test.serverHost", "localhost");
+ int masterPortNo = Integer.parseInt(System.getProperty("test.serverPort", "1527"));
+
+ suite.addTest(ReplicationTestRun_Verify.simpleVerify(masterHostName, masterPortNo));
+ System.out.println("*** Done suite.addTest(StandardTests.simpleTest())");
+
+ return (Test)suite;
+ }
+
+ private static Test simpleVerify(String serverHost, int serverPort)
+ {
+ return TestConfiguration.existingServerSuite(ReplicationTestRun_Verify.class,
+ false,serverHost,serverPort);
+ }
+
+ public void test() // Verification code..
+ throws SQLException
+ {
+ Connection conn = getConnection();
+ Statement s = conn.createStatement();
+ ResultSet rs = s.executeQuery("select SCHEMAID, TABLENAME from sys.systables");
+ while (rs.next())
+ {
+ System.out.println(rs.getString(1) + " " + rs.getString(2));
+ }
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationTestRun_Verify.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMaster.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMaster.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMaster.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMaster.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,173 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ShutdownMaster
+
+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 ShutdownMaster extends BaseJDBCTestCase
+{
+ private static ReplicationRun repRun = new ReplicationRun("ShutdownMaster");
+
+ public ShutdownMaster(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ /* */
+ static String jvmVersion = null;
+ static String derbyVersion = null;
+ static String masterServerHost = null;
+ static int masterServerPort = -1;
+ static String masterDatabasePath = null;
+ static String slaveServerHost = null;
+ static int slaveServerPort = -1;
+ static String slaveDatabasePath = null;
+ /* */
+
+ static void setEnv()
+ throws Exception
+ {
+ repRun.initEnvironment();
+ masterServerHost = ReplicationRun.masterServerHost;
+ masterServerPort = ReplicationRun.masterServerPort;
+ slaveServerHost = ReplicationRun.slaveServerHost;
+ slaveServerPort = ReplicationRun.slaveServerPort;
+ jvmVersion = ReplicationRun.masterJvmVersion;
+ derbyVersion = ReplicationRun.derbyMasterVersion;
+ masterDatabasePath = ReplicationRun.masterDatabasePath;
+ slaveDatabasePath = ReplicationRun.slaveDatabasePath;
+ }
+
+ /**
+ * Test shut down master server during replication.
+ *
+ * @throws SQLException, IOException, InterruptedException
+ */
+ void shutdown(String url, boolean dbOnly, boolean killServer) // FIXME?! Factor out this as common with ShutdownSlave!
+ throws SQLException, IOException, InterruptedException
+ {
+
+ System.out.println("**** ShutdownMaster.shutdown() "
+ + getTestConfiguration().getJDBCClient().getJDBCDriverName()
+ + " url: " + url + " dbOnly: " + dbOnly + " killServer: " + killServer);
+
+ 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 (?,?)");
+
+ boolean expectNoConnection = false;
+ for (int i=0;i<1000;i++)
+ {
+ try
+ {
+ pSt.setInt(1, i);
+ pSt.setString(2, "i"+i);
+ pSt.execute();
+ }
+ catch (SQLException se)
+ {
+ int errCode = se.getErrorCode();
+ String msg = se.getMessage();
+ String state = se.getSQLState();
+ System.out.println("execute Got SQLException: " + errCode + " " + state + " " + msg);
+ if ( expectNoConnection
+ && (errCode == 40000 && state.equalsIgnoreCase("08006")) /* FIXME! -1/40000 08006*/ )
+ {
+ System.out.println("As expected - connection terminated. Quit.");
+ return; // FIXME! Final code will refuse shutdown in this state!
+ }
+ else
+ {
+ throw se;
+ }
+ }
+ System.out.println("i: "+i);
+ if ( i == 500 )
+ {
+ if ( killServer )
+ {
+ repRun.killMaster(masterServerHost, masterServerPort);
+ expectNoConnection = true;
+ }
+ else if ( url == null )
+ {
+ System.out.println("**** stopServer: " + masterServerHost + ":" + masterServerPort);
+ repRun.stopServer(jvmVersion, derbyVersion, // Shut down server
+ masterServerHost, masterServerPort);
+ expectNoConnection = true;
+ // FIXME! Final code will refuse shutdown in this state!
+ }
+ else
+ {
+ /* Alternative: NB! url can be with or without database path! */
+ System.out.println("**** DriverManager.getConnection(\"" + url+";shutdown=true\");");
+ try
+ {
+ DriverManager.getConnection(url+";shutdown=true");
+ // Expecting: SQLCODE: -1, SQLSTATE: XJ015 | 08006, SQLERRMC: Derby system shutdown.
+ // FIXME! Final code will refuse shutdown in this state!
+ }
+ catch(SQLException se)
+ {
+ int errCode = se.getErrorCode();
+ String msg = se.getMessage();
+ String state = se.getSQLState();
+ String expectedState = (dbOnly)? "08006": "XJ015";
+ System.out.println("shutdown Got SQLException: " + errCode + " " + state + " " + msg);
+ if ( (errCode == -1)
+ && (state.equalsIgnoreCase(expectedState) ) )
+ {
+ System.out.println("As expected.");
+ expectNoConnection = true;
+ // return; // FIXME! Final code will refuse shutdown in this state!
+ }
+ else
+ {
+ throw se;
+ }
+ }
+ }
+ }
+ }
+ // With PoC V2d:
+ this.assertTrue("Should never reach this point in the ShutdownMaster test with PoC V2d!", false);
+ // Final code: shutdown of master database or server should not be allowed after
+ // starmaster.
+ 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/ShutdownMaster.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterDb.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterDb.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterDb.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterDb.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,82 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ShutdownMasterDb
+
+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.SQLException;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+public class ShutdownMasterDb extends ShutdownMaster
+{
+
+ public ShutdownMasterDb(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("**** ShutdownMasterDb.suite()");
+ System.out.println("'ShutdownMasterDb' can not be run outside the 'ReplicationRun' framework.");
+
+ setEnv();
+
+ TestSuite suite = new TestSuite("ShutdownMasterDb");
+ suite.addTest(ShutdownMasterDb.suite(masterServerHost,masterServerPort)); // (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("*** ShutdownMasterDb.suite("+serverHost+","+serverPort+")");
+
+ Test t = TestConfiguration.existingServerSuite(ShutdownMasterDb.class,false,serverHost,serverPort);
+ System.out.println("*** Done TestConfiguration.existingServerSuite(ShutdownMasterDb.class,false,"
+ +serverHost+":"+serverPort+")");
+ return t;
+ }
+
+ /**
+ * Test shut down master database during replication.
+ *
+ * @throws SQLException, IOException, InterruptedException
+ */
+ public void testShutdownMasterDb()
+ throws SQLException, IOException, InterruptedException
+ {
+ String masterServerURL = "jdbc:derby:"
+ +"//"+masterServerHost+":"+masterServerPort+"/";
+ String masterDbURL = masterServerURL
+ +ReplicationRun.masterDatabasePath
+ +"/"+ReplicationRun.masterDbSubPath
+ +"/"+ReplicationRun.replicatedDb;
+
+ shutdown(masterDbURL, true, false); // true : shutdown database only!
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterDb.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServer.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServer.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServer.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,77 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ShutdownMasterServer
+
+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.SQLException;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+public class ShutdownMasterServer extends ShutdownMaster
+{
+
+ public ShutdownMasterServer(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("**** ShutdownMasterServer.suite()");
+ System.out.println("'ShutdownMasterServer' can not be run outside the 'ReplicationRun' framework.");
+
+ setEnv();
+
+ TestSuite suite = new TestSuite("ShutdownMasterServer");
+ suite.addTest(ShutdownMasterServer.suite(masterServerHost,masterServerPort)); // (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("*** ShutdownMasterServer.suite("+serverHost+","+serverPort+")");
+
+ Test t = TestConfiguration.existingServerSuite(ShutdownMasterServer.class,false,serverHost,serverPort);
+ System.out.println("*** Done TestConfiguration.existingServerSuite(ShutdownMasterServer.class,false,"
+ +serverHost+":"+serverPort+")");
+ return t;
+ }
+
+ /**
+ * Test shut down master server during replication.
+ *
+ * @throws SQLException, IOException, InterruptedException
+ */
+ public void testShutdownMasterServer()
+ throws SQLException, IOException, InterruptedException
+ {
+ String masterServerURL = "jdbc:derby:"
+ +"//"+masterServerHost+":"+masterServerPort+"/"; // No database path!
+
+ shutdown(masterServerURL, false, false); // false : shutdown server, false: do not use OS kill!
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServerByOsKill.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServerByOsKill.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServerByOsKill.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServerByOsKill.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,79 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ShutdownMasterServer
+
+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.SQLException;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+/**
+ * Test (slave) behaviour after killing the master server.
+ */
+public class ShutdownMasterServerByOsKill extends ShutdownMaster
+{
+
+ public ShutdownMasterServerByOsKill(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("**** ShutdownMasterServerByOsKill.suite()");
+ System.out.println("'ShutdownMasterServerByOsKill' can not be run outside the 'ReplicationRun' framework.");
+
+ setEnv();
+
+ TestSuite suite = new TestSuite("ShutdownMasterServerByOsKillCtrl");
+ suite.addTest(ShutdownMasterServerByOsKill.suite(masterServerHost,masterServerPort)); // (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("*** ShutdownMasterServerByOsKill.suite("+serverHost+","+serverPort+")");
+
+ Test t = TestConfiguration.existingServerSuite(ShutdownMasterServerByOsKill.class,false,serverHost,serverPort);
+ System.out.println("*** Done TestConfiguration.existingServerSuite(ShutdownMasterServerByOsKill.class,false,"
+ +serverHost+":"+serverPort+")");
+ return t;
+ }
+
+ /**
+ * Test shut down master server during replication.
+ *
+ * @throws SQLException, IOException, InterruptedException
+ */
+ public void testShutdownMasterServer()
+ throws SQLException, IOException, InterruptedException
+ {
+ shutdown(null, false, true); // (null: use NetworkServerControl, false : shutdown server,) true: us OS kill on server!
+
+ // Check slave state:...
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServerByOsKill.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServerViaNwSrvCtrl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServerViaNwSrvCtrl.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServerViaNwSrvCtrl.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServerViaNwSrvCtrl.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,80 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ShutdownMasterServer
+
+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.SQLException;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+/**
+ * Test (slave) behaviour after shutdown of the master server
+ * via NetworkServerControl.
+ */
+public class ShutdownMasterServerViaNwSrvCtrl extends ShutdownMaster
+{
+
+ public ShutdownMasterServerViaNwSrvCtrl(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("**** ShutdownMasterServerViaNwSrvCtrl.suite()");
+ System.out.println("'ShutdownMasterServerViaNwSrvCtrl' can not be run outside the 'ReplicationRun' framework.");
+
+ setEnv();
+
+ TestSuite suite = new TestSuite("ShutdownMasterServerViaNwSrvCtrl");
+ suite.addTest(ShutdownMasterServerViaNwSrvCtrl.suite(masterServerHost,masterServerPort)); // (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("*** ShutdownMasterServerViaNwSrvCtrl.suite("+serverHost+","+serverPort+")");
+
+ Test t = TestConfiguration.existingServerSuite(ShutdownMasterServerViaNwSrvCtrl.class,false,serverHost,serverPort);
+ System.out.println("*** Done TestConfiguration.existingServerSuite(ShutdownMasterServerViaNwSrvCtrl.class,false,"
+ +serverHost+":"+serverPort+")");
+ return t;
+ }
+
+ /**
+ * Test shut down master server during replication.
+ *
+ * @throws SQLException, IOException, InterruptedException
+ */
+ public void testShutdownMasterServer()
+ throws SQLException, IOException, InterruptedException
+ {
+ shutdown(null, false, false); // null: use NetworkServerControl, false : shutdown server: not only db!
+
+ // Check slave state:...
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMasterServerViaNwSrvCtrl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlave.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlave.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlave.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlave.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,193 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ShutdownSlave
+
+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 ShutdownSlave extends BaseJDBCTestCase
+{
+ private static ReplicationRun repRun = new ReplicationRun("ShutdownSlave");
+
+ public ShutdownSlave(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ /* */
+ static String jvmVersion = null;
+ static String derbyVersion = null;
+ static String slaveServerHost = null;
+ static int slaveServerPort = -1;
+ static String slaveDatabasePath = null;
+ static String masterServerHost = null;
+ static int masterServerPort = -1;
+ static String masterDatabasePath = null;
+ /* */
+
+ static void setEnv()
+ throws Exception
+ {
+ repRun.initEnvironment();
+ masterServerHost = ReplicationRun.masterServerHost;
+ masterServerPort = ReplicationRun.masterServerPort;
+ slaveServerHost = ReplicationRun.slaveServerHost;
+ slaveServerPort = ReplicationRun.slaveServerPort;
+ jvmVersion = ReplicationRun.masterJvmVersion;
+ derbyVersion = ReplicationRun.derbyMasterVersion;
+ masterDatabasePath = ReplicationRun.masterDatabasePath;
+ slaveDatabasePath = ReplicationRun.slaveDatabasePath;
+ }
+
+ /*
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("**** ShutdownSlave.suite()");
+ System.out.println("'ShutdownSlave' can not be run outside the 'ReplicationRun' framework.");
+
+ setEnv();
+
+ TestSuite suite = new TestSuite("ShutdownSlave");
+ suite.addTest(ShutdownSlave.suite(masterServerHost, masterServerPort));
+ return (Test)suite;
+ }
+ */
+ /**
+ * Adds this class to the *existing server* suite.
+ */
+ /*
+ public static Test suite(String serverHost, int serverPort)
+ throws IOException
+ {
+ System.out.println("*** ShutdownSlave.suite("+serverHost+","+serverPort+")");
+
+ Test t = TestConfiguration.existingServerSuite(ShutdownSlave.class,false,serverHost,serverPort);
+ System.out.println("*** Done TestConfiguration.existingServerSuite(ShutdownSlave.class,false,"
+ +serverHost+":"+serverPort+")");
+ return t;
+ }
+ */
+
+ /**
+ * Test shut down slave server during replication.
+ *
+ * @throws SQLException, IOException, InterruptedException
+ */
+ /*
+ public void testShutdownSlave()
+ throws SQLException, IOException, InterruptedException
+ {
+ String slaveServerURL = "jdbc:derby:"
+ +"//"+slaveServerHost+":"+slaveServerPort+"/";
+ String slaveDbURL = slaveServerURL
+ +ReplicationRun.slaveDatabasePath
+ +"/"+ReplicationRun.slaveDbSubPath
+ +"/"+ReplicationRun.replicatedDb;
+
+ // shutdown(null, false, true); // -,-,true: Use OS kill on server!
+ // shutdown(null, false, false); // null,-,-: use networkservercontrol!
+ shutdown(slaveServerURL, false, false); // serverURL,false,-: shutdown server!
+ // shutdown(slaveDbURL, true, false); // dbURL,true,-: shutdown database!
+ }
+ */
+
+ void shutdown(String url, boolean dbOnly, boolean killServer) // FIXME! Factor out this as common with ShutdownMaster!
+ throws SQLException, IOException, InterruptedException
+ {
+
+ System.out.println("**** ShutdownSlave.shutdown() "
+ + getTestConfiguration().getJDBCClient().getJDBCDriverName()
+ + " " + url + " dbOnly: " + dbOnly + " killServer: " + killServer);
+
+ Connection conn = getConnection(); // To master
+ 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 )
+ {
+ // conn.commit(); // Force transferring replication data?
+ if ( killServer )
+ {
+ repRun.killMaster(slaveServerHost, slaveServerPort);
+ // expectNoConnection = true;
+ }
+ else if (url == null )
+ {
+ repRun.stopServer(jvmVersion, derbyVersion, // Shuts down the server
+ slaveServerHost, slaveServerPort);
+ }
+ else
+ { // url specifies server or database shutdown.
+ System.out.println("**** DriverManager.getConnection(\"" + url+";shutdown=true\");");
+ try
+ {
+ DriverManager.getConnection(url+";shutdown=true"); // PoC hangs on dburl.
+ // SQLCODE: -1, SQLSTATE: XJ015
+ // Will not be allowed in final code: when privileges are implemented!
+ }
+ catch( SQLException se)
+ {
+ int errCode = se.getErrorCode();
+ String msg = se.getMessage();
+ String state = se.getSQLState();
+ String expectedState = (dbOnly)? "08004": "XJ015";
+ System.out.println("shutdown Got SQLException: " + errCode + " " + state + " " + msg);
+ if ( (errCode == -1)
+ && (state.equalsIgnoreCase(expectedState) ) )
+ {
+ System.out.println("As expected.");
+ // Continue insert on master. return;
+ // shutdown db will be refused in this state!
+ }
+ else
+ {
+ throw se;
+ }
+ }
+ }
+ }
+ }
+ 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/ShutdownSlave.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveDb.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveDb.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveDb.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveDb.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,94 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ShutdownSlave
+
+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;
+
+/**
+ * Test (master) behaviour after shutdown of the slave database.
+ */
+public class ShutdownSlaveDb extends ShutdownSlave
+{
+
+ public ShutdownSlaveDb(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("**** ShutdownSlaveDb.suite()");
+ System.out.println("'ShutdownSlaveSDb' can not be run outside the 'ReplicationRun' framework.");
+
+ setEnv();
+
+ TestSuite suite = new TestSuite("ShutdownSlaveDb");
+ suite.addTest(ShutdownSlaveDb.suite(masterServerHost, masterServerPort));
+ return (Test)suite;
+ }
+ /**
+ * Adds this class to the *existing server* suite.
+ */
+ public static Test suite(String serverHost, int serverPort)
+ throws IOException
+ {
+ System.out.println("*** ShutdownSlaveDb.suite("+serverHost+","+serverPort+")");
+
+ Test t = TestConfiguration.existingServerSuite(ShutdownSlaveDb.class,false,serverHost,serverPort);
+ System.out.println("*** Done TestConfiguration.existingServerSuite(ShutdownSlaveDb.class,false,"
+ +serverHost+":"+serverPort+")");
+ return t;
+ }
+
+ /**
+ * Test shut down slave server during replication.
+ *
+ * @throws SQLException, IOException, InterruptedException
+ */
+ public void testShutdownSlave()
+ throws SQLException, IOException, InterruptedException
+ {
+ String slaveServerURL = "jdbc:derby:"
+ +"//"+slaveServerHost+":"+slaveServerPort+"/";
+ String slaveDbURL = slaveServerURL
+ +ReplicationRun.slaveDatabasePath
+ +"/"+ReplicationRun.slaveDbSubPath
+ +"/"+ReplicationRun.replicatedDb;
+
+ shutdown(slaveDbURL, true, false); // dbURL,true,-: shutdown database!
+
+ // Check master state:...
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveDb.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServer.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServer.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServer.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServer.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,90 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ShutdownSlave
+
+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;
+
+/**
+ * Test (master) behaviour after shutdown of the slave server.
+ */
+public class ShutdownSlaveServer extends ShutdownSlave
+{
+
+ public ShutdownSlaveServer(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("**** ShutdownSlaveServer.suite()");
+ System.out.println("'ShutdownSlaveServer' can not be run outside the 'ReplicationRun' framework.");
+
+ setEnv();
+
+ TestSuite suite = new TestSuite("ShutdownSlaveServer");
+ suite.addTest(ShutdownSlaveServer.suite(masterServerHost, masterServerPort));
+ return (Test)suite;
+ }
+ /**
+ * Adds this class to the *existing server* suite.
+ */
+ public static Test suite(String serverHost, int serverPort)
+ throws IOException
+ {
+ System.out.println("*** ShutdownSlaveServer.suite("+serverHost+","+serverPort+")");
+
+ Test t = TestConfiguration.existingServerSuite(ShutdownSlaveServer.class,false,serverHost,serverPort);
+ System.out.println("*** Done TestConfiguration.existingServerSuite(ShutdownSlaveServer.class,false,"
+ +serverHost+":"+serverPort+")");
+ return t;
+ }
+
+ /**
+ * Test shut down slave server during replication.
+ *
+ * @throws SQLException, IOException, InterruptedException
+ */
+ public void testShutdownSlave()
+ throws SQLException, IOException, InterruptedException
+ {
+ String slaveServerURL = "jdbc:derby:"
+ +"//"+slaveServerHost+":"+slaveServerPort+"/";
+
+ shutdown(slaveServerURL, false, false); // serverURL,false,-: shutdown server!
+
+ // Check master state:...
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServerByOsKill.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServerByOsKill.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServerByOsKill.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServerByOsKill.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,87 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ShutdownSlave
+
+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;
+
+/**
+ * Test (master) behaviour after killing the slave server.
+ */
+public class ShutdownSlaveServerByOsKill extends ShutdownSlave
+{
+
+ public ShutdownSlaveServerByOsKill(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("**** ShutdownSlaveServerByOsKill.suite()");
+ System.out.println("'ShutdownSlaveServerByOsKill' can not be run outside the 'ReplicationRun' framework.");
+
+ setEnv();
+
+ TestSuite suite = new TestSuite("ShutdownSlaveServerByOsKill");
+ suite.addTest(ShutdownSlaveServerByOsKill.suite(masterServerHost, masterServerPort));
+ return (Test)suite;
+ }
+ /**
+ * Adds this class to the *existing server* suite.
+ */
+ public static Test suite(String serverHost, int serverPort)
+ throws IOException
+ {
+ System.out.println("*** ShutdownSlaveServerByOsKill.suite("+serverHost+","+serverPort+")");
+
+ Test t = TestConfiguration.existingServerSuite(ShutdownSlaveServerByOsKill.class,false,serverHost,serverPort);
+ System.out.println("*** Done TestConfiguration.existingServerSuite(ShutdownSlaveServerByOsKill.class,false,"
+ +serverHost+":"+serverPort+")");
+ return t;
+ }
+
+ /**
+ * Test shut down slave server during replication.
+ *
+ * @throws SQLException, IOException, InterruptedException
+ */
+ public void testShutdownSlave()
+ throws SQLException, IOException, InterruptedException
+ {
+ shutdown(null, false, true); // -,-,true: Use OS kill on server!
+
+ // Check master state:...
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServerByOsKill.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServerViaNwSrvCtrl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServerViaNwSrvCtrl.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServerViaNwSrvCtrl.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServerViaNwSrvCtrl.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,88 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ShutdownSlave
+
+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;
+
+/**
+ * Test (master) behaviour after shutdown of the slave server
+ * via NetworkServerControl.
+ */
+public class ShutdownSlaveServerViaNwSrvCtrl extends ShutdownSlave
+{
+
+ public ShutdownSlaveServerViaNwSrvCtrl(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("**** ShutdownSlaveServerViaNwSrvCtrl.suite()");
+ System.out.println("'ShutdownSlaveServerViaNwSrvCtrl' can not be run outside the 'ReplicationRun' framework.");
+
+ setEnv();
+
+ TestSuite suite = new TestSuite("ShutdownSlaveServerViaNwSrvCtrl");
+ suite.addTest(ShutdownSlaveServerViaNwSrvCtrl.suite(masterServerHost, masterServerPort));
+ return (Test)suite;
+ }
+ /**
+ * Adds this class to the *existing server* suite.
+ */
+ public static Test suite(String serverHost, int serverPort)
+ throws IOException
+ {
+ System.out.println("*** ShutdownSlaveServerViaNwSrvCtrl.suite("+serverHost+","+serverPort+")");
+
+ Test t = TestConfiguration.existingServerSuite(ShutdownSlaveServerViaNwSrvCtrl.class,false,serverHost,serverPort);
+ System.out.println("*** Done TestConfiguration.existingServerSuite(ShutdownSlaveServerViaNwSrvCtrl.class,false,"
+ +serverHost+":"+serverPort+")");
+ return t;
+ }
+
+ /**
+ * Test shut down slave server during replication.
+ *
+ * @throws SQLException, IOException, InterruptedException
+ */
+ public void testShutdownSlave()
+ throws SQLException, IOException, InterruptedException
+ {
+ shutdown(null, false, false); // null,-,-: use networkservercontrol!
+
+ // Check master state:...
+ }
+
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlaveServerViaNwSrvCtrl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest.java?rev=632371&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest.java Fri Feb 29 08:10:21 2008
@@ -0,0 +1,127 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.SimplePerfTest
+
+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 SimplePerfTest extends BaseJDBCTestCase
+{
+
+ public SimplePerfTest(String testcaseName)
+ {
+ super(testcaseName);
+ }
+
+ public static Test suite()
+ throws Exception
+ {
+ System.out.println("**** SimplePerfTest.suite()");
+
+ String masterHostName = System.getProperty("test.serverHost", "localhost");
+ int masterPortNo = Integer.parseInt(System.getProperty("test.serverPort", "1527"));
+
+ TestSuite suite = new TestSuite("SimplePerfTest");
+
+ tuplesToInsert = Integer.parseInt(System.getProperty("test.inserts", "1000"));
+ commitFreq = Integer.parseInt(System.getProperty("test.commitFreq", "0"));
+
+ suite.addTest(SimplePerfTest.suite(masterHostName, masterPortNo));
+ System.out.println("*** Done suite.addTest(SimplePerfTest.suite())");
+
+ return (Test)suite;
+ }
+ private static int tuplesToInsert = 0;
+ private static int commitFreq = 0; // Means autocommit.
+ /**
+ * Adds this class to the *existing server* suite.
+ */
+ public static Test suite(String serverHost, int serverPort)
+ {
+ System.out.println("*** SimplePerfTest.suite(serverHost,serverPort)");
+
+ Test t = TestConfiguration.existingServerSuite(SimplePerfTest.class,false,serverHost,serverPort);
+ System.out.println("*** Done TestConfiguration.existingServerSuite(SimplePerfTest.class,false,serverHost,serverPort)");
+ return t;
+ }
+
+ /**
+ *
+ *
+ * @throws SQLException, IOException, InterruptedException
+ */
+ public void testInserts()
+ throws SQLException, IOException, InterruptedException
+ {
+ System.out.println("**** SimplePerfTest.testInserts() "+
+ 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 (?,?)");
+
+ conn.setAutoCommit(commitFreq == 0 ? true : false); // commitFreq == 0 means do autocommit
+
+ for (int i=0;i<tuplesToInsert;i++)
+ {
+ pSt.setInt(1, i);
+ pSt.setString(2, "i"+i);
+ pSt.execute();
+ // commit after each commitFreq insert
+ if ((commitFreq != 0) && ((i % commitFreq) == 0)){System.out.println("i: "+i);conn.commit();}
+ }
+
+ conn.commit();
+
+ 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");
+ }
+ public void verifyTestInserts()
+ throws SQLException, IOException, InterruptedException
+ {
+ System.out.println("**** SimplePerfTest.verifyTestInserts() "+
+ getTestConfiguration().getJDBCClient().getJDBCDriverName());
+
+ Connection conn = getConnection();
+
+ Statement s = conn.createStatement();
+
+ ResultSet rs = s.executeQuery("select count(*) from t");
+ rs.next();
+ int count = rs.getInt(1);
+ System.out.println("count: "+count);
+ }
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/SimplePerfTest.java
------------------------------------------------------------------------------
svn:eol-style = native