db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r799091 - in /db/derby/code/branches/10.5: ./ java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/
Date Wed, 29 Jul 2009 21:42:54 GMT
Author: dag
Date: Wed Jul 29 21:42:54 2009
New Revision: 799091

URL: http://svn.apache.org/viewvc?rev=799091&view=rev
Log:
DERBY-3921 Replication: Test replication of encrypted databases

Backported to 10.5 branch with:

svn merge -c 777105  https://svn.eu.apache.org/repos/asf/db/derby/code/trunk


Added:
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_1Indexing.java
      - copied unchanged from r777105, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_1Indexing.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p5.java
      - copied unchanged from r777105, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p5.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p6.java
      - copied unchanged from r777105, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p6.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_Encrypted_1.java
      - copied unchanged from r777105, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_Encrypted_1.java
Modified:
    db/derby/code/branches/10.5/   (props changed)
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 29 21:42:54 2009
@@ -1 +1 @@
-/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,779681,782991,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793588,794955,795166,796020,796027,797147
+/db/derby/code/trunk:769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434,793588,794955,795166,796020,796027,797147

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java?rev=799091&r1=799090&r2=799091&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
Wed Jul 29 21:42:54 2009
@@ -54,6 +54,10 @@
     
     static String userDir = null;
     
+    static String dataEncryption = null;
+      // Set to a legal encryption string to
+      // create or connect to an encrypted db.
+    
     static String masterServerHost = "localhost"; 
     static int masterServerPort = 1527; // .. default..
     static String slaveServerHost = "localhost";
@@ -72,6 +76,9 @@
     
     static boolean runUnReplicated = false;
     
+    static boolean simpleLoad = true;
+    static int simpleLoadTuples = 1000;
+    
     static int tuplesToInsertPerf = 10000;
     static int commitFreq = 0; // autocommit
     
@@ -134,6 +141,8 @@
     
     /** A Connection to the master database*/
     private Connection masterConn = null;
+    /** A Connection to the slave database*/
+    private Connection slaveConn = null;
     /** The exception thrown as a result of a startSlave connection attempt  */
     private volatile Exception startSlaveException = null;
 
@@ -172,6 +181,16 @@
         super.tearDown();
     }
     
+    String useEncryption(boolean create)
+    {
+        String encryptionString = "";
+        if ( dataEncryption != null)
+        {
+            if ( create ) encryptionString = ";dataEncryption=true";
+            encryptionString = encryptionString+";"+dataEncryption;
+        }
+        return encryptionString;
+    }
     
     //////////////////////////////////////////////////////////////
     ////
@@ -207,7 +226,8 @@
         String serverURL = "jdbc:derby:"
                 +"//"+serverHost+":"+serverPort+"/";
         String dbURL = serverURL
-                +fullDbPath;
+                +fullDbPath
+                +useEncryption(false);
         Connection conn = null;
         String lastmsg = null;
         long sleeptime = 200L;
@@ -266,6 +286,7 @@
             ds.setDatabaseName(fullDbPath);
             ds.setServerName(serverHost);
             ds.setPortNumber(serverPort);
+            ds.setConnectionAttributes(useEncryption(false));
             Connection conn = ds.getConnection();
             conn.close();
         }
@@ -294,6 +315,7 @@
                 ds.setDatabaseName(fullDbPath);
                 ds.setServerName(serverHost);
                 ds.setPortNumber(serverPort);
+                ds.setConnectionAttributes(useEncryption(false));
                 Connection conn = ds.getConnection();
                 util.DEBUG("Got connection after " 
                         + (count-1) +" * "+ sleepTime + " ms.");
@@ -327,6 +349,7 @@
                 ds.setDatabaseName(fullDbPath);
                 ds.setServerName(serverHost);
                 ds.setPortNumber(serverPort);
+                ds.setConnectionAttributes(useEncryption(false));
                 Connection conn = ds.getConnection();
                 // Should never get here!
                 conn.close();
@@ -370,7 +393,8 @@
                 +"//"+serverHost+":"+serverPort+"/";
         String dbURL = serverURL
                 +dbPath
-                +FS+replicatedDb;
+                +FS+replicatedDb
+                +useEncryption(false);
         util.DEBUG("**** DriverManager.getConnection(\"" + dbURL+";shutdown=true\");");
 
         try{
@@ -407,11 +431,20 @@
                 + ") "
                 );
         
+        if ( replicationTest == null ) 
+        {
+            util.DEBUG("No replicationTest specified. Exitting.");
+            return;
+        } 
+        
+        if ( simpleLoad )
+        {
+            _testInsertUpdateDeleteOnMaster(serverHost, serverPort,
+                dbName, simpleLoadTuples);
+            return;
+        }
         
-        String URL = DB_PROTOCOL
-                +"://"+serverHost
-                +":"+serverPort+"/"
-                +masterDatabasePath+FS+masterDbSubPath+FS+dbName;
+        String URL = masterURL(dbName);
         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
                 + PS + derbyVersion +FS+ "derbyTesting.jar"
                 + PS + derbyVersion +FS+ "derbytools.jar";
@@ -424,12 +457,6 @@
         
         String command = null;
         
-        if ( replicationTest == null ) 
-        {
-            util.DEBUG("No replicationTest specified. Exitting.");
-            return;
-        } 
-        
         util.DEBUG("replicationTest: " + replicationTest);
         if ( replicationTest.indexOf(".sql") >= 0 )
         {
@@ -492,10 +519,7 @@
                 );
         
         
-        String URL = DB_PROTOCOL
-                +"://"+serverHost
-                +":"+serverPort+"/"
-                +slaveDatabasePath+FS+slaveDbSubPath+FS+dbName;
+        String URL = slaveURL(dbName);
         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
                 + PS + derbyVersion +FS+ "derbyTesting.jar"
                 + PS + derbyVersion +FS+ "derbytools.jar";
@@ -588,10 +612,7 @@
                 );
         
         
-        String URL = DB_PROTOCOL
-                +"://"+masterHost
-                +":"+masterPort+"/"
-                +masterDatabasePath+ /* FS+masterDbSubPath+ */ FS+dbSubPath;
+        String URL = masterLoadURL(dbSubPath);
         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
                 + PS + derbyVersion +FS+ "derbyTesting.jar"
                 // Needed for 'run resource 'createTestProcedures.subsql';' cases?
@@ -667,10 +688,7 @@
                 );
         
         
-        String URL = DB_PROTOCOL
-                +"://"+masterHost
-                +":"+masterPort+"/"
-                +masterDatabasePath+ /* FS+masterDbSubPath+ */ FS+dbSubPath;
+        String URL = masterLoadURL(dbSubPath);
         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
                 + PS + derbyVersion +FS+ "derbyTesting.jar"
                 // Needed for 'run resource 'createTestProcedures.subsql';' cases?
@@ -733,11 +751,9 @@
     {
         // Should just do a "connect....;create=true" here, instead of copying in initMaster.
         
-        String URL = DB_PROTOCOL
-                +"://"+masterHost
-                +":"+masterServerPort+"/"
-                +masterDatabasePath+FS+masterDbSubPath+FS+dbName
-                +";create=true";
+        String URL = masterURL(dbName)
+                +";create=true"
+                +useEncryption(true);
 
         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
                 + PS + derbyVersion +FS+ "derbytools.jar";
@@ -748,13 +764,6 @@
         }
         String clientJvm = BaseTestCase.getJavaExecutableName();
         
-        String command = clientJvm 
-                + " -Dij.driver=" + DRIVER_CLASS_NAME
-                + " -Dij.connection.createMaster=\"" + URL + "\""
-                + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
-                + " " + "/home/os136789/Replication/testing/exit.sql" // FIXME!!
-                ;
-        
         String results = null;
         if ( masterHost.equalsIgnoreCase("localhost") || localEnv )
         {
@@ -770,6 +779,13 @@
         else
         {
         // Execute the ij command on the testClientHost as testUser
+            String command = clientJvm 
+                + " -Dij.driver=" + DRIVER_CLASS_NAME
+                + " -Dij.connection.createMaster=\"" + URL + "\""
+                + " -classpath " + ijClassPath + " org.apache.derby.tools.ij"
+                + " " + "exit.sql" // FIXME!!
+                ;
+        
             results =
                 runUserCommandRemotely(command,
                 testClientHost,
@@ -783,10 +799,7 @@
         util.DEBUG("************************** DERBY-???? Preliminary needs to freeze db
before copying to slave and setting replication mode.");
         if ( masterServerHost.equalsIgnoreCase("localhost") || localEnv )
         {
-             URL = DB_PROTOCOL
-                +"://"+masterServerHost
-                +":"+masterServerPort+"/"
-                +masterDatabasePath+FS+masterDbSubPath+FS+dbName;
+             URL = masterURL(dbName);
             Class.forName(DRIVER_CLASS_NAME); // Needed when running from classes!
             util.DEBUG("bootMasterDatabase getConnection("+URL+")");
             Connection conn = DriverManager.getConnection(URL);
@@ -812,6 +825,7 @@
                     masterServerHost, masterServerPort,
                     dbSubPath+FS+dbName);
         }
+        util.DEBUG("bootMasterDatabase done.");
     }
 
     /**
@@ -913,10 +927,7 @@
             masterClassPath = classPath;
         }
                 
-        String URL = DB_PROTOCOL
-                +"://"+masterHost
-                +":"+masterServerPort+"/"
-                +masterDatabasePath+FS+masterDbSubPath+FS+dbName
+        String URL = masterURL(dbName)
                 +";startMaster=true;slaveHost="+slaveReplInterface
                 +";slavePort="+slaveReplPort;
         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
@@ -952,10 +963,7 @@
             throws Exception
     {
         
-        String URL = DB_PROTOCOL
-                +"://"+masterHost
-                +":"+masterServerPort+"/"
-                +masterDatabasePath+FS+masterDbSubPath+FS+dbName
+        String URL = masterURL(dbName)
                 +";startMaster=true;slaveHost="+slaveReplInterface
                 +";slavePort="+slaveReplPort;
                 
@@ -979,7 +987,8 @@
                     ds.setPortNumber(masterServerPort);
                     ds.setConnectionAttributes("startMaster=true"
                             +";slaveHost="+slaveReplInterface
-                            +";slavePort="+slaveReplPort);
+                            +";slavePort="+slaveReplPort
+                            +useEncryption(false));
                     conn = ds.getConnection();
                     
                     done = true;
@@ -1026,10 +1035,7 @@
      */
     protected Connection getMasterConnection() {
         if (masterConn == null) {
-            String url = DB_PROTOCOL + "://" + masterServerHost + ":" +
-                         masterServerPort + "/" +
-                         masterDatabasePath + FS + masterDbSubPath + FS +
-                         replicatedDb;
+            String url = masterURL(replicatedDb);
             try {
                 masterConn = DriverManager.getConnection(url);
             } catch (SQLException sqle) {
@@ -1038,6 +1044,22 @@
         }
         return masterConn;
     }
+    
+    /**
+     * Get a connection to the slave database.
+     * @return A connection to the slave database
+     */
+    protected Connection getSlaveConnection() {
+        if (slaveConn == null) {
+            String url = slaveURL(replicatedDb);
+            try {
+                slaveConn = DriverManager.getConnection(url);
+            } catch (SQLException sqle) {
+                fail("Could not connect to slave database");
+            }
+        }
+        return slaveConn;
+    }
 
 
     /**
@@ -1053,6 +1075,18 @@
     }
 
     /**
+     * Execute SQL on the slave database through a Statement
+     * @param sql The sql that should be executed on the slave database
+     * @throws java.sql.SQLException thrown if an error occured while
+     * executing the sql
+     */
+    protected void executeOnSlave(String sql) throws SQLException {
+         Statement s = getSlaveConnection().createStatement();
+         s.execute(sql);
+         s.close();
+    }
+
+    /**
      * Set slave db in replication slave mode
      */
     void startSlave(String clientVM,
@@ -1147,10 +1181,7 @@
         { // Use full classpath when running locally. Can not vary server versions!
             slaveClassPath = classPath;
         }
-        String URL = DB_PROTOCOL
-                +"://"+slaveHost
-                +":"+slaveServerPort+"/"
-                +slaveDatabasePath+FS+slaveDbSubPath+FS+dbName
+        String URL = slaveURL(dbName)
                 +";startSlave=true;slaveHost="+slaveReplInterface
                 +";slavePort="+slaveReplPort;
         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
@@ -1191,10 +1222,7 @@
             int slaveReplPort)
             throws Exception
     {
-        final String URL = DB_PROTOCOL
-                +"://"+slaveHost
-                +":"+slaveServerPort+"/"
-                +slaveDatabasePath+FS+slaveDbSubPath+FS+dbName
+        final String URL = slaveURL(dbName)
                 +";startSlave=true;slaveHost="+slaveReplInterface
                 +";slavePort="+slaveReplPort;
         
@@ -1205,7 +1233,8 @@
             final int fSlaveServerPort = slaveServerPort;
             final String fConnAttrs = "startSlave=true"
                                 +";slaveHost="+slaveReplInterface
-                                +";slavePort="+slaveReplPort;
+                                +";slavePort="+slaveReplPort
+                                +useEncryption(false);
             Thread connThread = new Thread(
                     new Runnable()
             {
@@ -1260,10 +1289,7 @@
         
         String masterClassPath = derbyMasterVersion +FS+ "derbynet.jar";
                 
-        String URL = DB_PROTOCOL
-                +"://"+slaveHost
-                +":"+slaveServerPort+"/"
-                +slaveDatabasePath+FS+slaveDbSubPath+FS+dbName
+        String URL = slaveURL(dbName)
                 +";stopSlave=true";
         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
                 + PS + derbyVersion +FS+ "derbytools.jar";
@@ -1320,10 +1346,7 @@
         
         String masterClassPath = derbyMasterVersion +FS+ "derbynet.jar";
                 
-        String URL = DB_PROTOCOL
-                +"://"+host
-                +":"+serverPort+"/"
-                +dbPath+FS+dbSubPath+FS+dbName
+        String URL = masterURL(dbName)
                 +";failover=true";
         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
                 + PS + derbyVersion +FS+ "derbytools.jar";
@@ -1354,10 +1377,7 @@
             int serverPort)
             throws Exception
     {
-        String URL = DB_PROTOCOL
-                +"://"+host
-                +":"+serverPort+"/"
-                +dbPath+FS+dbSubPath+FS+dbName
+        String URL = masterURL(dbName)
                 +";failover=true";
                
             util.DEBUG("failOver_direct getConnection("+URL+")");
@@ -1403,11 +1423,8 @@
             masterClassPath = classPath;
         }
                 
-        String URL = DB_PROTOCOL
-                +"://"+masterHost
-                +":"+masterServerPort+"/"
-                +masterDatabasePath+FS+masterDbSubPath+FS+dbName
-                +";stopSlave=true";
+        String URL = masterURL(dbName)
+                +";stopMaster=true"; 
         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
                 + PS + derbyVersion +FS+ "derbytools.jar";
         if ( masterHost.equals("localhost") )
@@ -1429,7 +1446,7 @@
                 runUserCommandRemotely(command,
                 testClientHost,
                 testUser,
-                "stopSlave_ij ");
+                "stopMaster_ij ");
         util.DEBUG(results);
     }
     
@@ -1476,7 +1493,7 @@
         util.DEBUG("xFindServerPID: " + pid);
         return pid;
     }
-    private void xStopServer(String serverHost, int serverPID)
+    void xStopServer(String serverHost, int serverPID)
     throws InterruptedException
     {
         if ( serverPID == -1 || serverPID == 0 )
@@ -1493,11 +1510,22 @@
     {
         util.DEBUG("BEGIN verifySlave "+slaveServerHost+":"
                 +slaveServerPort+"/"+slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb);
+        
+        if ( (replicationTest != null) // If 'replicationTest==null' no table was created/filled
+                && simpleLoad )
+        {
+            _verifyDatabase(slaveServerHost, slaveServerPort, 
+                    slaveDatabasePath+FS+slaveDbSubPath+FS+replicatedDb,
+                    simpleLoadTuples);
+            // return;
+        }
+
         ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
         ds.setDatabaseName(slaveDatabasePath + FS + slaveDbSubPath + FS +
                            replicatedDb);
         ds.setServerName(slaveServerHost);
         ds.setPortNumber(slaveServerPort);
+        ds.setConnectionAttributes(useEncryption(false));
         Connection conn = ds.getConnection();
             
         simpleVerify(conn);
@@ -1515,11 +1543,22 @@
     {
         util.DEBUG("BEGIN verifyMaster " + masterServerHost + ":"
                 +masterServerPort+"/"+masterDatabasePath+FS+masterDbSubPath+FS+replicatedDb);
+        
+        if ( (replicationTest != null)  // If 'replicationTest==null' no table was created/filled
+                && simpleLoad )
+        {
+            _verifyDatabase(masterServerHost, masterServerPort, 
+                    masterDatabasePath+FS+masterDbSubPath+FS+replicatedDb,
+                    simpleLoadTuples);
+            // return;
+        }
+
         ClientDataSource ds = new org.apache.derby.jdbc.ClientDataSource();
         ds.setDatabaseName(masterDatabasePath + FS + masterDbSubPath + FS +
                            replicatedDb);
         ds.setServerName(masterServerHost);
         ds.setPortNumber(masterServerPort);
+        ds.setConnectionAttributes(useEncryption(false));
         Connection conn = ds.getConnection();
             
         simpleVerify(conn);
@@ -1558,10 +1597,7 @@
                 serverHost,serverPort,
                 dbName);
         /*
-        String URL = DB_PROTOCOL
-                +"://"+serverHost
-                +":"+serverPort+"/"
-                +slaveDatabasePath+FS+slaveDbSubPath+FS+dbName;
+        String URL = slaveURL(dbName);
         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
                 + PS + derbyVersion +FS+ "derbytools.jar";
         
@@ -1608,10 +1644,7 @@
                 serverHost,serverPort,
                 dbName);
         /*
-        String URL = DB_PROTOCOL
-                +"://"+serverHost
-                +":"+serverPort+"/"
-                +masterDatabasePath+FS+masterDbSubPath+FS+dbName;
+        String URL = masterURL(dbName);
         String ijClassPath = derbyVersion +FS+ "derbyclient.jar"
                 + PS + derbyVersion +FS+ "derbytools.jar";
         
@@ -1664,7 +1697,7 @@
      */
     
     
-    private String runUserCommand(String command,
+    /* private */ String runUserCommand(String command,
             String testUser)
     {
         util.DEBUG("Execute '"+ command +"'");
@@ -2012,6 +2045,10 @@
         unFreezeDB = null;
         util.DEBUG("unFreezeDB: " + unFreezeDB);
         
+        simpleLoad = System.getProperty("derby.tests.replSimpleLoad", "true")
+                                                     .equalsIgnoreCase("true");
+        util.DEBUG("simpleLoad: " + simpleLoad);
+        
         /* Done in subclasses
         replicationTest = "org.apache.derbyTesting.functionTests.tests.replicationTests.ReplicationTestRun";
         util.DEBUG("replicationTest: " + replicationTest);
@@ -2771,11 +2808,8 @@
         if ( !existingDB )
         {
             // Create it!
-            String URL = DB_PROTOCOL
-                    +"://"+serverHost
-                    +":"+serverPort+"/"
-                    +masterDatabasePath+FS+dbSubPath+FS+database // FIXME! for slave load!
-                    +";create=true"; // Creating!
+            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";
@@ -2810,6 +2844,59 @@
         
     }
 
+    void makeReadyForReplication()
+        throws Exception
+    {   // Replace the following code in all tests with a call to makeReadyForReplication()!
+        cleanAllTestHosts();
+        
+        initEnvironment();
+        
+        initMaster(masterServerHost,
+                replicatedDb);
+        
+        masterServer = startServer(masterJvmVersion, derbyMasterVersion,
+                masterServerHost,
+                ALL_INTERFACES,
+                masterServerPort,
+                masterDbSubPath);
+        
+        slaveServer = startServer(slaveJvmVersion, derbySlaveVersion,
+                slaveServerHost,
+                ALL_INTERFACES,
+                slaveServerPort,
+                slaveDbSubPath);
+        
+        startServerMonitor(slaveServerHost);
+        
+        bootMasterDatabase(jvmVersion,
+                masterDatabasePath +FS+ masterDbSubPath,
+                replicatedDb,
+                masterServerHost,
+                masterServerPort,
+                null // bootLoad, // The "test" to start when booting db.
+                );
+        
+        initSlave(slaveServerHost,
+                jvmVersion,
+                replicatedDb);
+        
+        startSlave(jvmVersion, replicatedDb,
+                slaveServerHost,
+                slaveServerPort,
+                slaveServerHost,
+                slaveReplPort,
+                testClientHost);
+        
+        startMaster(jvmVersion, replicatedDb,
+                masterServerHost,
+                masterServerPort,
+                masterServerHost,
+                slaveServerPort,
+                slaveServerHost,
+                slaveReplPort);
+        
+    }
+    
     ///////////////////////////////////////////////////////////////////////////
     /* Remove any servers or tests still running
      */
@@ -3319,6 +3406,7 @@
         ds.setDatabaseName(dbPath);
         ds.setServerName(serverHost);
         ds.setPortNumber(serverPort);
+        ds.setConnectionAttributes(useEncryption(false));
         Connection conn = ds.getConnection();
         
         PreparedStatement ps = conn.prepareStatement("create table t(i integer primary key,
s varchar(64))");
@@ -3349,6 +3437,7 @@
         ds.setDatabaseName(dbPath);
         ds.setServerName(serverHost);
         ds.setPortNumber(serverPort);
+        ds.setConnectionAttributes(useEncryption(false));
         Connection conn = ds.getConnection();
         
         _verify(conn,_noTuplesInserted);
@@ -3372,4 +3461,43 @@
         assertEquals("Expected " +(_noTuplesInserted-1) +" max, got " + max +".",
                      _noTuplesInserted - 1, max);
     }
+    
+    Connection getConnection(String serverHost, int serverPort,
+            String databasePath, String dbSubPath, String replicatedDb)
+        throws SQLException
+    {
+        String db = databasePath +FS+dbSubPath +FS+ replicatedDb;
+        String connectionURL = "jdbc:derby:"  
+                + "//" + serverHost + ":" + serverPort + "/"
+                + db;
+        util.DEBUG(connectionURL);
+        return DriverManager.getConnection(connectionURL);
+    }
+    
+    String masterURL(String dbName)
+    {
+        return DB_PROTOCOL
+                +"://"+masterServerHost
+                +":"+masterServerPort+"/"
+                +masterDatabasePath+FS+masterDbSubPath+FS+dbName
+                +useEncryption(false);
+    }
+    String masterLoadURL(String dbSubPath)
+    {
+        return DB_PROTOCOL
+                +"://"+masterServerHost
+                +":"+masterServerPort+"/"
+                +masterDatabasePath+FS+dbSubPath
+                +useEncryption(false);
+    }
+
+    String slaveURL(String dbName)
+    {
+        return DB_PROTOCOL
+                +"://"+slaveServerHost
+                +":"+slaveServerPort+"/"
+                +slaveDatabasePath+FS+slaveDbSubPath+FS+dbName
+                +useEncryption(false);
+    }
+
 }

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java?rev=799091&r1=799090&r2=799091&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local.java
Wed Jul 29 21:42:54 2009
@@ -46,16 +46,6 @@
         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");
@@ -77,7 +67,13 @@
     ////
     //////////////////////////////////////////////////////////////
     
-    public void testReplication_Local_existingTestsAsReplLoad()
+    /**
+     * Test the "normal" replication scenario:
+     * Load on the master db while replicating to slave db,
+     * then verify that slave db is correct after failover.
+     * @throws java.lang.Exception
+     */
+    public void testReplication_Local_TestStraightReplication()
     throws Exception
     {
         cleanAllTestHosts();

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java?rev=799091&r1=799090&r2=799091&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3.java
Wed Jul 29 21:42:54 2009
@@ -26,9 +26,9 @@
 
 
 /**
- * Run a replication test on localhost
- * by using default values for master and slave hosts,
- * and master and slave ports.
+ * Defining startSlave, stopmaster, stopSlave and
+ * failOver methods returning SQLException for
+ * negative testing (ReplicationRun_Local_3 set of tests).
  * 
  */
 
@@ -44,16 +44,6 @@
         super(testcaseName);
     }
     
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-    }
-    
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-    }
-        
     //////////////////////////////////////////////////////////////
     ////
     //// The replication test framework (testReplication()):
@@ -73,7 +63,8 @@
         ds.setDatabaseName(dbPath);
         ds.setServerName(serverHost);
         ds.setPortNumber(serverPort);
-        ds.setConnectionAttributes("failover=true");
+        ds.setConnectionAttributes("failover=true"
+                +useEncryption(false));
         try {
             Connection conn = ds.getConnection(); // 
             conn.close();
@@ -96,7 +87,8 @@
         ds.setDatabaseName(dbPath);
         ds.setServerName(serverHost);
         ds.setPortNumber(serverPort);
-        ds.setConnectionAttributes("startSlave=true;create=true");
+        ds.setConnectionAttributes("startSlave=true;create=true"
+                +useEncryption(true));
         try {
             Connection conn = ds.getConnection(); // XRE10 - REPLICATION_CONFLICTING_ATTRIBUTES
             conn.close();
@@ -113,7 +105,8 @@
         ds.setDatabaseName(dbPath);
         ds.setServerName(masterServerHost);
         ds.setPortNumber(masterServerPort);
-        ds.setConnectionAttributes("stopMaster=true");
+        ds.setConnectionAttributes("stopMaster=true"
+                +useEncryption(false));
         try {
             Connection conn = ds.getConnection(); // 
             conn.close();
@@ -133,7 +126,8 @@
         ds.setDatabaseName(dbPath);
         ds.setServerName(slaveServerHost);
         ds.setPortNumber(slaveServerPort);
-        ds.setConnectionAttributes("stopSlave=true");
+        ds.setConnectionAttributes("stopSlave=true"
+                +useEncryption(false));
         try {
             Connection conn = ds.getConnection();
             conn.close();

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java?rev=799091&r1=799090&r2=799091&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p1.java
Wed Jul 29 21:42:54 2009
@@ -29,6 +29,12 @@
  * Run a replication test on localhost
  * by using default values for master and slave hosts,
  * and master and slave ports.
+ * Test that
+ * - stopSlave is not accepted on replicating slave,
+ * - stopSlave is not accepted on replicating master,
+ * - stopMaster is accepted on replicating master,
+ * - stopSlave is not accepted on non-replicating slave host,
+ * - failOver is not accepted on non-replicating master host.
  * 
  */
 
@@ -44,16 +50,6 @@
         super(testcaseName);
     }
     
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-    }
-    
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-    }
-    
     public static Test suite()
     {
         TestSuite suite = new TestSuite("ReplicationRun_Local_3_p1 Suite");
@@ -134,7 +130,8 @@
                 slaveServerHost, // for slaveReplInterface
                 slaveReplPort);
         
-        runTest(null, // Returns immediatly if replicationTest is null.
+        replicationTest = null; // Used as a flag to verifyMaster and verifySlave!
+        runTest(replicationTest, // Returns immediatly if replicationTest is null.
                 jvmVersion,
                 testClientHost,
                 masterServerHost, masterServerPort,

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java?rev=799091&r1=799090&r2=799091&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p3.java
Wed Jul 29 21:42:54 2009
@@ -31,6 +31,7 @@
  * Run a replication test on localhost
  * by using default values for master and slave hosts,
  * and master and slave ports.
+ * Verify that a second failover is not accepted.
  * 
  */
 
@@ -50,16 +51,6 @@
         super(testcaseName);
     }
     
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-    }
-    
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-    }
-    
     public static Test suite()
     {
         TestSuite suite = new TestSuite("ReplicationRun_Local_3_p3 Suite");
@@ -81,6 +72,10 @@
     ////
     //////////////////////////////////////////////////////////////
     
+    /**
+     * Verify that a second failover is not accepted.
+     * @throws java.lang.Exception
+     */
     public void testReplication_Local_3_p3_StateNegativeTests()
     throws Exception
     {
@@ -138,7 +133,8 @@
                 slaveServerHost, // for slaveReplInterface
                 slaveReplPort);
         
-        runTest(null, // Returns immediatly if replicationTest is null.
+        replicationTest = null; // Used as a flag to verifyMaster and verifySlave!
+        runTest(replicationTest, // Returns immediatly if replicationTest is null.
                 jvmVersion,
                 testClientHost,
                 masterServerHost, masterServerPort,

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java?rev=799091&r1=799090&r2=799091&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_3_p4.java
Wed Jul 29 21:42:54 2009
@@ -29,9 +29,8 @@
 
 
 /**
- * Run a replication test on localhost
- * by using default values for master and slave hosts,
- * and master and slave ports.
+ * Verify that "internal_stopslave=true" is
+ * NOT accepted as user supplied connection attr.
  * 
  */
 
@@ -47,16 +46,6 @@
         super(testcaseName);
     }
     
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-    }
-    
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-    }
-    
     public static Test suite()
     {
         TestSuite suite = new TestSuite("ReplicationRun_Local_3_p4 Suite");
@@ -78,6 +67,12 @@
     ////
     //////////////////////////////////////////////////////////////
     
+    /**
+     * Test to verify that "internal_stopslave=true" is
+     * NOT accepted as connection attr. on the slave.
+     * "internal_stopslave=true" is for internal use only.
+     * @throws java.lang.Exception
+     */
     public void testReplication_Local_3_p4_StateNegativeTests()
     throws Exception
     {
@@ -129,8 +124,8 @@
                 slaveServerHost, // for slaveReplInterface
                 slaveReplPort);
         
-        
-        runTest(null, // Returns immediatly if replicationTest is null.
+        replicationTest = null; // Used as a flag to verifyMaster and verifySlave!
+        runTest(replicationTest, // Returns immediatly if replicationTest is null.
                 jvmVersion,
                 testClientHost,
                 masterServerHost, masterServerPort,
@@ -183,6 +178,7 @@
         ds.setDatabaseName(dbPath);
         ds.setServerName(slaveServerHost);
         ds.setPortNumber(slaveServerPort);
+        ds.setConnectionAttributes(useEncryption(false));
         try {
             Connection conn = ds.getConnection(); // 
             conn.close();
@@ -201,7 +197,8 @@
         ds.setDatabaseName(dbPath);
         ds.setServerName(slaveServerHost);
         ds.setPortNumber(slaveServerPort);
-        ds.setConnectionAttributes("internal_stopslave=true");
+        ds.setConnectionAttributes("internal_stopslave=true"
+                +useEncryption(false));
         try {
             Connection conn = ds.getConnection(); // 
             conn.close();

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java?rev=799091&r1=799090&r2=799091&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun_Local_StateTest_part2.java
Wed Jul 29 21:42:54 2009
@@ -49,16 +49,6 @@
         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_StateTest_part2 Suite");
@@ -68,6 +58,18 @@
         return SecurityManagerSetup.noSecurityManager(suite);
     }
         
+    /**
+     * Verify that correct response to replication "commands":
+     * startSlave, startMaster, stopSlave, stopMaster and failOver,
+     * are given when the replicating database is in the following states:
+     * Failover has been performed and 
+     * - slave db has not been shut down,
+     * - slave db has been shut down,
+     * - slave server has been stopped,
+     * - master db has been shut down,
+     * - master server has been stopped.
+     * @throws java.lang.Exception
+     */
     public void testReplication_Local_StateTest_part2()
     throws Exception
     {
@@ -203,47 +205,47 @@
         
         // Tests against slave:
         assertException(
-                startSlave(slaveServerHost,slaveServerPort,
+                _startSlave(slaveServerHost,slaveServerPort,
                     slaveDatabasePath, replicatedDb,
                     slaveReplPort),
                 "XRE09");
 
         assertException(
-                stopSlave(slaveServerHost,slaveServerPort,
+                _stopSlave(slaveServerHost,slaveServerPort,
                     slaveDatabasePath, replicatedDb,
                     slaveReplPort),
                 "XRE40");
         
         assertException(
-                failOver(slaveServerHost,slaveServerPort,
+                _failOver(slaveServerHost,slaveServerPort,
                     slaveDatabasePath, slaveDbSubPath, replicatedDb),
                 "XRE07");
         
         // Tests against master:
         assertException(
-                startMaster(masterServerHost,masterServerPort,
+                _startMaster(masterServerHost,masterServerPort,
                     masterDatabasePath, replicatedDb,
                     slaveServerHost,slaveReplPort),
                 "XRE04");
         
         assertException(
-                failOver(masterServerHost,masterServerPort,
+                _failOver(masterServerHost,masterServerPort,
                     masterDatabasePath, masterDbSubPath, replicatedDb),
                 "XRE07");
         
         // connect / show tables
         assertException(
-                executeQuery(mConn, "select count(*) from SYS.SYSTABLES"), 
+                _executeQuery(mConn, "select count(*) from SYS.SYSTABLES"), 
                 "08006"); // Thats's just how it is...
          assertException(
-                executeQuery(mConn, "select count(*) from SYS.SYSTABLES"), 
+                _executeQuery(mConn, "select count(*) from SYS.SYSTABLES"), 
                 "08003"); // Thats's just how it is...
         
         // Tests against slave:
         Connection sConn = getConnection(slaveServerHost, slaveServerPort, 
                     slaveDatabasePath, slaveDbSubPath, replicatedDb); // OK
          assertException(
-                executeQuery(sConn, "select count(*) from SYS.SYSTABLES"), 
+                _executeQuery(sConn, "select count(*) from SYS.SYSTABLES"), 
                 null); // null: Should be OK
          sConn.close();
     }
@@ -283,7 +285,7 @@
                 + " No value-adding suggestions here.");
     }
     
-    SQLException startSlave(String slaveServerHost, int slaveServerPort,
+    SQLException _startSlave(String slaveServerHost, int slaveServerPort,
             String slaveDatabasePath, String replicatedDb,
             int slaveReplPort)
     {
@@ -307,7 +309,7 @@
         }
     }
 
-    SQLException stopSlave(String slaveServerHost, int slaveServerPort, 
+    SQLException _stopSlave(String slaveServerHost, int slaveServerPort, 
             String slaveDatabasePath, String replicatedDb, 
             int slaveReplPort)
     {
@@ -331,7 +333,7 @@
         }
     }
 
-    SQLException failOver(String serverHost, int serverPort, 
+    SQLException _failOver(String serverHost, int serverPort, 
             String databasePath, String dbSubPath, String replicatedDb)
     {
         String db = databasePath +FS+dbSubPath +FS+ replicatedDb;
@@ -352,7 +354,7 @@
         }
     }
     
-    SQLException startMaster(String masterServerHost, int masterServerPort,
+    SQLException _startMaster(String masterServerHost, int masterServerPort,
             String databasePath, String replicatedDb,
             String slaveServerHost,
             int slaveReplPort)
@@ -377,18 +379,6 @@
         }
     }
 
-    Connection getConnection(String serverHost, int serverPort,
-            String databasePath, String dbSubPath, String replicatedDb)
-        throws SQLException
-    {
-        String db = databasePath +FS+dbSubPath +FS+ replicatedDb;
-        String connectionURL = "jdbc:derby:"  
-                + "//" + serverHost + ":" + serverPort + "/"
-                + db;
-        util.DEBUG(connectionURL);
-        return DriverManager.getConnection(connectionURL);
-    }
-    
     SQLException connectTo(String serverHost, int serverPort,
             String databasePath, String dbSubPath, String replicatedDb)
     {
@@ -409,7 +399,7 @@
         }
     }
 
-    SQLException executeQuery(Connection conn, String query)
+    SQLException _executeQuery(Connection conn, String query)
     {
         util.DEBUG("executeQuery: " + query);
         try

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java?rev=799091&r1=799090&r2=799091&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationSuite.java
Wed Jul 29 21:42:54 2009
@@ -50,6 +50,8 @@
         
 		suite.addTest(ReplicationRun_Local_1.suite());
         
+		suite.addTest(ReplicationRun_Local_1Indexing.suite());
+		
 		suite.addTest(ReplicationRun_Local_StateTest_part1.suite());
 		suite.addTest(ReplicationRun_Local_StateTest_part1_1.suite());
 		suite.addTest(ReplicationRun_Local_StateTest_part1_2.suite());
@@ -65,6 +67,12 @@
         suite.addTest(ReplicationRun_Local_3_p3.suite());
         suite.addTest(ReplicationRun_Local_3_p4.suite());
         
+		suite.addTest(ReplicationRun_Local_3_p5.suite()); // Test for DERBY-3878
+		
+		suite.addTest(ReplicationRun_Local_Encrypted_1.suite());
+		
+		suite.addTest(ReplicationRun_Local_3_p6.suite());
+		
 		return suite;
 	}
 }



Mime
View raw message