Java Code Examples for org.apache.derbyTesting.junit.BaseTestCase#getJavaExecutableName()

The following examples show how to use org.apache.derbyTesting.junit.BaseTestCase#getJavaExecutableName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: 919148_ReplicationRun_0_s.java    From coming with MIT License 5 votes vote down vote up
private void failOver_ij(String jvmVersion,
        String dbPath, String dbSubPath, String dbName,
        String host,  // Where the db is run.
        int serverPort,
        
        String testClientHost)
        throws Exception
{
    
    String masterClassPath = derbyMasterVersion +FS+ "derbynet.jar";
            
    String URL = masterURL(dbName)
            +";failover=true";
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbytools.jar";
    if ( host.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
    }
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = clientJvm // "java"
            + " -Dij.driver=" + DRIVER_CLASS_NAME
            + " -Dij.connection.failover=\"" + URL + "\""
            + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
            + " " + "/home/os136789/Replication/testing/exit.sql"
            ;
    
    // Execute the ij command on the testClientHost as testUser
    String results =
            runUserCommandRemotely(command,
            testClientHost,
            testUser,
            "failOver_ij ");
    util.DEBUG(results);
}
 
Example 2
Source File: 919148_ReplicationRun_0_t.java    From coming with MIT License 4 votes vote down vote up
private void stopMaster_ij(String jvmVersion,
        String dbName,
        String masterHost,  // Where the master db is run.
        int masterServerPort,
        
        String testClientHost)
        throws Exception
{
    
    String masterClassPath = derbyMasterVersion +FS+ "derbynet.jar";
    if ( masterHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        masterClassPath = classPath;
    }
            
    String URL = masterURL(dbName)
            +";stopMaster=true"; 
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbytools.jar";
    if ( masterHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
    }
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = clientJvm // "java"
            + " -Dij.driver=" + DRIVER_CLASS_NAME
            + " -Dij.connection.stopMaster=\"" + URL + "\""
            + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
            + " " + "/home/os136789/Replication/testing/exit.sql"
            ;
    
    // Execute the ij command on the testClientHost as testUser
    String results =
            runUserCommandRemotely(command,
            testClientHost,
            testUser,
            "stopMaster_ij ");
    util.DEBUG(results);
}
 
Example 3
Source File: 919148_ReplicationRun_0_t.java    From coming with MIT License 4 votes vote down vote up
private void startSlave_ij(String jvmVersion,
        String dbName,
        String slaveHost,  // Where the slave db is run.
        int slaveServerPort, // slave server interface accepting client requests
        
        String slaveReplInterface, // slaveHost,
        int slaveReplPort, // slavePort)
        
        String testClientHost)
        throws Exception
{
    
    String slaveClassPath = derbySlaveVersion +FS+ "derbynet.jar";
    if ( slaveHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        slaveClassPath = classPath;
    }
    String URL = slaveURL(dbName)
            +";startSlave=true;slaveHost="+slaveReplInterface
            +";slavePort="+slaveReplPort;
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbytools.jar";
    if ( slaveHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
    }
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = clientJvm // "java"
            + " -Dij.driver=" + DRIVER_CLASS_NAME
            + " -Dij.connection.startSlave=\"" + URL + "\""
            + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
            + " " + "/home/os136789/Replication/testing/exit.sql"
            ;
    
    // Execute the ij command on the testClientHost as testUser
    /* String results =
            runUserCommandRemotely(command,
            testClientHost,
            testUser,
            "startSlave_ij ");
    util.DEBUG(results); */
    // 618220 + failover_impl_3205_v3.diff + derby-3361-1a.diff :
    runUserCommandInThreadRemotely(command,
            testClientHost,
            testUser,
            slaveDbSubPath+FS+dbName,
            "startSlave_ij ");
    
}
 
Example 4
Source File: 919148_ReplicationRun_0_t.java    From coming with MIT License 4 votes vote down vote up
private void startSlave_CLI(String clientVM,
        String dbName,
        String slaveClientInterface, // slaveHost, // Where the command is to be executed.
        int slaveServerPort,
        String slaveReplInterface,
        int slaveReplPort)
        throws InterruptedException
{
    
    String slaveClassPath = derbySlaveVersion +FS+ "derbynet.jar";
    if ( slaveClientInterface.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        slaveClassPath = classPath;
    }
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    /*
     * java -classpath ${SLAVE_LIB}/derbynet.jar org.apache.derby.drda.NetworkServerControl \
     *       startslave test -slavehost ${SLAVEREPLINTERFACE}  -slaveport ${SLAVEREPLPORT} \
     *       -h ${SLAVECLIENTINTERFACE} -p ${SLAVESERVERPORT}??  \
     *       -noSecurityManager
     */
    String command = clientJvm
            + " -classpath " + slaveClassPath
            + " " + networkServerControl
            + " startslave"
            + " " + dbName
            + " -slavehost " + slaveReplInterface + " -slaveport " + slaveReplPort
            + " -h " + slaveClientInterface + " -p " + slaveServerPort
            + " -noSecurityManager"
            ;
    
    util.DEBUG("Executing  '" + command + "' on " + slaveClientInterface); // slaveHost
    
    runUserCommandInThreadRemotely(command,
            slaveClientInterface, // slaveHost,
            testUser,
            slaveDbSubPath+FS+dbName,
            "startSlave_CLI ");
    
}
 
Example 5
Source File: 919148_ReplicationRun_0_t.java    From coming with MIT License 4 votes vote down vote up
private void startMaster_ij(String dbName,
        String masterHost,
        int masterServerPort,  // Where the master db is run.
        String slaveReplInterface, // master server interface accepting client requests
        
        int slaveReplPort, // slaveHost,
        String testClientHost)
        throws Exception
{
    
    String masterClassPath = derbyMasterVersion +FS+ "derbynet.jar";
    if ( masterHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        masterClassPath = classPath;
    }
            
    String URL = masterURL(dbName)
            +";startMaster=true;slaveHost="+slaveReplInterface
            +";slavePort="+slaveReplPort;
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbytools.jar";
    if ( masterHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
    }
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = clientJvm // "java"
            + " -Dij.driver=" + DRIVER_CLASS_NAME
            + " -Dij.connection.startMaster=\"" + URL + "\""
            + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
            + " " + "/home/os136789/Replication/testing/exit.sql"
            ;
    
    // Execute the ij command on the testClientHost as testUser
    String results =
            runUserCommandRemotely(command,
            testClientHost,
            testUser,
            "startMaster_ij ");
    util.DEBUG(results);
}
 
Example 6
Source File: 919148_ReplicationRun_0_t.java    From gumtree-spoon-ast-diff with Apache License 2.0 4 votes vote down vote up
private void startMaster_CLI(String clientVM,
        String dbName,
        String masterHost,  // Where the command is to be executed.
        int masterServerPort, // master server interface accepting client requests
        String slaveClientInterface, // Will be = slaveReplInterface = slaveHost if only one interface card used.
        int slaveServerPort, // masterPort, // Not used since slave don't accept client requests
        String slaveReplInterface, // slaveHost,
        int slaveReplPort) // slavePort)
        throws Exception
{
    
    String masterClassPath = derbyMasterVersion +FS+ "derbynet.jar";
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    if ( masterHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        masterClassPath = classPath;
    }
    /* java -classpath ${MASTER_LIB}/derbynet.jar \
     *       org.apache.derby.drda.NetworkServerControl startreplication test \
     *       -slavehost ${SLAVEREPLINTERFACE} -slaveport ${SLAVEREPLPORT} \
     *       -h ${SLAVECLIENTINTERFACE} -p ${SLAVESERVERPORT}?? \
     *       -noSecurityManager
     */
    String command = clientJvm
            + " -classpath " + masterClassPath
            + " " + networkServerControl
            + " startreplication" // startmaster!
            + " " + dbName
            + " -slavehost " + /*slaveHost*/ slaveReplInterface + " -slaveport " + /*slavePort*/ slaveReplPort
            + " -h " + /*masterHost*/ slaveClientInterface + " -p " + masterServerPort /*masterPort*/ /* see comment above slaveServerPort */
            + " -noSecurityManager"
            ;
    
    util.DEBUG("Executing '" + command + "' on " + masterHost);
    
    // Do rsh/ssh to masterHost and execute the command there.
    
    // runUserCommandRemotely(command, // FIXME?! Should NOT be in sep. thread? Wait for it to complete!?
    runUserCommandInThreadRemotely(command, //
            masterHost,
            testUser,
            masterDbSubPath+FS+dbName,
            "startMaster_CLI ");
    
}
 
Example 7
Source File: 919148_ReplicationRun_0_s.java    From gumtree-spoon-ast-diff with Apache License 2.0 4 votes vote down vote up
private void startSlave_ij(String jvmVersion,
        String dbName,
        String slaveHost,  // Where the slave db is run.
        int slaveServerPort, // slave server interface accepting client requests
        
        String slaveReplInterface, // slaveHost,
        int slaveReplPort, // slavePort)
        
        String testClientHost)
        throws Exception
{
    
    String slaveClassPath = derbySlaveVersion +FS+ "derbynet.jar";
    if ( slaveHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        slaveClassPath = classPath;
    }
    String URL = slaveURL(dbName)
            +";startSlave=true;slaveHost="+slaveReplInterface
            +";slavePort="+slaveReplPort;
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbytools.jar";
    if ( slaveHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
    }
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = clientJvm // "java"
            + " -Dij.driver=" + DRIVER_CLASS_NAME
            + " -Dij.connection.startSlave=\"" + URL + "\""
            + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
            + " " + "/home/os136789/Replication/testing/exit.sql"
            ;
    
    // Execute the ij command on the testClientHost as testUser
    /* String results =
            runUserCommandRemotely(command,
            testClientHost,
            testUser,
            "startSlave_ij ");
    util.DEBUG(results); */
    // 618220 + failover_impl_3205_v3.diff + derby-3361-1a.diff :
    runUserCommandInThreadRemotely(command,
            testClientHost,
            testUser,
            slaveDbSubPath+FS+dbName,
            "startSlave_ij ");
    
}
 
Example 8
Source File: 919148_ReplicationRun_0_t.java    From coming with MIT License 4 votes vote down vote up
private void runLoad(String load,
        String clientVM,
        String testClientHost,
        String masterHost, int masterPort,
        String dbSubPath) // FIXME? Should we allow extra URL options?
        throws Exception
{
    util.DEBUG("runLoad(" + load
            + ", " + clientVM
            + ", " + testClientHost
            + ", " + masterHost
            + ", " + masterPort
            + ", " + dbSubPath
            + ") "
            );
    
    
    String URL = masterLoadURL(dbSubPath);
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbyTesting.jar"
            // Needed for 'run resource 'createTestProcedures.subsql';' cases?
            // Nope? what is 'resource'?
            + PS + derbyVersion +FS+ "derbytools.jar";
    String testingClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbynet.jar" // WHY IS THIS NEEDED?
            // See TestConfiguration: startNetworkServer and stopNetworkServer
            + PS + test_jars;
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = null;
    
    if ( masterHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
        testingClassPath = classPath;
    }
    util.DEBUG("load: " + load);
    if ( load.indexOf(".sql") >= 0 )
    {
        command = clientJvm // "java"
                + " -Dij.driver=" + DRIVER_CLASS_NAME
                + " -Dij.connection.startTestClient=" + URL
                + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
                + " " + load
                ;
    }
    else
    {
        /* BEGIN For junit: */
        command = clientJvm // "java"
                + " -Dderby.tests.trace=true"
                // + " -Djava.security.policy=\"<NONE>\""  // Now using noSecurityManager decorator
                + " -classpath " + testingClassPath
                + " junit.textui.TestRunner"
                + " " + load //
                // + " org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationTestRun"
                ;
        /* END */
    }
    
    /* String results = */
    if ( testClientHost.equalsIgnoreCase("localhost") )
    {
        runUserCommandInThread(command,  testUser, dbSubPath,
                "runLoad["+dbSubPath+"] ");
    }
    else
    {
        runUserCommandInThreadRemotely(command,
                testClientHost, testUser, dbSubPath,
                "runLoad["+dbSubPath+"] ");
    }
    
}
 
Example 9
Source File: 919148_ReplicationRun_0_s.java    From gumtree-spoon-ast-diff with Apache License 2.0 4 votes vote down vote up
void stopServer(String serverVM, String serverVersion,
        String serverHost, int serverPort)
{
    util.DEBUG("");
    final String debugId = "stopServer@" + serverHost + ":" + serverPort + " ";
    util.DEBUG("+++ stopServer " + serverVM + " / " + serverVersion
            + " " + debugId);
    
    String serverJvm = BaseTestCase.getJavaExecutableName();
    String serverClassPath = serverVersion + FS+"derby.jar"
            + PS + serverVersion + FS+"derbynet.jar";
    if ( serverHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        serverClassPath = classPath;
    }
    
    String command = "shutdown";
    int port = serverPort;
    
    final String[] commandElements = {serverJvm
            , " -Dderby.infolog.append=true"
            , " -cp ", serverClassPath
            , " " + networkServerControl
            , " " + command
            , " -h " + serverHost // FIXME! interfacesToListenOn
            , " -p ", serverPort+""
            // , " " + securityOption
            };
    String[] envElements = {"CLASS_PATH="+serverClassPath
            , "PATH="+serverVM+FS+".."+FS+"bin"
            };
    if ( serverHost.equals("localhost") )
    {
        envElements =null;
    }
    
    String workingDirName = System.getProperty("user.dir"); // Means we will do the shutdown wherever we are
    util.DEBUG(debugId+"user.dir: " + workingDirName);
    
    String tmp ="";
    for ( int i=0;i<commandElements.length;i++)
    {tmp = tmp + commandElements[i];}
    util.DEBUG(debugId+"commandElements: " + tmp);
    
    final String fullCmd = tmp;
    tmp ="";
    if ( envElements != null )
    {
        for ( int i=0;i<envElements.length;i++)
        {tmp = tmp + envElements[i] + " ";}
    }
    util.DEBUG(debugId+"envElements: " + tmp);
    
    final File workingDir = new File(workingDirName);
    
    String shellCmd = null;
    
    if ( serverHost.equalsIgnoreCase("localhost") )
    {
        util.DEBUG(debugId+"Stopping server on localhost "+ serverHost);
        shellCmd = fullCmd;
    }
    else
    {
        util.DEBUG(debugId+"Stopping server on non-local host "+ serverHost);
        
        String[] shEnvElements = {"setenv CLASS_PATH "+serverClassPath
                , "setenv PATH "+serverVM+FS+".."+FS+"bin:${PATH}"
                };
        String shellEnv = "";
        for ( int i=0;i<shEnvElements.length;i++)
        {shellEnv = shellEnv + shEnvElements[i] + ";";}
        util.DEBUG(debugId+"shellEnv: " + shellEnv);
        
        shellCmd = "pwd;" + shellEnv + ";"  + fullCmd;
        util.DEBUG(debugId+"shellCmd: " + shellCmd);
        
        shellCmd = remoteShell + " "
                + "-l " + testUser + " -n " + serverHost + " "
                + shellCmd;
    }
    
    {
        final String localCommand = shellCmd;
        util.DEBUG(debugId+"localCommand: " + localCommand);
        
        try
        {
            Process proc = Runtime.getRuntime().exec(localCommand,envElements,workingDir);
            processDEBUGOutput(debugId+"pDo ", proc);
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }
    
    util.DEBUG(debugId+"--- stopServer ");
    util.DEBUG("");
    
}
 
Example 10
Source File: 919148_ReplicationRun_0_t.java    From coming with MIT License 4 votes vote down vote up
void runTest(String replicationTest,
        String clientVM,
        String testClientHost,
        String serverHost, int serverPort,
        String dbName)
        throws Exception
{
    util.DEBUG("runTest(" + replicationTest
            + ", " + clientVM
            + ", " + testClientHost
            + ", " + serverHost
            + ", " + serverPort
            + ", " + dbName
            + ") "
            );
    
    if ( replicationTest == null ) 
    {
        util.DEBUG("No replicationTest specified. Exitting.");
        return;
    } 
    
    if ( simpleLoad )
    {
        _testInsertUpdateDeleteOnMaster(serverHost, serverPort,
            dbName, simpleLoadTuples);
        return;
    }
    
    String URL = masterURL(dbName);
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbyTesting.jar"
            + PS + derbyVersion +FS+ "derbytools.jar";
    String testingClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbynet.jar" // WHY IS THIS NEEDED?
            // See TestConfiguration: startNetworkServer and stopNetworkServer
            + PS + test_jars;
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = null;
    
    util.DEBUG("replicationTest: " + replicationTest);
    if ( replicationTest.indexOf(".sql") >= 0 )
    {
        command = clientJvm
                + " -Dij.driver=" + DRIVER_CLASS_NAME
                + " -Dij.connection.startTestClient=" + URL
                + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
                + " " + replicationTest
                ;
    }
    else
    { // JUnit
        if ( testClientHost.equals("localhost") )
        {
            testingClassPath = classPath; // Using the complete classpath
        }
        command = clientJvm
                + " -Dderby.tests.trace=true"
                // + " -Djava.security.policy=\"<NONE>\"" // Now using noSecurityManager decorator
                + " -Dtest.serverHost=" + serverHost  // Tell the test what server
                + " -Dtest.serverPort=" + serverPort  // and port to connect to.
                + " -Dtest.inserts=" + tuplesToInsertPerf // for SimplePerfTest
                + " -Dtest.commitFreq=" +  commitFreq // for SimplePerfTest
                + " -classpath " + testingClassPath
                + " junit.textui.TestRunner"
                + " " + replicationTest
                ;
    }
    
    long startTime = System.currentTimeMillis();
    String results = null;
    if ( testClientHost.equalsIgnoreCase("localhost") )
    {
        runUserCommandLocally(command, userDir+FS+masterDbSubPath, "runTest ");
    }
    else
    {
        command = "cd "+ userDir +";" // Must be positioned where the properties file is located.
                + command;
        results = runUserCommandRemotely(command, testClientHost, testUser,
                "runTest ");
    }
    util.DEBUG("Time: " + (System.currentTimeMillis() - startTime) / 1000.0);
    
}
 
Example 11
Source File: 919148_ReplicationRun_0_t.java    From gumtree-spoon-ast-diff with Apache License 2.0 4 votes vote down vote up
void runTestOnSlave(String replicationTest,
        String clientVM,
        String testClientHost,
        String serverHost, int serverPort,
        String dbName)
        throws Exception
{
    util.DEBUG("runTestOnSlave(" + replicationTest
            + ", " + clientVM
            + ", " + testClientHost
            + ", " + serverHost
            + ", " + serverPort
            + ", " + dbName
            + ") "
            );
    
    
    String URL = slaveURL(dbName);
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbyTesting.jar"
            + PS + derbyVersion +FS+ "derbytools.jar";
    String testingClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbynet.jar" // WHY IS THIS NEEDED?
            // See TestConfiguration: startNetworkServer and stopNetworkServer
            + PS + test_jars;
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = null;
    
    if ( replicationTest == null ) 
    {
        util.DEBUG("No replicationTest specified. Exitting.");
        return;
    } 
    
    if ( serverHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
        testingClassPath = classPath;
    }
    util.DEBUG("replicationTest: " + replicationTest);
    if ( replicationTest.indexOf(".sql") >= 0 )
    {
        command = clientJvm
                + " -Dij.driver=" + DRIVER_CLASS_NAME
                + " -Dij.connection.startTestClient=" + URL
                + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
                + " " + replicationTest
                ;
    }
    else
    { // JUnit
        if ( testClientHost.equals("localhost") ) 
        {
            testingClassPath = classPath; // Using the complete classpath
        }
        command = clientJvm
                + " -Dderby.tests.trace=true"
                // + " -Djava.security.policy=\"<NONE>\""  // Now using noSecurityManager decorator
                + " -Dtest.serverHost=" + serverHost  // Tell the test what server
                + " -Dtest.serverPort=" + serverPort  // and port to connect to.
                + " -Dtest.inserts=" + tuplesToInsertPerf // for SimplePerfTest
                + " -Dtest.commitFreq=" +  commitFreq // for SimplePerfTest
                + " -classpath " + testingClassPath
                + " junit.textui.TestRunner"
                + " " + replicationTest
                ;
    }
    
    long startTime = System.currentTimeMillis();
    String results = null;
    if ( testClientHost.equalsIgnoreCase("localhost") )
    {
        runUserCommandLocally(command, userDir+FS+slaveDbSubPath, "runTestOnSlave ");
    }
    else
    {
        command = "cd "+ userDir +";" // Must be positioned where the properties file is located.
                + command;
        results = runUserCommandRemotely(command, testClientHost, testUser,
                "runTestOnSlave ");
    }
    util.DEBUG("Time: " + (System.currentTimeMillis() - startTime) / 1000.0);
    
}
 
Example 12
Source File: 919148_ReplicationRun_0_t.java    From gumtree-spoon-ast-diff with Apache License 2.0 4 votes vote down vote up
void startLoad(String load,
        String dbSubPath,
        String database,
        boolean existingDB,
        String testClientHost,
        String serverHost,
        int serverPort)
        throws Exception
{
    util.DEBUG("run load " + load
            + " on client " + testClientHost
            + " against server " + serverHost + ":" + serverPort
            + " using DB  " + database + "["+existingDB+"]"
            );
    if ( load == null )
    {
        util.DEBUG("No load supplied!");
        return;
    }
    if ( !existingDB )
    {
        // Create it!
        String URL = masterURL(database)
                +";create=true"; // Creating! No need for encryption here?
        String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
                + PS + derbyVersion +FS+ "derbyTesting.jar"
                + PS + derbyVersion +FS+ "derbytools.jar";
    if ( serverHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
    }
        String clientJvm = BaseTestCase.getJavaExecutableName();
        String command = "rm -rf /"+masterDatabasePath+FS+dbSubPath+FS+database+";" // FIXME! for slave load!
                + clientJvm // "java"
                + " -Dij.driver=" + DRIVER_CLASS_NAME
                + " -Dij.connection.create"+database+"=\"" + URL + "\""
                + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
                + " " + sqlLoadInit // FIXME! Should be load specific!
                ;
        String results =
                runUserCommandRemotely(command,
                testClientHost,
                testUser,
                "Create_"+database);
        
    }
    
    // Must run in separate thread!:
    runLoad(load,
            jvmVersion,
            testClientHost,
            serverHost, serverPort,
            dbSubPath+FS+database);
    
    // FIXME! How to join and cleanup....
    
}
 
Example 13
Source File: 919148_ReplicationRun_0_t.java    From gumtree-spoon-ast-diff with Apache License 2.0 4 votes vote down vote up
private void runStateTest(String stateTest,
        String clientVM,
        String testClientHost,
        String masterHost, int masterPort, // serverHost?, serverPort?
        String dbSubPath) // FIXME? Should we allow extra URL options?
        throws Exception
{
    util.DEBUG("runStateTest(" + stateTest
            + ", " + clientVM
            + ", " + testClientHost
            + ", " + masterHost
            + ", " + masterPort
            + ", " + dbSubPath
            + ") "
            );
    
    
    String URL = masterLoadURL(dbSubPath);
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbyTesting.jar"
            // Needed for 'run resource 'createTestProcedures.subsql';' cases?
            // Nope? what is 'resource'?
            + PS + derbyVersion +FS+ "derbytools.jar";
    String testingClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbynet.jar" // WHY IS THIS NEEDED?
            // See TestConfiguration: startNetworkServer and stopNetworkServer
            + PS + test_jars;
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = null;
    
    if ( masterHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
        testingClassPath = classPath;
    }
    util.DEBUG("stateTest: " + stateTest);
    if ( stateTest.indexOf(".sql") >= 0 )
    {
        command = clientJvm 
                + " -Dij.driver=" + DRIVER_CLASS_NAME
                + " -Dij.connection.startTestClient=" + URL
                + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
                + " " + stateTest
                ;
    }
    else
    {
        /* BEGIN For junit: */
        command = "cd "+ userDir +";" // Must be positioned where the properties file is located.
                + clientJvm 
                + " -Dderby.tests.trace=true"
                // + " -Djava.security.policy=\"<NONE>\""  // Now using noSecurityManager decorator
                + " -classpath " + testingClassPath
                + " junit.textui.TestRunner"
                + " " + stateTest
                ;
        /* END */
    }
    
    /* String results = */
    runUserCommandRemotely(command,
            testClientHost, // masterHost,
            testUser,
            // dbSubPath,
            "runStateTest "); // ["+dbSubPath+"]
    
}
 
Example 14
Source File: 919148_ReplicationRun_0_s.java    From coming with MIT License 4 votes vote down vote up
private void startSlave_ij(String jvmVersion,
        String dbName,
        String slaveHost,  // Where the slave db is run.
        int slaveServerPort, // slave server interface accepting client requests
        
        String slaveReplInterface, // slaveHost,
        int slaveReplPort, // slavePort)
        
        String testClientHost)
        throws Exception
{
    
    String slaveClassPath = derbySlaveVersion +FS+ "derbynet.jar";
    if ( slaveHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        slaveClassPath = classPath;
    }
    String URL = slaveURL(dbName)
            +";startSlave=true;slaveHost="+slaveReplInterface
            +";slavePort="+slaveReplPort;
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbytools.jar";
    if ( slaveHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
    }
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = clientJvm // "java"
            + " -Dij.driver=" + DRIVER_CLASS_NAME
            + " -Dij.connection.startSlave=\"" + URL + "\""
            + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
            + " " + "/home/os136789/Replication/testing/exit.sql"
            ;
    
    // Execute the ij command on the testClientHost as testUser
    /* String results =
            runUserCommandRemotely(command,
            testClientHost,
            testUser,
            "startSlave_ij ");
    util.DEBUG(results); */
    // 618220 + failover_impl_3205_v3.diff + derby-3361-1a.diff :
    runUserCommandInThreadRemotely(command,
            testClientHost,
            testUser,
            slaveDbSubPath+FS+dbName,
            "startSlave_ij ");
    
}
 
Example 15
Source File: 919148_ReplicationRun_0_s.java    From gumtree-spoon-ast-diff with Apache License 2.0 4 votes vote down vote up
private void stopMaster_ij(String jvmVersion,
        String dbName,
        String masterHost,  // Where the master db is run.
        int masterServerPort,
        
        String testClientHost)
        throws Exception
{
    
    String masterClassPath = derbyMasterVersion +FS+ "derbynet.jar";
    if ( masterHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        masterClassPath = classPath;
    }
            
    String URL = masterURL(dbName)
            +";stopMaster=true"; 
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbytools.jar";
    if ( masterHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
    }
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = clientJvm // "java"
            + " -Dij.driver=" + DRIVER_CLASS_NAME
            + " -Dij.connection.stopMaster=\"" + URL + "\""
            + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
            + " " + "/home/os136789/Replication/testing/exit.sql"
            ;
    
    // Execute the ij command on the testClientHost as testUser
    String results =
            runUserCommandRemotely(command,
            testClientHost,
            testUser,
            "stopMaster_ij ");
    util.DEBUG(results);
}
 
Example 16
Source File: 919148_ReplicationRun_0_s.java    From coming with MIT License 4 votes vote down vote up
private void startMaster_ij(String dbName,
        String masterHost,
        int masterServerPort,  // Where the master db is run.
        String slaveReplInterface, // master server interface accepting client requests
        
        int slaveReplPort, // slaveHost,
        String testClientHost)
        throws Exception
{
    
    String masterClassPath = derbyMasterVersion +FS+ "derbynet.jar";
    if ( masterHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        masterClassPath = classPath;
    }
            
    String URL = masterURL(dbName)
            +";startMaster=true;slaveHost="+slaveReplInterface
            +";slavePort="+slaveReplPort;
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbytools.jar";
    if ( masterHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
    }
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = clientJvm // "java"
            + " -Dij.driver=" + DRIVER_CLASS_NAME
            + " -Dij.connection.startMaster=\"" + URL + "\""
            + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
            + " " + "/home/os136789/Replication/testing/exit.sql"
            ;
    
    // Execute the ij command on the testClientHost as testUser
    String results =
            runUserCommandRemotely(command,
            testClientHost,
            testUser,
            "startMaster_ij ");
    util.DEBUG(results);
}
 
Example 17
Source File: 919148_ReplicationRun_0_t.java    From coming with MIT License 4 votes vote down vote up
void startLoad(String load,
        String dbSubPath,
        String database,
        boolean existingDB,
        String testClientHost,
        String serverHost,
        int serverPort)
        throws Exception
{
    util.DEBUG("run load " + load
            + " on client " + testClientHost
            + " against server " + serverHost + ":" + serverPort
            + " using DB  " + database + "["+existingDB+"]"
            );
    if ( load == null )
    {
        util.DEBUG("No load supplied!");
        return;
    }
    if ( !existingDB )
    {
        // Create it!
        String URL = masterURL(database)
                +";create=true"; // Creating! No need for encryption here?
        String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
                + PS + derbyVersion +FS+ "derbyTesting.jar"
                + PS + derbyVersion +FS+ "derbytools.jar";
    if ( serverHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
    }
        String clientJvm = BaseTestCase.getJavaExecutableName();
        String command = "rm -rf /"+masterDatabasePath+FS+dbSubPath+FS+database+";" // FIXME! for slave load!
                + clientJvm // "java"
                + " -Dij.driver=" + DRIVER_CLASS_NAME
                + " -Dij.connection.create"+database+"=\"" + URL + "\""
                + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
                + " " + sqlLoadInit // FIXME! Should be load specific!
                ;
        String results =
                runUserCommandRemotely(command,
                testClientHost,
                testUser,
                "Create_"+database);
        
    }
    
    // Must run in separate thread!:
    runLoad(load,
            jvmVersion,
            testClientHost,
            serverHost, serverPort,
            dbSubPath+FS+database);
    
    // FIXME! How to join and cleanup....
    
}
 
Example 18
Source File: 919148_ReplicationRun_0_s.java    From gumtree-spoon-ast-diff with Apache License 2.0 4 votes vote down vote up
void runTestOnSlave(String replicationTest,
        String clientVM,
        String testClientHost,
        String serverHost, int serverPort,
        String dbName)
        throws Exception
{
    util.DEBUG("runTestOnSlave(" + replicationTest
            + ", " + clientVM
            + ", " + testClientHost
            + ", " + serverHost
            + ", " + serverPort
            + ", " + dbName
            + ") "
            );
    
    
    String URL = slaveURL(dbName);
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbyTesting.jar"
            + PS + derbyVersion +FS+ "derbytools.jar";
    String testingClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbynet.jar" // WHY IS THIS NEEDED?
            // See TestConfiguration: startNetworkServer and stopNetworkServer
            + PS + test_jars;
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = null;
    
    if ( replicationTest == null ) 
    {
        util.DEBUG("No replicationTest specified. Exitting.");
        return;
    } 
    
    if ( serverHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
        testingClassPath = classPath;
    }
    util.DEBUG("replicationTest: " + replicationTest);
    if ( replicationTest.indexOf(".sql") >= 0 )
    {
        command = clientJvm
                + " -Dij.driver=" + DRIVER_CLASS_NAME
                + " -Dij.connection.startTestClient=" + URL
                + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
                + " " + replicationTest
                ;
    }
    else
    { // JUnit
        if ( testClientHost.equals("localhost") ) 
        {
            testingClassPath = classPath; // Using the complete classpath
        }
        command = clientJvm
                + " -Dderby.tests.trace=true"
                // + " -Djava.security.policy=\"<NONE>\""  // Now using noSecurityManager decorator
                + " -Dtest.serverHost=" + serverHost  // Tell the test what server
                + " -Dtest.serverPort=" + serverPort  // and port to connect to.
                + " -Dtest.inserts=" + tuplesToInsertPerf // for SimplePerfTest
                + " -Dtest.commitFreq=" +  commitFreq // for SimplePerfTest
                + " -classpath " + testingClassPath
                + " junit.textui.TestRunner"
                + " " + replicationTest
                ;
    }
    
    long startTime = System.currentTimeMillis();
    String results = null;
    if ( testClientHost.equalsIgnoreCase("localhost") )
    {
        runUserCommandLocally(command, userDir+FS+slaveDbSubPath, "runTestOnSlave ");
    }
    else
    {
        command = "cd "+ userDir +";" // Must be positioned where the properties file is located.
                + command;
        results = runUserCommandRemotely(command, testClientHost, testUser,
                "runTestOnSlave ");
    }
    util.DEBUG("Time: " + (System.currentTimeMillis() - startTime) / 1000.0);
    
}
 
Example 19
Source File: 919148_ReplicationRun_0_s.java    From coming with MIT License 4 votes vote down vote up
private void runLoad(String load,
        String clientVM,
        String testClientHost,
        String masterHost, int masterPort,
        String dbSubPath) // FIXME? Should we allow extra URL options?
        throws Exception
{
    util.DEBUG("runLoad(" + load
            + ", " + clientVM
            + ", " + testClientHost
            + ", " + masterHost
            + ", " + masterPort
            + ", " + dbSubPath
            + ") "
            );
    
    
    String URL = masterLoadURL(dbSubPath);
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbyTesting.jar"
            // Needed for 'run resource 'createTestProcedures.subsql';' cases?
            // Nope? what is 'resource'?
            + PS + derbyVersion +FS+ "derbytools.jar";
    String testingClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbynet.jar" // WHY IS THIS NEEDED?
            // See TestConfiguration: startNetworkServer and stopNetworkServer
            + PS + test_jars;
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = null;
    
    if ( masterHost.equals("localhost") )
    { // Use full classpath when running locally. Can not vary server versions!
        ijClassPath = classPath;
        testingClassPath = classPath;
    }
    util.DEBUG("load: " + load);
    if ( load.indexOf(".sql") >= 0 )
    {
        command = clientJvm // "java"
                + " -Dij.driver=" + DRIVER_CLASS_NAME
                + " -Dij.connection.startTestClient=" + URL
                + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
                + " " + load
                ;
    }
    else
    {
        /* BEGIN For junit: */
        command = clientJvm // "java"
                + " -Dderby.tests.trace=true"
                // + " -Djava.security.policy=\"<NONE>\""  // Now using noSecurityManager decorator
                + " -classpath " + testingClassPath
                + " junit.textui.TestRunner"
                + " " + load //
                // + " org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationTestRun"
                ;
        /* END */
    }
    
    /* String results = */
    if ( testClientHost.equalsIgnoreCase("localhost") )
    {
        runUserCommandInThread(command,  testUser, dbSubPath,
                "runLoad["+dbSubPath+"] ");
    }
    else
    {
        runUserCommandInThreadRemotely(command,
                testClientHost, testUser, dbSubPath,
                "runLoad["+dbSubPath+"] ");
    }
    
}
 
Example 20
Source File: 919148_ReplicationRun_0_s.java    From gumtree-spoon-ast-diff with Apache License 2.0 4 votes vote down vote up
void runTest(String replicationTest,
        String clientVM,
        String testClientHost,
        String serverHost, int serverPort,
        String dbName)
        throws Exception
{
    util.DEBUG("runTest(" + replicationTest
            + ", " + clientVM
            + ", " + testClientHost
            + ", " + serverHost
            + ", " + serverPort
            + ", " + dbName
            + ") "
            );
    
    if ( replicationTest == null ) 
    {
        util.DEBUG("No replicationTest specified. Exitting.");
        return;
    } 
    
    if ( simpleLoad )
    {
        _testInsertUpdateDeleteOnMaster(serverHost, serverPort,
            dbName, simpleLoadTuples);
        return;
    }
    
    String URL = masterURL(dbName);
    String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbyTesting.jar"
            + PS + derbyVersion +FS+ "derbytools.jar";
    String testingClassPath = derbyVersion +FS+ "derbyclient.jar"
            + PS + derbyVersion +FS+ "derbynet.jar" // WHY IS THIS NEEDED?
            // See TestConfiguration: startNetworkServer and stopNetworkServer
            + PS + test_jars;
    
    String clientJvm = BaseTestCase.getJavaExecutableName();
    
    String command = null;
    
    util.DEBUG("replicationTest: " + replicationTest);
    if ( replicationTest.indexOf(".sql") >= 0 )
    {
        command = clientJvm
                + " -Dij.driver=" + DRIVER_CLASS_NAME
                + " -Dij.connection.startTestClient=" + URL
                + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
                + " " + replicationTest
                ;
    }
    else
    { // JUnit
        if ( testClientHost.equals("localhost") )
        {
            testingClassPath = classPath; // Using the complete classpath
        }
        command = clientJvm
                + " -Dderby.tests.trace=true"
                // + " -Djava.security.policy=\"<NONE>\"" // Now using noSecurityManager decorator
                + " -Dtest.serverHost=" + serverHost  // Tell the test what server
                + " -Dtest.serverPort=" + serverPort  // and port to connect to.
                + " -Dtest.inserts=" + tuplesToInsertPerf // for SimplePerfTest
                + " -Dtest.commitFreq=" +  commitFreq // for SimplePerfTest
                + " -classpath " + testingClassPath
                + " junit.textui.TestRunner"
                + " " + replicationTest
                ;
    }
    
    long startTime = System.currentTimeMillis();
    String results = null;
    if ( testClientHost.equalsIgnoreCase("localhost") )
    {
        runUserCommandLocally(command, userDir+FS+masterDbSubPath, "runTest ");
    }
    else
    {
        command = "cd "+ userDir +";" // Must be positioned where the properties file is located.
                + command;
        results = runUserCommandRemotely(command, testClientHost, testUser,
                "runTest ");
    }
    util.DEBUG("Time: " + (System.currentTimeMillis() - startTime) / 1000.0);
    
}