1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
|
/*
Derby - Class org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationRun_Full
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 org.apache.derbyTesting.junit.BaseTestSuite;
import org.apache.derbyTesting.junit.SecurityManagerSetup;
public class ReplicationRun_Full extends ReplicationRun
{
public ReplicationRun_Full(String testcaseName)
{
super(testcaseName);
LF = System.getProperties().getProperty("line.separator");
}
public static Test suite()
{
BaseTestSuite suite = new BaseTestSuite("Replication_Full Suite");
suite.addTestSuite( ReplicationRun_Full.class );
return SecurityManagerSetup.noSecurityManager(suite);
}
//////////////////////////////////////////////////////////////
////
//// The replication test framework (testReplication()):
//// a) "clean" replication run starting master and slave servers,
//// preparing master and slave databases,
//// starting and stopping replication and doing
//// failover for a "normal"/"failure free" replication
//// test run.
//// b) Running (positive and negative) tests at the various states
//// of replication to test what is and is not accepted compared to
//// the functional specification.
//// c) Adding additional load on master and slave servers in
//// different states of replication.
////
//////////////////////////////////////////////////////////////
public void testReplication()
throws Exception
{
cleanAllTestHosts();
initEnvironment();
/* 'testReplication' steps through all states of the
* replication process.
* Tests required to be run in these states
* should be specified in the replicationtest.properties file.
*/
if ( runUnReplicated ) // test.runUnReplicated
{
util.DEBUG("**** BEGIN Running test without replication.");
initMaster(masterServerHost,
replicatedDb);
startServer(masterJvmVersion, derbyVersion, // No replication
masterServerHost,
ALL_INTERFACES, // masterServerHost, // "0.0.0.0", // All. or use masterServerHost for interfacesToListenOn,
masterServerPort,
masterDbSubPath); // Distinguishing master/slave
runTest(replicationTest,
jvmVersion,
testClientHost,
masterServerHost, masterServerPort,
replicatedDb);
stopServer(masterJvmVersion, derbyMasterVersion,
masterServerHost, masterServerPort);
util.DEBUG("**** END Running test without replication.");
// util.sleep(5000L, "End of runUnReplicated"); // Just for testing....
}
///////////////////////////////////////////////////////
// State: PreStartedMasterServer, PreStartedSlaveServer
if (state.testPreStartedMasterServer()) return;
initMaster(masterServerHost,
replicatedDb); // Prototype V2: copy orig (possibly empty) db to db_master.
startServer(masterJvmVersion, derbyMasterVersion,
masterServerHost,
ALL_INTERFACES, // masterServerHost, // "0.0.0.0", // All. or use masterServerHost for interfacesToListenOn,
masterServerPort,
masterDbSubPath); // Distinguishing master/slave
///////////////////////////////////////////////////////
// State: PostStartedMasterServer, PreStartedSlaveServer
startOptionalLoad(masterPreRepl,
masterDbSubPath,
masterServerHost,
masterServerPort);
if (state.testPreStartedSlaveServer()) return; // + stop master server!
// Thread.sleep(5000L); // Just for testing....
startServer(slaveJvmVersion, derbySlaveVersion,
slaveServerHost,
ALL_INTERFACES, // slaveServerHost, // "0.0.0.0", // All. or use slaveServerHost for interfacesToListenOn,
slaveServerPort,
slaveDbSubPath); // Distinguishing master/slave
///////////////////////////////////////////////////////
// State: PostStartedMasterServer, PostStartedSlaveServer
// PreStartedMaster, PreStartedSlave
// Thread.sleep(15000L); // Just for testing....
startServerMonitor(slaveServerHost);
xFindServerPID(slaveServerHost, slaveServerPort); // JUST DEBUGGING!
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.
);
///////////////////////////////////////////////////////
// State: PostStartedMasterServer, PostStartedSlaveServer
// PostStartedMaster, PreStartedSlave
startOptionalLoad(masterPostRepl,
masterDbSubPath,
masterServerHost,
masterServerPort);
startOptionalLoad(slavePreSlave,
slaveDbSubPath,
slaveServerHost,
slaveServerPort);
// util.sleep(sleepTime, "Before initSlave"); // A. 'Something wrong with the instants!' if removed!
// 5secs is too little! 15secs is too little sometimes...!
// 30secs is too little w/ShutdownSlave!
if (state.testPreInitSlave()) return;
initSlave(/*slaveHost*/ slaveServerHost,
jvmVersion,
replicatedDb); // Trunk and Prototype V2: copy master db to db_slave.
if (state.testPreStartedSlave()) return;
startSlave(jvmVersion, replicatedDb,
slaveServerHost, // slaveClientInterface // where the slave db runs
slaveServerPort,
slaveServerHost, // for slaveReplInterface
slaveReplPort,
testClientHost);
if (state.testPreStartedMaster()) return;
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);
///////////////////////////////////////////////////////
// State: PostStartedMasterServer, PostStartedSlaveServer
// PostStartedMaster, PostStartedSlave
startOptionalLoad(masterPostSlave,
masterDbSubPath,
masterServerHost,
masterServerPort);
startOptionalLoad(slavePostSlave,
slaveDbSubPath,
slaveServerHost,
slaveServerPort);
// Thread.sleep(5000L); // Just for testing....
// util.sleep(10000L, "Before runTest"); // Perf. testing....
if (state.testPostStartedMasterAndSlave()) return;
// Could be run concurrently with runTest below?
// 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);
///////////////////////////////////////////////////////
// State: PostStartedMasterServer, PostStartedSlaveServer
// PostStartedMaster, PostStartedSlave
// PreStoppedMaster, PreStoppedSlave
if (state.testPreStoppedMaster()) return;
// PoC stopMaster(replicatedDb); // v7: RENAMED! FIXME! when 'stopMaster' cmd. available! // master..
/* stopMaster_ij(jvmVersion, replicatedDb,
masterServerHost,
masterServerPort,
testClientHost);
*/
///////////////////////////////////////////////////////
// State: PostStartedMasterServer, PostStartedSlaveServer
// PostStartedMaster, PostStartedSlave
// PostStoppedMaster, PreStoppedSlave, PreFailover
// Thread.sleep(5000L); // Just for testing....
if (state.testPreStoppedMasterServer()) return;
/* PoC stopServer(masterJvmVersion, derbyMasterVersion, // v7: NA // PoC V2b: forces failover on slave
masterServerHost, masterServerPort);
*/
///////////////////////////////////////////////////////
// State: PostStartedMasterServer, PostStartedSlaveServer
// PostStartedMaster, PostStartedSlave
// PostStoppedMaster, PreStoppedSlave
// PostStoppedMasterServer, PreStoppedSlaveServer, PoC: PostFailover
if (state.testPreStoppedSlave()) return;
// Thread.sleep(5000L); // Just for testing....
// PoC stopSlave(replicatedDb); // v7: NEW! FIXME! when 'stopSlave' cmd. available!
/* stopSlave_ij(jvmVersion, replicatedDb,
slaveServerHost,
slaveServerPort,
testClientHost);
*/
///////////////////////////////////////////////////////
// State: PostStartedMasterServer, PostStartedSlaveServer
// PostStartedMaster, PostStartedSlave
// PostStoppedMaster, PostStoppedSlave
// PostStoppedMasterServer, PreStoppedSlaveServer, PreFailover // PoC: PostFailover
// Thread.sleep(5000L); // Just for testing....
failOver(jvmVersion, // On master, which is the normal case.
masterDatabasePath, masterDbSubPath, replicatedDb,
masterServerHost, // Where the master db is run.
masterServerPort,
testClientHost);
// PoC failOver(replicatedDb); // FIXME! when 'failOver' cmd. available!
///////////////////////////////////////////////////////
// State: PostStartedMasterServer, PostStartedSlaveServer
// PostStartedMaster, PostStartedSlave
// PostStoppedMaster, PostStoppedSlave
// PostStoppedMasterServer, PreStoppedSlaveServer, PostFailover
// util.sleep(10000L, "After failover"); // Try to avoid DERBY-3463....
connectPing(slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb,
slaveServerHost,slaveServerPort,
testClientHost);
// If the slave server was shutdown, killed or died, start a "default" server on
// the same server and port to do the verification:
int slavePid = xFindServerPID(slaveServerHost, slaveServerPort);
if ( slavePid == -1 )
{
util.DEBUG("WARNING: slave server not available. Starting.");
startServer(jvmVersion, derbyVersion,
slaveServerHost,
ALL_INTERFACES, // slaveServerHost, // "0.0.0.0", // All. or use slaveServerHost for interfacesToListenOn,
slaveServerPort,
slaveDbSubPath); // Distinguishing master/slave
}
/* BEGIN Failover do not yet clean replication mode on slave! Must restart the server!*/
else{
if (true)
{
util.DEBUG("*********************** DERBY-3205/svn 630806. failover does now unset replication mode on slave.");
}
else // failover does not unset replication mode on slave.
{
util.DEBUG("*********************** DERBY-3205. failover does not unset replication mode on slave.");
/* That also blocks for connecting!:
// Do slave db shutdown (and reconnect) to unset... PRELIMINARY!!!
shutdownDb(slaveServerHost,slaveServerPort,
slaveDatabasePath +FS+ slaveDbSubPath,replicatedDb);
*/
/* */
restartServer(jvmVersion, derbyVersion, // restart server is too strong!
slaveServerHost,
ALL_INTERFACES,
slaveServerPort,
slaveDbSubPath); // Distinguishing master/slave
/* */
}
}/* END */
verifySlave();
// We should verify the master as well, at least to see that we still can connect.
// If the slave server was shutdown, killed or died, start a "default" server on
// the same server and port to do the verification:
int masterPid = xFindServerPID(masterServerHost, masterServerPort);
if ( masterPid == -1 )
{
util.DEBUG("WARNING: master server not available. Starting.");
startServer(jvmVersion, derbyVersion,
masterServerHost,
ALL_INTERFACES, // masterServerHost, // "0.0.0.0", // All. or use slaveServerHost for interfacesToListenOn,
masterServerPort,
masterDbSubPath); // Distinguishing master/slave
}
verifyMaster(); // NB NB Hangs here with localhost/ReplicationTestRun!
xFindServerPID(slaveServerHost, slaveServerPort); // JUST DEBUGGING!
// Thread.sleep(5000L); // Just for testing....
stopServer(jvmVersion, derbyVersion,
slaveServerHost, slaveServerPort);
///////////////////////////////////////////////////////
// State: PostStartedMasterServer, PostStartedSlaveServer
// PostStartedMaster, PostStartedSlave
// PostStoppedMaster, PostStoppedSlave
// PostStoppedMasterServer, PostStoppedSlaveServer, PostFailover
if (state.testPostStoppedSlaveServer()) return;
// Shutdown master:
stopServer(jvmVersion, derbyVersion,
masterServerHost, masterServerPort);
// As of 2008-02-06 master does not accept shutdown after replication, so:
masterPid = xFindServerPID(masterServerHost, masterServerPort);
if ( masterPid != -1 )
{
util.DEBUG("*********************** DERBY-3394. master does not accept shutdown after failover.");
killMaster(masterServerHost,masterServerPort);
}
}
}
|